summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2001-09-15 15:06:10 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2001-09-15 15:06:10 +0000
commit79c2889d61649d36c7b3688dfa55c0ce1616fa12 (patch)
tree9771d49ba2c9a6dda8cae15c55620dae5fa6d375
parentcf6f3a5084b9c5150228dc7560ed5e99d228d3e8 (diff)
downloaddrakx-79c2889d61649d36c7b3688dfa55c0ce1616fa12.tar
drakx-79c2889d61649d36c7b3688dfa55c0ce1616fa12.tar.gz
drakx-79c2889d61649d36c7b3688dfa55c0ce1616fa12.tar.bz2
drakx-79c2889d61649d36c7b3688dfa55c0ce1616fa12.tar.xz
drakx-79c2889d61649d36c7b3688dfa55c0ce1616fa12.zip
Command line commands as "lpr", "lpq", ... are mapped to the correct spooler now.
-rw-r--r--perl-install/printer.pm27
-rw-r--r--perl-install/printerdrake.pm28
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};
}