summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorTill Kamppeter <tkamppeter@mandriva.com>2001-08-12 21:41:27 +0000
committerTill Kamppeter <tkamppeter@mandriva.com>2001-08-12 21:41:27 +0000
commitcc1544f519cec27e9872bc04077b0dd0161b6845 (patch)
treed5f710c98243fd196ff728dc58e7ed1ed05e3d27 /perl-install
parente025fbd6340efa676817f635c36835874485476e (diff)
downloaddrakx-cc1544f519cec27e9872bc04077b0dd0161b6845.tar
drakx-cc1544f519cec27e9872bc04077b0dd0161b6845.tar.gz
drakx-cc1544f519cec27e9872bc04077b0dd0161b6845.tar.bz2
drakx-cc1544f519cec27e9872bc04077b0dd0161b6845.tar.xz
drakx-cc1544f519cec27e9872bc04077b0dd0161b6845.zip
Check files before checking RPM database => Acceleration, waiting windows
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/printer.pm10
-rw-r--r--perl-install/printerdrake.pm143
2 files changed, 119 insertions, 34 deletions
diff --git a/perl-install/printer.pm b/perl-install/printer.pm
index a592dbcb8..9ed8dbb90 100644
--- a/perl-install/printer.pm
+++ b/perl-install/printer.pm
@@ -110,6 +110,14 @@ sub stop_service ($) {
|| die "Could not stop $service!";
}
+sub files_exist {
+ my @files = @_;
+ for (@files) {
+ if (! -f "$prefix$_") {return 0;}
+ }
+ return 1;
+}
+
sub copy_printer_params($$) {
my ($from, $to) = @_;
map { $to->{$_} = $from->{$_} } grep { $_ ne 'configured' } keys %$from;
@@ -750,7 +758,7 @@ sub print_pages($@) {
# images must be treated seperately
if ($page =~ /\.jpg$/) {
system(($::testing ? "$prefix" : "chroot $prefix/ ") .
- "convert $page -page 427x654+100+65 PS:- | " .
+ "/usr/bin/convert $page -page 427x654+100+65 PS:- | " .
"$lpr -s $printer->{SPOOLER} -P $queue");
} else {
run_program::rooted($prefix, $lpr, "-s", $printer->{SPOOLER},
diff --git a/perl-install/printerdrake.pm b/perl-install/printerdrake.pm
index f4c6a621e..7d75106bd 100644
--- a/perl-install/printerdrake.pm
+++ b/perl-install/printerdrake.pm
@@ -281,7 +281,10 @@ complete => sub {
#- LPD does not support filtered queues to a remote LPD server by itself
#- It needs an additional program as "rlpr"
- $printer->{SPOOLER} eq 'lpd' and $in->do_pkgs->install('rlpr');
+ if (($printer->{SPOOLER} eq 'lpd') && (!$::testing) &&
+ (!printer::files_exist((qw(/usr/bin/rlpr))))) {
+ $in->do_pkgs->install('rlpr');
+ }
1;
}
@@ -370,7 +373,10 @@ complete => sub {
($smbpassword && ":$smbpassword") . "@")), ($workgroup && ("$workgroup/")),
($smbserver || $smbserverip), "/$smbshare");
- $in->do_pkgs->install('samba-client');
+ if ((!$::testing) &&
+ (!printer::files_exist((qw(/usr/bin/smbclient))))) {
+ $in->do_pkgs->install('samba-client');
+ }
$printer->{SPOOLER} eq 'cups' and printer::restart_queue($printer);
1;
}
@@ -440,7 +446,11 @@ complete => sub {
($ncppassword && ":$ncppassword") . "@")),
"$ncpserver/$ncpqueue");
- $in->do_pkgs->install('ncpfs');
+ if ((!$::testing) &&
+ (!printer::files_exist((qw(/usr/bin/nprint))))) {
+ $in->do_pkgs->install('ncpfs');
+ }
+
1;
}
@@ -489,7 +499,11 @@ complete => sub {
join '', ("socket://$remotehost", $remoteport ? (":$remoteport") : ());
#- LPD and LPRng need netcat ('nc') to access to socket printers
- $printer->{SPOOLER} eq 'lpd' || $printer->{SPOOLER} eq 'lprng' and $in->do_pkgs->install('nc');
+ if ((($printer->{SPOOLER} eq 'lpd') || ($printer->{SPOOLER} eq 'lprng'))&&
+ (!$::testing) &&
+ (!printer::files_exist((qw(/usr/bin/nc))))) {
+ $in->do_pkgs->install('nc');
+ }
1;
}
@@ -519,13 +533,32 @@ complete => sub {
return 0;
}
);
- if ($printer->{currentqueue}{'connect'} =~ /^smb:/) {
- $in->do_pkgs->install('samba-client');
- printer::restart_queue($printer);
+
+ # If the chosen protocol needs additional software, install it.
+
+ # LPD does not support filtered queues to a remote LPD server by itself
+ # It needs an additional program as "rlpr"
+ if (($printer->{currentqueue}{'connect'} =~ /^lpd:/) &&
+ ($printer->{SPOOLER} eq 'lpd') && (!$::testing) &&
+ (!printer::files_exist((qw(/usr/bin/rlpr))))) {
+ $in->do_pkgs->install('rlpr');
+ }
+ if (($printer->{currentqueue}{'connect'} =~ /^smb:/) &&
+ (!$::testing) &&
+ (!printer::files_exist((qw(/usr/bin/smbclient))))) {
+ $in->do_pkgs->install('samba-client');
+ }
+ if (($printer->{currentqueue}{'connect'} =~ /^ncp:/) &&
+ (!$::testing) &&
+ (!printer::files_exist((qw(/usr/bin/nprint))))) {
+ $in->do_pkgs->install('ncpfs');
}
- if ($printer->{currentqueue}{'connect'} =~ /^ncp:/) {
- $in->do_pkgs->install('ncpfs');
- printer::restart_queue($printer);
+ #- LPD and LPRng need netcat ('nc') to access to socket printers
+ if (($printer->{currentqueue}{'connect'} =~ /^socket:/) &&
+ (($printer->{SPOOLER} eq 'lpd') || ($printer->{SPOOLER} eq 'lprng'))&&
+ (!$::testing) &&
+ (!printer::files_exist((qw(/usr/bin/nc))))) {
+ $in->do_pkgs->install('nc');
}
1;
}
@@ -961,7 +994,10 @@ In most cases it is enough to print the standard test page."),
my $asciitestpage = "/usr/share/printer-testpages/testpage.asc";
my @testpages;
# Install the filter to convert the photo test page to PS
- $photo && $in->do_pkgs->install('ImageMagick');
+ if (($photo) && (!$::testing) &&
+ (!printer::files_exist((qw(/usr/bin/convert))))) {
+ $in->do_pkgs->install('ImageMagick');
+ }
# set up list of pages to print
$standard && push (@testpages, $stdtestpage);
$altletter && push (@testpages, $altlttestpage);
@@ -1019,29 +1055,59 @@ sub install_spooler {
my ($printer, $in) = @_;
if (!$::testing) {
if ($printer->{SPOOLER} eq "cups") {
- $in->do_pkgs->install(('cups', 'xpp', 'qtcups',
- if_($in->do_pkgs->is_installed('kdebase'), 'kups'),
- ($::expert ? 'cups-drivers' : ())));
+ if ((!$::testing) &&
+ (!printer::files_exist((qw(/usr/lib/cups/cgi-bin/printers.cgi
+ /usr/bin/xpp
+ /usr/bin/qtcups),
+ (printer::files_exist("/usr/bin/kwin")?
+ "/usr/bin/kups" : ()),
+ ($::expert ?
+ "/usr/share/cups/model/postscript.ppd.gz" : ())
+ )))) {
+ $in->do_pkgs->install(('cups', 'xpp', 'qtcups',
+ if_($in->do_pkgs->is_installed('kdebase'), 'kups'),
+ ($::expert ? 'cups-drivers' : ())));
+ }
# Start daemon
printer::start_service("cups");
- sleep 1;
+ #sleep 1;
} elsif ($printer->{SPOOLER} eq "lpd") {
# "lpr" conflicts with "LPRng", remove "LPRng"
- $in->do_pkgs->remove_nodeps('LPRng');
- $in->do_pkgs->install('lpr');
+ if ((!$::testing) &&
+ (printer::files_exist((qw(/usr/lib/filters/lpf))))) {
+ my $w = $in->wait_message('', _("Removing LPRng..."));
+ $in->do_pkgs->remove_nodeps('LPRng');
+ }
+ if ((!$::testing) &&
+ (!printer::files_exist((qw(/usr/sbin/lpf
+ /usr/sbin/lpd))))) {
+ $in->do_pkgs->install('lpr');
+ }
# Start daemon
printer::restart_service("lpd");
- sleep 1;
+ #sleep 1;
} elsif ($printer->{SPOOLER} eq "lprng") {
# "LPRng" conflicts with "lpr", remove "lpr"
- $in->do_pkgs->remove_nodeps('lpr');
- $in->do_pkgs->install('LPRng');
+ if ((!$::testing) &&
+ (printer::files_exist((qw(/usr/sbin/lpf))))) {
+ my $w = $in->wait_message('', _("Removing LPD..."));
+ $in->do_pkgs->remove_nodeps('lpr');
+ }
+ if ((!$::testing) &&
+ (!printer::files_exist((qw(/usr/lib/filters/lpf
+ /usr/sbin/lpd))))) {
+ $in->do_pkgs->install('LPRng');
+ }
# Start daemon
printer::restart_service("lpd");
- sleep 1;
+ #sleep 1;
} elsif ($printer->{SPOOLER} eq "pdq") {
- $in->do_pkgs->install('pdq');
- # PDQ has no daemon
+ if ((!$::testing) &&
+ (!printer::files_exist((qw(/usr/bin/pdq
+ /usr/X11R6/bin/xpdq))))) {
+ $in->do_pkgs->install('pdq');
+ }
+ # PDQ has no daemon, so nothing needs to be started
}
}
}
@@ -1052,19 +1118,30 @@ sub main {
# printerdrake does not work without foomatic, and for more convenience
# we install some more stuff
- if (!$::testing) {
- $in->do_pkgs->install('foomatic', 'printer-utils','printer-testpages',
- if_($in->do_pkgs->is_installed('gimp'), 'gimpprint'));
- }
+ {
+ my $w = $in->wait_message('', _("Checking installed software..."));
+ if ((!$::testing) &&
+ (!printer::files_exist((qw(/usr/sbin/foomatic-configure
+ /usr/lib/perl5/site_perl/5.6.1/Foomatic/DB.pm
+ /usr/bin/escputil
+ /usr/share/printer-testpages/testprint.ps
+ ),
+ (printer::files_exist("/usr/bin/gimp") ?
+ "/usr/lib/gimp/1.2/plug-ins/print" : ())
+ )))) {
+ $in->do_pkgs->install('foomatic', 'printer-utils','printer-testpages',
+ if_($in->do_pkgs->is_installed('gimp'), 'gimpprint'));
+ }
- # only experts should be asked for the spooler
- !$::expert && ($printer->{SPOOLER} ||= 'cups');
+ # only experts should be asked for the spooler
+ !$::expert && ($printer->{SPOOLER} ||= 'cups');
- # If we have chosen a spooler, install it.
- if (($printer->{SPOOLER}) && ($printer->{SPOOLER} ne '')) {
- install_spooler($printer, $in);
- }
+ # If we have chosen a spooler, install it.
+ if (($printer->{SPOOLER}) && ($printer->{SPOOLER} ne '')) {
+ install_spooler($printer, $in);
+ }
+ }
# Control variables for the main loop
my ($queue, $continue, $newqueue, $editqueue, $expertswitch) =
('', 1, 0, 0, 0);