summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorFrancois Pons <fpons@mandriva.com>2000-03-17 18:28:37 +0000
committerFrancois Pons <fpons@mandriva.com>2000-03-17 18:28:37 +0000
commitc2291d42ccff39452769c2c5d1e62842765dcf7b (patch)
tree14ce67c307837e19500279e7d0133ac53933f329 /perl-install
parent3622540f67228fabb5399876b5af89f37cf461be (diff)
downloaddrakx-c2291d42ccff39452769c2c5d1e62842765dcf7b.tar
drakx-c2291d42ccff39452769c2c5d1e62842765dcf7b.tar.gz
drakx-c2291d42ccff39452769c2c5d1e62842765dcf7b.tar.bz2
drakx-c2291d42ccff39452769c2c5d1e62842765dcf7b.tar.xz
drakx-c2291d42ccff39452769c2c5d1e62842765dcf7b.zip
*** empty log message ***
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/ChangeLog11
-rw-r--r--perl-install/commands.pm1
-rw-r--r--perl-install/common.pm6
-rw-r--r--perl-install/install_steps.pm12
-rw-r--r--perl-install/install_steps_interactive.pm3
-rw-r--r--perl-install/mouse.pm2
-rw-r--r--perl-install/pkgs.pm2
-rw-r--r--perl-install/printer.pm146
-rw-r--r--perl-install/printerdrake.pm151
-rwxr-xr-xperl-install/standalone/printerdrake3
10 files changed, 170 insertions, 167 deletions
diff --git a/perl-install/ChangeLog b/perl-install/ChangeLog
index 360913b34..46ceb7531 100644
--- a/perl-install/ChangeLog
+++ b/perl-install/ChangeLog
@@ -1,3 +1,14 @@
+2000-03-17 François Pons <fpons@mandrakesoft.com>
+
+ * install_steps.pm: added setup for all configured queue.
+ * install_steps_interactive.pm: modified for retrieving packages
+ or current configuration.
+ * printer.pm: correction, tested retrieve of printer
+ configuration without printtool comments in printcap file: added
+ update of entry according to gsdriver used (untested again).
+ * printerdrake.pm: better handling of cancel, manage of multiple
+ queue definition together (as lp|My printer).
+
2000-03-16 François Pons <fpons@mandrakesoft.com>
* install_steps_interactive.pm: moved in printerdrake.pm the test
diff --git a/perl-install/commands.pm b/perl-install/commands.pm
index 1f2170de2..0c49dd87a 100644
--- a/perl-install/commands.pm
+++ b/perl-install/commands.pm
@@ -99,6 +99,7 @@ sub mkdir_ {
$rec or die "mkdir: $root does not exist (try option -p)\n";
&$mkdir($root);
}
+ $rec and -d $_[0] and return;
mkdir $_[0], 0755 or die "mkdir: error creating directory $_: $!\n";
};
&$mkdir($_) foreach @_;
diff --git a/perl-install/common.pm b/perl-install/common.pm
index 0e75369ce..777038e2e 100644
--- a/perl-install/common.pm
+++ b/perl-install/common.pm
@@ -367,11 +367,7 @@ sub template2file($$%) {
local *OUT; local *IN;
open IN, $inputfile or die "Can't open $inputfile $!";
- if ($::testing) {
- *OUT = *STDOUT;
- } else {
- open OUT, ">$outputfile" or die "Can't open $outputfile $!";
- }
+ open OUT, ">$outputfile" or die "Can't open $outputfile $!";
map { s/@@@(.*?)@@@/$toreplace{$1}/g; print OUT; } <IN>;
}
diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm
index 146447a0a..5abd53cff 100644
--- a/perl-install/install_steps.pm
+++ b/perl-install/install_steps.pm
@@ -465,13 +465,19 @@ sub servicesConfig {}
#------------------------------------------------------------------------------
sub printerConfig {
my($o) = @_;
- if ($o->{printer}{complete}) {
- require printer;
+ if ($o->{printer}{configured}) {
require pkgs;
pkgs::selectPackage($o->{packages}, pkgs::packageByName($o->{packages}, 'rhs-printfilters'));
$o->installPackages($o->{packages});
- printer::configure_queue($o->{printer});
+ require printer;
+ foreach (keys %{$o->{printer}{configured} || {}}) {
+ log::l("configuring printer queue $_->{queue}");
+ printer::copy_printer_params($_, $o->{printer});
+ #- setup all configured queues, which is not the case interactively where
+ #- only the working queue is setup on configuration.
+ printer::configure_queue($o->{printer});
+ }
}
}
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index 157df8c82..18b9e3059 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -560,8 +560,9 @@ sub servicesConfig {
sub printerConfig($) {
my ($o) = @_;
+ require printer;
+ eval { add2hash($o->{printer} ||= {}, printer::getinfo($o->{prefix})) };
require printerdrake;
- eval { add2hash($o->{printer}, printerdrake::getinfo($o->{prefix})) };
printerdrake::main($o->{printer}, $o, sub { install_any::pkg_install($o, $_[0]) });
}
diff --git a/perl-install/mouse.pm b/perl-install/mouse.pm
index 3cf91bd7a..0e8c18d7e 100644
--- a/perl-install/mouse.pm
+++ b/perl-install/mouse.pm
@@ -155,6 +155,4 @@ sub detect() {
#- defaults to generic ttyS0
add2hash({ device => "ttyS0", unsafe => 1 }, name2mouse("Generic Mouse (serial)"));
-
-#- die "mouseconfig failed";
}
diff --git a/perl-install/pkgs.pm b/perl-install/pkgs.pm
index faba585f5..c391b2494 100644
--- a/perl-install/pkgs.pm
+++ b/perl-install/pkgs.pm
@@ -722,7 +722,7 @@ sub install($$$;$$) {
my ($prefix, $isUpgrade, $toInstall, $depOrder, $media) = @_;
my %packages;
- return if $::g_auto_install;
+ return if $::g_auto_install || !scalar(@$toInstall);
#- first stage to extract some important informations
#- about the packages selected. this is used to select
diff --git a/perl-install/printer.pm b/perl-install/printer.pm
index f8e34452c..68127f0ff 100644
--- a/perl-install/printer.pm
+++ b/perl-install/printer.pm
@@ -269,6 +269,56 @@ $spooldir = "/var/spool/lpd";
#-#####################################################################################
sub set_prefix($) { $prefix = $_[0]; }
+
+sub default_queue($) { (split '\|', $_[0])[0] }
+
+sub copy_printer_params($$) {
+ my ($from, $to) = @_;
+ map { $to->{$_} = $from->{$_} } grep { $_ ne 'configured' } keys %$from; #- avoid cycles.
+}
+
+sub getinfo($) {
+ my ($prefix) = @_;
+ my $printer = {};
+
+ set_prefix($prefix);
+ read_configured_queue($printer);
+
+ add2hash($printer, {
+ want => 0,
+ complete => 0,
+ str_type => $printer::printer_type_default,
+ QUEUE => "lp",
+ SPOOLDIR => "/var/spool/lpd/lp",
+ DBENTRY => "PostScript",
+ PAPERSIZE => "letter",
+ ASCII_TO_PS => undef,
+ CRLF => undef,
+ NUP => 1,
+ RTLFTMAR => 18,
+ TOPBOTMAR => 18,
+ AUTOSENDEOF => 1,
+
+ DEVICE => "/dev/lp0",
+
+ REMOTEHOST => "",
+ REMOTEQUEUE => "",
+
+ NCPHOST => "", #-"printerservername",
+ NCPQUEUE => "", #-"queuename",
+ NCPUSER => "", #-"user",
+ NCPPASSWD => "", #-"pass",
+
+ SMBHOST => "", #-"hostname",
+ SMBHOSTIP => "", #-"1.2.3.4",
+ SMBSHARE => "", #-"printername",
+ SMBUSER => "", #-"user",
+ SMBPASSWD => "", #-"passowrd",
+ SMBWORKGROUP => "", #-"AS3",
+ });
+ $printer;
+}
+
#-*****************************************************************************
#- read function
#-*****************************************************************************
@@ -281,7 +331,7 @@ sub read_printer_db(;$) {
%thedb and return;
my %available_devices; #- keep only available devices in our database.
- local *AVAIL; open AVAIL, (!$::testing && "chroot ") . "$prefix/usr/bin/gs --help |";
+ local *AVAIL; open AVAIL, ($::testing ? "$prefix" : "chroot $prefix ") . "/usr/bin/gs --help |";
foreach (<AVAIL>) {
if (/^Available devices:/ ... /^\S/) {
@available_devices{split /\s+/, $_} = () if /^\s+/;
@@ -297,10 +347,7 @@ sub read_printer_db(;$) {
while (<DBPATH>) {
if (/^StartEntry:\s(\w*)/) {
- my $entryname = $1;
- my $entry;
-
- $entry->{ENTRY} = $entryname;
+ my $entry = { ENTRY => $1 };
WHILE :
while (<DBPATH>) {
@@ -318,23 +365,23 @@ sub read_printer_db(;$) {
}
};
/Resolution:\s*{(.*)}\s*{(.*)}\s*{(.*)}/
- and do { push @{$entry->{RESOLUTION}}, { XDPI => $1, YDPI => $2, DESCR => $3 }; last SWITCH };
+ and do { push @{$entry->{RESOLUTION} ||= []}, { XDPI => $1, YDPI => $2, DESCR => $3 }; last SWITCH };
/BitsPerPixel:\s*{(.*)}\s*{(.*)}/
- and do { push @{$entry->{BITSPERPIXEL}}, {DEPTH => $1, DESCR => $2}; last SWITCH };
+ and do { push @{$entry->{BITSPERPIXEL} ||= []}, {DEPTH => $1, DESCR => $2}; last SWITCH };
/EndEntry/ and last WHILE;
}
}
if (exists $available_devices{$entry->{GSDRIVER}}) {
- $thedb{$entryname} = $entry;
+ $thedb{$entry->{ENTRY}} = $entry;
$thedb_gsdriver{$entry->{GSDRIVER}} = $entry;
}
}
}
@entries_db_short = sort keys %printer::thedb;
- @entry_db_description = map { $printer::thedb{$_}{DESCR} } @entries_db_short;
%descr_to_db = map { $printer::thedb{$_}{DESCR}, $_ } @entries_db_short;
+ @entry_db_description = keys %descr_to_db;
%db_to_descr = reverse %descr_to_db;
}
@@ -350,15 +397,14 @@ sub create_spool_dir($) {
my ($queue_path) = @_;
my $complete_path = "$prefix/$queue_path";
- unless (-d $complete_path) {
- mkdir "$complete_path", 0755
- or die "An error has occurred - can't create $complete_path : $!";
- }
+ commands::mkdir_("-p", $complete_path);
- #-redhat want that "drwxr-xr-x root lp"
- my $gid_lp = (getpwnam("lp"))[3];
- chown 0, $gid_lp, $complete_path
- or die "An error has occurred - can't chgrp $complete_path to lp $!";
+ unless ($::testing) {
+ #-redhat want that "drwxr-xr-x root lp"
+ my $gid_lp = (getpwnam("lp"))[3];
+ chown 0, $gid_lp, $complete_path
+ or die "An error has occurred - can't chgrp $complete_path to lp $!";
+ }
}
#------------------------------------------------------------------------------
@@ -394,9 +440,8 @@ my $intro_printcap_test = "
# Please don't edit this file directly unless you know what you are doing!
# Look at the printcap(5) man page for more info.
# Be warned that the control-panel printtool requires a very strict format!
-# Look at the printcap(5) man page for more info.
#
-# This file can be edited with the printtool in the control-panel.
+# This file can be edited with printerdrake or printtool.
#
";
@@ -446,9 +491,9 @@ sub read_configured_queue($) {
local *F; open F, "$prefix$entry->{SPOOLDIR}/general.cfg" or next;
foreach (<F>) {
chomp;
- if (/^\s*(?:export\s+)PRINTER_TYPE=(.*?)\s*$/) { $entry->{TYPE} = $1 unless defined $entry->{TYPE} }
- elsif (/^\s*(?:export\s+)ASCII_TO_PS=(.*?)\s*$/) { $entry->{ASCII_TO_PS} = $1 eq 'YES' unless defined $entry->{ASCII_TO_PS} }
- elsif (/^\s*(?:export\s+)PAPER_SIZE=(.*?)\s*$/) { $entry->{PAPERSIZE} = $1 unless defined $entry->{PAPERSIZE} }
+ if (/^\s*(?:export\s+)?PRINTER_TYPE=(.*?)\s*$/) { $entry->{TYPE} = $1 unless defined $entry->{TYPE} }
+ elsif (/^\s*(?:export\s+)?ASCII_TO_PS=(.*?)\s*$/) { $entry->{ASCII_TO_PS} = $1 eq 'YES' unless defined $entry->{ASCII_TO_PS} }
+ elsif (/^\s*(?:export\s+)?PAPER_SIZE=(.*?)\s*$/) { $entry->{PAPERSIZE} = $1 unless defined $entry->{PAPERSIZE} }
}
close F;
}
@@ -459,17 +504,17 @@ sub read_configured_queue($) {
local *F; open F, "$prefix$entry->{SPOOLDIR}/postscript.cfg" or next;
foreach (<F>) {
chomp;
- if (/^\s*(?:export\s+)GSDEVICE=(.*?)\s*$/) { $entry->{DBENTRY} = $thedb_gsdriver{$1}{ENTRY} unless defined $entry->{DBENTRY} }
- elsif (/^\s*(?:export\s+)RESOLUTION=(.*?)\s*$/) { $entry->{RESOLUTION} = $1 unless defined $entry->{RESOLUTION} }
- elsif (/^\s*(?:export\s+)COLOR=-dBitsPerPixel=(.*?)\s*$/) { $entry->{COLOR} = $1 unless defined $entry->{COLOR} }
- elsif (/^\s*(?:export\s+)COLOR=(.*?)\s*$/) { $entry->{COLOR} = $1 ? $1 : 'Default' unless defined $entry->{COLOR} }
- elsif (/^\s*(?:export\s+)PAPERSIZE=(.*?)\s*$/) { $entry->{PAPERSIZE} = $1 unless defined $entry->{PAPERSIZE} }
- elsif (/^\s*(?:export\s+)EXTRA_GS_OPTIONS=(.*?)\s*$/) { $entry->{EXTRA_GS_OPTIONS} = $1 unless defined $entry->{EXTRA_GS_OPTIONS}; $entry->{EXTRA_GS_OPTIONS} =~ s/^\"(.*)\"/$1/ }
- elsif (/^\s*(?:export\s+)REVERSE_ORDER=(.*?)\s*$/) { $entry->{REVERSE_ORDER} = $1 unless defined $entry->{REVERSE_ORDER} }
- elsif (/^\s*(?:export\s+)PS_SEND_EOF=(.*?)\s*$/) { $entry->{AUTOSENDEOF} = $1 eq 'YES' && $entry->{DBENTRY} eq 'PostScript' unless defined $entry->{AUTOSENDEOF} }
- elsif (/^\s*(?:export\s+)NUP=(.*?)\s*$/) { $entry->{NUP} = $1 unless defined $entry->{NUP} }
- elsif (/^\s*(?:export\s+)RTLFTMAR=(.*?)\s*$/) { $entry->{RTLFTMAR} = $1 unless defined $entry->{RTLFTMAR} }
- elsif (/^\s*(?:export\s+)TOPBOTMAR=(.*?)\s*$/) { $entry->{TOPBOTMAR} = $1 unless defined $entry->{TOPBOTMAR} }
+ if (/^\s*(?:export\s+)?GSDEVICE=(.*?)\s*$/) { $entry->{GSDRIVER} = $1 unless defined $entry->{GSDRIVER} }
+ elsif (/^\s*(?:export\s+)?RESOLUTION=(.*?)\s*$/) { $entry->{RESOLUTION} = $1 unless defined $entry->{RESOLUTION} }
+ elsif (/^\s*(?:export\s+)?COLOR=-dBitsPerPixel=(.*?)\s*$/) { $entry->{COLOR} = $1 unless defined $entry->{COLOR} }
+ elsif (/^\s*(?:export\s+)?COLOR=(.*?)\s*$/) { $entry->{COLOR} = $1 ? $1 : 'Default' unless defined $entry->{COLOR} }
+ elsif (/^\s*(?:export\s+)?PAPERSIZE=(.*?)\s*$/) { $entry->{PAPERSIZE} = $1 unless defined $entry->{PAPERSIZE} }
+ elsif (/^\s*(?:export\s+)?EXTRA_GS_OPTIONS=(.*?)\s*$/) { $entry->{EXTRA_GS_OPTIONS} = $1 unless defined $entry->{EXTRA_GS_OPTIONS}; $entry->{EXTRA_GS_OPTIONS} =~ s/^\"(.*)\"/$1/ }
+ elsif (/^\s*(?:export\s+)?REVERSE_ORDER=(.*?)\s*$/) { $entry->{REVERSE_ORDER} = $1 unless defined $entry->{REVERSE_ORDER} }
+ elsif (/^\s*(?:export\s+)?PS_SEND_EOF=(.*?)\s*$/) { $entry->{AUTOSENDEOF} = $1 eq 'YES' && $entry->{DBENTRY} eq 'PostScript' unless defined $entry->{AUTOSENDEOF} }
+ elsif (/^\s*(?:export\s+)?NUP=(.*?)\s*$/) { $entry->{NUP} = $1 unless defined $entry->{NUP} }
+ elsif (/^\s*(?:export\s+)?RTLFTMAR=(.*?)\s*$/) { $entry->{RTLFTMAR} = $1 unless defined $entry->{RTLFTMAR} }
+ elsif (/^\s*(?:export\s+)?TOPBOTMAR=(.*?)\s*$/) { $entry->{TOPBOTMAR} = $1 unless defined $entry->{TOPBOTMAR} }
}
close F;
}
@@ -480,17 +525,17 @@ sub read_configured_queue($) {
local *F; open F, "$prefix$entry->{SPOOLDIR}/textonly.cfg" or next;
foreach (<F>) {
chomp;
- if (/^\s*(?:export\s+)TEXTONLYOPTIONS=(.*?)\s*$/) { $entry->{TEXTONLYOPTIONS} = $1 unless defined $entry->{TEXTONLYOPTIONS}; $entry->{TEXTONLYOPTIONS} =~ s/^\"(.*)\"/$1/ }
- elsif (/^\s*(?:export\s+)CRLFTRANS=(.*?)\s*$/) { $entry->{CRLF} = $1 eq 'YES' unless defined $entry->{CRLF} }
- elsif (/^\s*(?:export\s+)TEXT_SEND_EOF=(.*?)\s*$/) { $entry->{AUTOSENDEOF} = $1 eq 'YES' && $entry->{DBENTRY} ne 'PostScript' unless defined $entry->{AUTOSENDEOF} }
+ if (/^\s*(?:export\s+)?TEXTONLYOPTIONS=(.*?)\s*$/) { $entry->{TEXTONLYOPTIONS} = $1 unless defined $entry->{TEXTONLYOPTIONS}; $entry->{TEXTONLYOPTIONS} =~ s/^\"(.*)\"/$1/ }
+ elsif (/^\s*(?:export\s+)?CRLFTRANS=(.*?)\s*$/) { $entry->{CRLF} = $1 eq 'YES' unless defined $entry->{CRLF} }
+ elsif (/^\s*(?:export\s+)?TEXT_SEND_EOF=(.*?)\s*$/) { $entry->{AUTOSENDEOF} = $1 eq 'YES' && $entry->{DBENTRY} ne 'PostScript' unless defined $entry->{AUTOSENDEOF} }
}
close F;
}
#- get extra parameters for SMB or NCP type queue.
foreach (values %{$printer->{configured}}) {
- if ($_->{TYPE} eq 'SMB') {
- my $entry = $_;
+ my $entry = $_;
+ if ($entry->{TYPE} eq 'SMB') {
my $config_file = "$prefix$entry->{SPOOLDIR}/.config";
local *F; open F, "$config_file" or next; #die "Can't open $config_file $!";
foreach (<F>) {
@@ -509,8 +554,7 @@ sub read_configured_queue($) {
}
}
close F;
- } elsif ($_->{TYPE} eq 'NCP') {
- my $entry = $_;
+ } elsif ($entry->{TYPE} eq 'NCP') {
my $config_file = "$prefix$entry->{SPOOLDIR}/.config";
local *F; open F, "$config_file" or next; #die "Can't open $config_file $!";
foreach (<F>) {
@@ -532,12 +576,7 @@ sub read_configured_queue($) {
sub configure_queue($) {
my ($entry) = @_;
-
- $entry->{SPOOLDIR} ||= "$spooldir/$entry->{QUEUE}";
- $entry->{IF} ||= "$entry->{SPOOLDIR}/filter";
- $entry->{AF} ||= "$entry->{SPOOLDIR}/acct";
-
- my $queue_path = "$entry->{SPOOLDIR}";
+ my $queue_path = "$entry->{SPOOLDIR}";
create_spool_dir($queue_path);
my $get_name_file = sub {
@@ -568,7 +607,7 @@ sub configure_queue($) {
$fieldname{extragsoptions} = "\"$entry->{EXTRA_GS_OPTIONS}\"";
$fieldname{pssendeof} = $entry->{AUTOSENDEOF} ? ($dbentry->{GSDRIVER} eq "POSTSCRIPT" ? "YES" : "NO") : "NO";
$fieldname{nup} = $entry->{NUP};
- $fieldname{rtlftmar} = $entry->{RTFLTMAR};
+ $fieldname{rtlftmar} = $entry->{RTLFTMAR};
$fieldname{topbotmar} = $entry->{TOPBOTMAR};
create_config_file($filein, $file, %fieldname);
@@ -605,15 +644,16 @@ sub configure_queue($) {
#-now the printcap file, note this one contains all the printer (use configured for that).
local *PRINTCAP;
- if ($::testing) {
- *PRINTCAP = *STDOUT;
- } else {
- open PRINTCAP, ">$prefix/etc/printcap" or die "Can't open printcap file $!";
- }
+ open PRINTCAP, ">$prefix/etc/printcap" or die "Can't open printcap file $!";
print PRINTCAP $intro_printcap_test;
foreach (values %{$entry->{configured}}) {
- my $db_ = $thedb{($_->{DBENTRY})} or die "no dbentry";
+ $_->{DBENTRY} = $thedb_gsdriver{$_->{GSDRIVER}}{ENTRY} unless defined $_->{DBENTRY};
+ my $db_ = $thedb{$_->{DBENTRY}} or next; #die "no dbentry";
+
+ $_->{SPOOLDIR} ||= "$spooldir/" . default_queue($_->{QUEUE});
+ $_->{IF} ||= "$_->{SPOOLDIR}/filter";
+ $_->{AF} ||= "$_->{SPOOLDIR}/acct";
printf PRINTCAP "##PRINTTOOL3## %s %s %s %s %s %s %s%s\n",
$_->{TYPE} || '{}',
diff --git a/perl-install/printerdrake.pm b/perl-install/printerdrake.pm
index a6a2061f1..9bf53776d 100644
--- a/perl-install/printerdrake.pm
+++ b/perl-install/printerdrake.pm
@@ -13,53 +13,6 @@ use printer;
1;
-sub getinfo($) {
- my ($prefix) = @_;
- my $printer = {};
-
- printer::set_prefix($prefix);
- printer::read_configured_queue($printer);
-
- add2hash($printer, {
- want => 0,
- complete => 0,
- str_type => $printer::printer_type_default,
- QUEUE => "lp",
- SPOOLDIR => "/var/spool/lpd/lp",
- DBENTRY => "PostScript",
- PAPERSIZE => "letter",
- ASCII_TO_PS => undef,
- CRLF => undef,
- NUP => 1,
- RTLFTMAR => 18,
- TOPBOTMAR => 18,
- AUTOSENDEOF => 1,
-
- DEVICE => "/dev/lp0",
-
- REMOTEHOST => "",
- REMOTEQUEUE => "",
-
- NCPHOST => "", #-"printerservername",
- NCPQUEUE => "", #-"queuename",
- NCPUSER => "", #-"user",
- NCPPASSWD => "", #-"pass",
-
- SMBHOST => "", #-"hostname",
- SMBHOSTIP => "", #-"1.2.3.4",
- SMBSHARE => "", #-"printername",
- SMBUSER => "", #-"user",
- SMBPASSWD => "", #-"passowrd",
- SMBWORKGROUP => "", #-"AS3",
- });
- $printer;
-}
-
-sub copy_printer_params($$) {
- my ($from, $to) = @_;
- map { $to->{$_} = $from->{$_} } grep { $_ ne 'configured' } keys %$from; #- avoid cycles.
-}
-
sub setup_local($$$) {
my ($printer, $in, $install) = @_;
@@ -104,7 +57,7 @@ sub setup_remote($$$) {
_("To use a remote lpd print queue, you need to supply
the hostname of the printer server and the queue name
on that server which jobs should be placed in."), [
-_("Remote hostname:") => \$printer->{REMOTEHOST},
+_("Remote hostname") => \$printer->{REMOTEHOST},
_("Remote queue") => \$printer->{REMOTEQUEUE}, ],
);
}
@@ -119,12 +72,12 @@ SMB host name (Note! It may be different from its
TCP/IP hostname!) and possibly the IP address of the print server, as
well as the share name for the printer you wish to access and any
applicable user name, password, and workgroup information."), [
-_("SMB server host:") => \$printer->{SMBHOST},
-_("SMB server IP:") => \$printer->{SMBHOSTIP},
-_("Share name:") => \$printer->{SMBSHARE},
-_("User name:") => \$printer->{SMBUSER},
-_("Password:") => { val => \$printer->{SMBPASSWD}, hidden => 1 },
-_("Workgroup:") => \$printer->{SMBWORKGROUP} ],
+_("SMB server host") => \$printer->{SMBHOST},
+_("SMB server IP") => \$printer->{SMBHOSTIP},
+_("Share name") => \$printer->{SMBSHARE},
+_("User name") => \$printer->{SMBUSER},
+_("Password") => { val => \$printer->{SMBPASSWD}, hidden => 1 },
+_("Workgroup") => \$printer->{SMBWORKGROUP} ],
complete => sub {
unless (network::is_ip($printer->{SMBHOSTIP})) {
$in->ask_warn('', _("IP address should be in format 1.2.3.4"));
@@ -145,10 +98,10 @@ _("To print to a NetWare printer, you need to provide the
NetWare print server name (Note! it may be different from its
TCP/IP hostname!) as well as the print queue name for the printer you
wish to access and any applicable user name and password."), [
-_("Printer Server:") => \$printer->{NCPHOST},
-_("Print Queue Name:") => \$printer->{NCPQUEUE},
-_("User name:") => \$printer->{NCPUSER},
-_("Password:") => {val => \$printer->{NCPPASSWD}, hidden => 1} ],
+_("Printer Server") => \$printer->{NCPHOST},
+_("Print Queue Name") => \$printer->{NCPQUEUE},
+_("User name") => \$printer->{NCPUSER},
+_("Password") => {val => \$printer->{NCPPASSWD}, hidden => 1} ],
);
&$install('ncpfs');
1;
@@ -167,14 +120,14 @@ sub setup_gsdriver($$) {
do {
$printer->{DBENTRY} ||= $printer::thedb_gsdriver{$printer->{GSDRIVER}}{ENTRY};
- $printer->{DBENTRY} =
- $printer::descr_to_db{
+ eval { $printer->{DBENTRY} = $printer::descr_to_db{
$in->ask_from_list_(_("Configure Printer"),
_("What type of printer do you have?"),
[@printer::entry_db_description],
$printer::db_to_descr{$printer->{DBENTRY}},
)
};
+ }; $@ =~ /^ask_from_list cancel/ and return;
my %db_entry = %{$printer::thedb{$printer->{DBENTRY}}};
@@ -191,8 +144,8 @@ sub setup_gsdriver($$) {
$printer->{CRLF} = $db_entry{DESCR} =~ /HP/ unless defined($printer->{CRLF});
$printer->{BITSPERPIXEL} = @list_col ? $depth_to_col{$printer->{BITSPERPIXEL}} || $col[0] : "Default";
$printer->{NUP} = 1 unless member($printer->{NUP}, qw(1 2 4 8));
- $printer->{RTFLTMAP} = 18 unless $printer->{RTFLTMAP} =~ /^\d+$/;
- $printer->{TOPBOTMAP} = 18 unless $printer->{TOPBOTMAP} =~ /^\d+$/;
+ $printer->{RTLFTMAR} = 18 unless $printer->{RTLFTMAR} =~ /^\d+$/;
+ $printer->{TOPBOTMAR} = 18 unless $printer->{TOPBOTMAR} =~ /^\d+$/;
$printer->{EXTRA_GS_OPTIONS} =~ s/^\"(.*)\"/$1/;
$printer->{TEXTONLYOPTIONS} =~ s/^\"(.*)\"/$1/;
@@ -213,8 +166,8 @@ _("Fix stair-stepping text?") => { val => \$printer->{CRLF}, type => 'bool' },
) : (),
$db_entry{GSDRIVER} ne 'TEXT' ? (
_("Number of pages per output pages") => { val => \$printer->{NUP}, type => 'list', not_edit => !$::expert, list => [1,2,4,8] },
-_("Right/Left margins in points (1/72 of inch)") => \$printer->{RTFLTMAP},
-_("Top/Bottom margins in points (1/72 of inch)") => \$printer->{TOPBOTMAP},
+_("Right/Left margins in points (1/72 of inch)") => \$printer->{RTLFTMAR},
+_("Top/Bottom margins in points (1/72 of inch)") => \$printer->{TOPBOTMAR},
) : (),
$::expert && $db_entry{GSDRIVER} ne 'TEXT' && $db_entry{GSDRIVER} ne 'POSTSCRIPT' ? (
_("Extra GhostScript options") => \$printer->{EXTRA_GS_OPTIONS},
@@ -227,7 +180,7 @@ _("Extra Text options") => \$printer->{TEXTONLYOPTIONS},
$printer->{BITSPERPIXEL} = $col_to_depth{$printer->{BITSPERPIXEL}} || $printer->{BITSPERPIXEL}; #- translate back.
$printer->{complete} = 1;
- copy_printer_params($printer, $printer->{configured}{$printer->{QUEUE}} ||= {});
+ printer::copy_printer_params($printer, $printer->{configured}{$printer->{QUEUE}} ||= {});
printer::configure_queue($printer);
$printer->{complete} = 0;
@@ -245,8 +198,8 @@ _("Extra Text options") => \$printer->{TEXTONLYOPTIONS},
{
my $w = $in->wait_message('', _("Printing test page(s)..."));
- printer::restart_queue($printer->{QUEUE});
- @lpq_output = printer::print_pages($printer->{QUEUE}, @testpages);
+ printer::restart_queue(printer::default_queue($printer->{QUEUE}));
+ @lpq_output = printer::print_pages(printer::default_queue($printer->{QUEUE}), @testpages);
}
if (@lpq_output) {
@@ -266,12 +219,11 @@ Does it work properly?"), 1) ? 'done' : 'change';
#- Program entry point.
sub main($$$) {
my ($printer, $in, $install) = @_;
- my ($queue, $continue);
+ my ($queue, $continue) = ('', 1);
- printer::read_printer_db();
- do {
+ while ($continue) {
if ($::beginner || !(scalar keys %{$printer->{configured} || {}})) {
- $queue = $in->ask_yesorno(_("Printer"),
+ $queue = $printer->{configured}{lp} || $in->ask_yesorno(_("Printer"),
_("Would you like to configure a printer?"),
$printer->{want}) ? 'lp' : 'Done';
} else {
@@ -281,55 +233,47 @@ You can add some more or change the existing ones."),
[ (sort keys %{$printer->{configured} || {}}), __("Add"), __("Done") ],
);
if ($queue eq 'Add') {
- my $i = '';
- while ($i < 99) {
- last unless $printer->{configured}{"lp$i"};
- ++$i;
- }
- unless ($printer->{configured}{"lp$i"}) {
- $queue = "lp$i";
- $printer->{QUEUE} = $queue;
- $printer->{SPOOLDIR} = "$printer::spooldir/$printer->{QUEUE}";
- }
+ my %queues; @queues{map { split '\|', $_ } keys %{$printer->{configured}}} = ();
+ my $i = ''; while ($i < 100) { last unless exists $queues{"lp$i"}; ++$i; }
+ $queue = "lp$i";
}
}
$queue eq 'Done' and last;
- copy_printer_params($printer->{configured}{$queue}, $printer) if $printer->{configured}{$queue};
- $printer->{complete} = 0; #- ??? keep that
-
&$install('rhs-printfilters') unless $::testing;
+ printer::read_printer_db();
- do {
+ printer::copy_printer_params($printer->{configured}{$queue}, $printer) if $printer->{configured}{$queue};
+ $printer->{OLD_QUEUE} = $printer->{QUEUE} = $queue; #- keep in mind old name of queue (in case of changing)
+
+ while ($continue) {
+ $printer->{TYPE} = 'LOCAL' unless $printer::printer_type_inv{$printer->{TYPE}};
+ $printer->{str_type} = $printer::printer_type_inv{$printer->{TYPE}};
if ($::beginner) {
$printer->{str_type} =
$in->ask_from_list_(_("Select Printer Connection"),
_("How is the printer connected?"),
[ keys %printer::printer_type ],
- $printer::printer_type_inv{$printer->{TYPE}},
+ $printer->{str_type},
);
- $printer->{TYPE} = $printer::printer_type{$printer->{str_type}};
} else {
- $in->ask_from_entries_refH([_("Select Printer Connection"), _("Ok"), _("Remove queue")],
+ $in->ask_from_entries_refH([_("Select Printer Connection"), _("Ok"), $::beginner ? () : _("Remove queue")],
_("Every print queue (which print jobs are directed to) needs a
name (often lp) and a spool directory associated with it. What
name and directory should be used for this queue and how is the printer connected?"), [
_("Name of queue:") => { val => \$printer->{QUEUE} },
_("Spool directory:") => { val => \$printer->{SPOOLDIR} },
-_("Printer Connection") => { val => \$printer->{str_type}, list => [ keys %printer::printer_type ] },
+_("Printer Connection") => { val => \$printer->{str_type}, not_edit => 1, list => [ keys %printer::printer_type ] },
],
changed => sub {
- $printer->{SPOOLDIR} = "$printer::spooldir/$printer->{QUEUE}" unless $_[0];
- },
- complete => sub {
- $printer->{TYPE} = $printer::printer_type{$printer->{str_type}} or
- $in->ask_warn('', _("Unknown printer connection!")), return (1, 2);
- return 0;
+ $printer->{SPOOLDIR} = "$printer::spooldir/" .
+ printer::default_queue($printer->{QUEUE}) unless $_[0];
}
- ) or delete $printer->{configured}{$queue}, redo; #- global redo on steps
+ ) or delete $printer->{configured}{$queue}, $continue = 1, last;
}
+ $printer->{TYPE} = $printer::printer_type{$printer->{str_type}};
- $continue = '';
+ $continue = 0;
for ($printer->{TYPE}) {
/LOCAL/ and setup_local ($printer, $in, $install) and last;
/REMOTE/ and setup_remote($printer, $in, $install) and last;
@@ -337,10 +281,15 @@ _("Printer Connection") => { val => \$printer->{str_type}, list => [ keys %print
/NCP/ and setup_ncp ($printer, $in, $install) and last;
$continue = 1; last;
}
- } while ($continue);
+ }
#- configure ghostscript driver to be used.
- setup_gsdriver($printer, $in);
-
- } until ($::beginner || $queue eq 'Done');
+ if (!$continue && setup_gsdriver($printer, $in)) {
+ delete $printer->{OLD_QUEUE}
+ if $printer->{QUEUE} ne $printer->{OLD_QUEUE} && $printer->{configured}{$printer->{QUEUE}};
+ $continue = !$::beginner;
+ } else {
+ $continue = 1;
+ }
+ }
}
diff --git a/perl-install/standalone/printerdrake b/perl-install/standalone/printerdrake
index 2e7ed085d..4903e3bc4 100755
--- a/perl-install/standalone/printerdrake
+++ b/perl-install/standalone/printerdrake
@@ -21,6 +21,7 @@
use lib qw(/usr/lib/libDrakX);
use interactive;
+use printer;
use printerdrake;
use c;
@@ -42,6 +43,6 @@ my $f = "/usr/lib/rhs/rhs-printfilters";
my $in = vnew interactive('su');
-printerdrake::main('', printerdrake::getinfo(''), $in, sub { `urpmi --auto $_[0]` });
+printerdrake::main(eval { printer::getinfo('') } || {}, $in, sub { `urpmi --auto $_[0]` });
$in->exit(0);