From f00fc90cbf7db7fcf24330d8753fe5949464469f Mon Sep 17 00:00:00 2001 From: Till Kamppeter Date: Mon, 10 Sep 2001 17:31:14 +0000 Subject: Copying of PPD file when moving a CUPS (non-Foomatic) queue modified to not get interactive when overwriting a file. Comment put into non-Foomatic CUPS PPD files in /etc/cups/ppd/ to be able to identify which PPD from /usr/share/cups/model was used (for auto-install). --- perl-install/printer.pm | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) (limited to 'perl-install') diff --git a/perl-install/printer.pm b/perl-install/printer.pm index bbcd0449c..0d4871529 100644 --- a/perl-install/printer.pm +++ b/perl-install/printer.pm @@ -201,9 +201,22 @@ sub read_configured_queues($) { $descr =~ m/^([^\|]*)\|([^\|]*)\|.*$/; $printer->{configured}{$QUEUES[$i]->{'queuedata'}{'queue'}}{'queuedata'}{'make'} ||= $1; $printer->{configured}{$QUEUES[$i]->{'queuedata'}{'queue'}}{'queuedata'}{'model'} ||= $2; + # Read out which PPD file was originally used to set up this + # queue + local *F; + if (open F, "< $prefix/etc/cups/ppd/$QUEUES[$i]->{'queuedata'}{'queue'}.ppd") { + while () { + if ($_ =~ /^\*%MDKMODELCHOICE:(.+)$/) { + $printer->{configured}{$QUEUES[$i]->{'queuedata'}{'queue'}}{'queuedata'}{'ppd'} = $1; + } + } + close F; + } # Mark that we have a CUPS queue but do not know the name # the PPD file in /usr/share/cups/model - $printer->{configured}{$QUEUES[$i]->{'queuedata'}{'queue'}}{'queuedata'}{'ppd'} = '1'; + if (!$printer->{configured}{$QUEUES[$i]->{'queuedata'}{'queue'}}{'queuedata'}{'ppd'}) { + $printer->{configured}{$QUEUES[$i]->{'queuedata'}{'queue'}}{'queuedata'}{'ppd'} = '1'; + } $printer->{configured}{$QUEUES[$i]->{'queuedata'}{'queue'}}{'queuedata'}{'driver'} = 'CUPS/PPD'; $printer->{OLD_QUEUE} = ""; # Read out the printer's options @@ -382,12 +395,10 @@ sub read_cups_options ($) { local *F; if ($queue_or_file =~ /.ppd.gz$/) { # compressed PPD file open F, ($::testing ? "$prefix" : "chroot $prefix/ ") . - "gunzip -cd $queue_or_file | lphelp - |" || - die "Could not run lphelp"; + "gunzip -cd $queue_or_file | lphelp - |" || return 0; } else { # PPD file not compressed or queue open F, ($::testing ? "$prefix" : "chroot $prefix/ ") . - "lphelp $queue_or_file |" || - die "Could not run lphelp"; + "lphelp $queue_or_file |" || return 0; } my $i; my $j; @@ -725,6 +736,7 @@ sub poll_ppd_base { sub configure_queue($) { my ($printer) = @_; + local *F; if ($printer->{currentqueue}{foomatic}) { #- Create the queue with "foomatic-configure", in case of queue @@ -760,14 +772,21 @@ sub configure_queue($) { ("-L", $printer->{currentqueue}{'loc'}) : (), @{$printer->{currentqueue}{options}} ) or die "lpadmin failed"; + # Add a comment line containing the path of the used PPD file to the + # end of the PPD file + if ($printer->{currentqueue}{'ppd'} ne '1') { + open F, ">> $prefix/etc/cups/ppd/$printer->{currentqueue}{'queue'}.ppd"; + print F "*%MDKMODELCHOICE:$printer->{currentqueue}{'ppd'}\n"; + close F; + } # Copy the old queue's PPD file to the new queue when it is renamed, # to conserve the option settings if (($printer->{currentqueue}{'queue'} ne $printer->{OLD_QUEUE}) && ($printer->{configured}{$printer->{OLD_QUEUE}})) { - run_program::rooted($prefix, "cp", "-f", - "/etc/cups/ppd/$printer->{OLD_QUEUE}.ppd", - "/etc/cups/ppd/$printer->{currentqueue}{'queue'}.ppd"); + system("echo yes | cp -f " . + "$prefix/etc/cups/ppd/$printer->{OLD_QUEUE}.ppd " . + "$prefix/etc/cups/ppd/$printer->{currentqueue}{'queue'}.ppd"); } } -- cgit v1.2.1