diff options
author | Till Kamppeter <tkamppeter@mandriva.com> | 2004-01-12 23:05:15 +0000 |
---|---|---|
committer | Till Kamppeter <tkamppeter@mandriva.com> | 2004-01-12 23:05:15 +0000 |
commit | 80e96d2362f7f0dcf6fab84aec645f4b4d2d769b (patch) | |
tree | 89e21bc14e381ae753dcdb4c96a1dc78c9e16a48 /perl-install/printer/main.pm | |
parent | f920665947b0b6fbbc80b4a0f2c59a3559ee789a (diff) | |
download | drakx-backup-do-not-use-80e96d2362f7f0dcf6fab84aec645f4b4d2d769b.tar drakx-backup-do-not-use-80e96d2362f7f0dcf6fab84aec645f4b4d2d769b.tar.gz drakx-backup-do-not-use-80e96d2362f7f0dcf6fab84aec645f4b4d2d769b.tar.bz2 drakx-backup-do-not-use-80e96d2362f7f0dcf6fab84aec645f4b4d2d769b.tar.xz drakx-backup-do-not-use-80e96d2362f7f0dcf6fab84aec645f4b4d2d769b.zip |
Added functionality to configure a PostScript printer with a
manufacturer-supplied PPD file.
Diffstat (limited to 'perl-install/printer/main.pm')
-rw-r--r-- | perl-install/printer/main.pm | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/perl-install/printer/main.pm b/perl-install/printer/main.pm index ddadb605d..2bc625ddf 100644 --- a/perl-install/printer/main.pm +++ b/perl-install/printer/main.pm @@ -1396,6 +1396,36 @@ sub get_direct_uri() { @direct_uri; } +sub checkppd { + # Check whether the PPD file is valid + my ($printer, $ppdfile) = @_; + return 1 if $printer->{SPOOLER} ne "cups"; + return run_program::rooted($::prefix, "cupstestppd", "-q", + $ppdfile); +} + +sub installppd { + # Install the PPD file in /usr/share/cups/model/printerdrake/ + my ($printer, $ppdfile) = @_; + return "" if !$ppdfile; + # Install PPD file + mkdir_p("$::prefix/usr/share/cups/model/printerdrake"); + # "cp_f()" is broken, it hangs infinitely + # cp_f($ppdfile, "$::prefix/usr/share/cups/model/printerdrake"); + run_program::rooted($::prefix, "cp", "-f", "$ppdfile", + "$::prefix/usr/share/cups/model/printerdrake"); + $ppdfile =~ s!^(.*)(/[^/]+)$!/usr/share/cups/model/printerdrake$2!; + chmod 0644, "$::prefix$ppdfile"; + # Restart CUPS to register new PPD file + printer::services::restart("cups") if $printer->{SPOOLER} eq "cups"; + # Re-read printer database + %thedb = (); + read_printer_db($printer, $printer->{SPOOLER}); + # Return description string of the PPD file + my $ppdentry = get_descr_from_ppdfile($printer, $ppdfile); + return $ppdentry; +} + sub clean_manufacturer_name { my ($make) = @_; # Clean some manufacturer's names so that every manufacturer has only @@ -1508,15 +1538,23 @@ sub ppd_entry_str { sub get_descr_from_ppd { my ($printer) = @_; - my %ppd; - #- if there is no ppd, this means this is a raw queue. if (! -r "$::prefix/etc/cups/ppd/$printer->{OLD_QUEUE}.ppd") { return "|" . N("Unknown model"); } + return get_descr_from_ppdfile($printer, "/etc/cups/ppd/$printer->{OLD_QUEUE}.ppd"); +} + +sub get_descr_from_ppdfile { + my ($printer, $ppdfile) = @_; + my %ppd; + + # Remove ".gz" from end of file name, so that "catMaybeCompressed" works + $ppdfile =~ s/\.gz$//; + eval { local $_; - foreach (cat_("$::prefix/etc/cups/ppd/$printer->{OLD_QUEUE}.ppd")) { + foreach (catMaybeCompressed("$::prefix$ppdfile")) { # "OTHERS|Generic PostScript printer|PostScript (en)"; /^\*([^\s:]*)\s*:\s*\"([^\"]*)\"/ and do { $ppd{$1} = $2; next }; |