diff options
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/printer.pm | 27 | ||||
-rw-r--r-- | perl-install/printerdrake.pm | 28 |
2 files changed, 55 insertions, 0 deletions
diff --git a/perl-install/printer.pm b/perl-install/printer.pm index bd10417b1..454909cda 100644 --- a/perl-install/printer.pm +++ b/perl-install/printer.pm @@ -196,6 +196,33 @@ sub files_exist { return 1; } +sub set_alternative { + my ($command, $executable) = @_; + local *F; + # Read the list of executables for the given command to find the number + # of the desired executable + open F, ($::testing ? "$prefix" : "chroot $prefix/ ") . + "/bin/sh -c \"export LC_ALL=C; /bin/echo | update-alternatives --config $command \" |" || + die "Could not run \"update-alternatives\"!"; + my $choice = 0; + while (<F>) { + chomp; + if ($_ =~ m/^[\* ][\+ ]\s*([0-9]+)\s+(\S+)\s*$/) { # list entry? + if ($2 eq $executable) { + $choice = $1; + last; + } + } + } + close F; + # If the executable was found, assign the command to it + if ($choice > 0) { + system(($::testing ? "$prefix" : "chroot $prefix/ ") . + "/bin/sh -c \"/bin/echo $choice | update-alternatives --config $command > /dev/null 2>&1\""); + } + return 1; +} + sub copy_printer_params($$) { my ($from, $to) = @_; map { $to->{$_} = $from->{$_} } grep { $_ ne 'configured' } keys %$from; diff --git a/perl-install/printerdrake.pm b/perl-install/printerdrake.pm index 6a6ae3c85..4a73c86c6 100644 --- a/perl-install/printerdrake.pm +++ b/perl-install/printerdrake.pm @@ -1422,6 +1422,14 @@ sub install_spooler { printer::start_service("cups"); # Should it be started at boot time? start_spooler_on_boot($printer, $in, "cups"); + # Set the CUPS tools as defaults for "lpr", "lpq", "lprm", ... + printer::set_alternative("lpr","/usr/bin/lpr-cups"); + printer::set_alternative("lpq","/usr/bin/lpq-cups"); + printer::set_alternative("lprm","/usr/bin/lprm-cups"); + printer::set_alternative("lp","/usr/bin/lp-cups"); + printer::set_alternative("cancel","/usr/bin/cancel-cups"); + printer::set_alternative("lpstat","/usr/bin/lpstat-cups"); + printer::set_alternative("lpc","/usr/sbin/lpc-cups"); } elsif ($printer->{SPOOLER} eq "lpd") { # "lpr" conflicts with "LPRng", remove "LPRng" if ((!$::testing) && @@ -1442,6 +1450,11 @@ sub install_spooler { printer::restart_service("lpd"); # Should it be started at boot time? start_spooler_on_boot($printer, $in, "lpd"); + # Set the LPD tools as defaults for "lpr", "lpq", "lprm", ... + printer::set_alternative("lpr","/usr/bin/lpr-lpd"); + printer::set_alternative("lpq","/usr/bin/lpq-lpd"); + printer::set_alternative("lprm","/usr/bin/lprm-lpd"); + printer::set_alternative("lpc","/usr/sbin/lpc-lpd"); } elsif ($printer->{SPOOLER} eq "lprng") { # "LPRng" conflicts with "lpr", remove "lpr" if ((!$::testing) && @@ -1462,6 +1475,14 @@ sub install_spooler { printer::restart_service("lpd"); # Should it be started at boot time? start_spooler_on_boot($printer, $in, "lpd"); + # Set the LPD tools as defaults for "lpr", "lpq", "lprm", ... + printer::set_alternative("lpr","/usr/bin/lpr-lpd"); + printer::set_alternative("lpq","/usr/bin/lpq-lpd"); + printer::set_alternative("lprm","/usr/bin/lprm-lpd"); + printer::set_alternative("lp","/usr/bin/lp-lpd"); + printer::set_alternative("cancel","/usr/bin/cancel-lpd"); + printer::set_alternative("lpstat","/usr/bin/lpstat-lpd"); + printer::set_alternative("lpc","/usr/sbin/lpc-lpd"); } elsif ($printer->{SPOOLER} eq "pdq") { if ((!$::testing) && (!printer::files_exist((qw(/usr/bin/pdq @@ -1469,6 +1490,11 @@ sub install_spooler { $in->do_pkgs->install('pdq'); } # PDQ has no daemon, so nothing needs to be started + + # Set the LPD tools as defaults for "lpr", "lpq", "lprm", ... + printer::set_alternative("lpr","/usr/bin/lpr-pdq"); + printer::set_alternative("lpq","/usr/bin/lpq-foomatic"); + printer::set_alternative("lprm","/usr/bin/lprm-foomatic"); } } 1; @@ -1504,6 +1530,8 @@ sub setup_default_spooler { %printer::thedb = (); #my $w = $in->wait_message('', _("Reading printer database ...")); #printer::read_printer_db($printer->{SPOOLER}); + # Save spooler choice + printer::set_default_spooler($printer); } return $printer->{SPOOLER}; } |