summaryrefslogtreecommitdiff
path: root/src/cups/cups-genppdupdate.in
diff options
context:
space:
mode:
authorRoger Leigh <rleigh@debian.org>2012-06-21 23:30:20 +0100
committerRoger Leigh <rleigh@debian.org>2012-06-21 23:30:20 +0100
commit3514df18b289ec827cb6e4c446419feab1813231 (patch)
tree0fe6a3d1afbe720aac197918c6f4fb3583b240e1 /src/cups/cups-genppdupdate.in
parent15578e218035547ca17e25ef351fbe56bc55a4ae (diff)
Imported Upstream version 5.2.8
Diffstat (limited to 'src/cups/cups-genppdupdate.in')
-rw-r--r--src/cups/cups-genppdupdate.in49
1 files changed, 40 insertions, 9 deletions
diff --git a/src/cups/cups-genppdupdate.in b/src/cups/cups-genppdupdate.in
index adf27e9..66d0a46 100644
--- a/src/cups/cups-genppdupdate.in
+++ b/src/cups/cups-genppdupdate.in
@@ -1,5 +1,5 @@
#! @PERL@ -w
-# $Id: cups-genppdupdate.in,v 1.58 2010/01/01 19:22:18 rlk Exp $
+# $Id: cups-genppdupdate.in,v 1.60 2012/02/14 23:11:41 tillkamppeter Exp $
# Update CUPS PPDs for Gutenprint queues.
# Copyright (C) 2002-2003 Roger Leigh (rleigh@debian.org)
#
@@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
use strict;
-use Getopt::Std;
+use Getopt::Long;
use Fcntl qw(:mode);
use FileHandle;
use IPC::Open2;
@@ -78,8 +78,6 @@ if (-x $driver_bin) {
get_driver_version();
}
-$Getopt::Std::STANDARD_HELP_VERSION = 1;
-
my @ppd_files; # A list of in-use Gutenprint PPD files
# Used to convert a language name to its two letter code
@@ -175,7 +173,14 @@ if (!$quiet || $verbose) {
print STDOUT "No Gutenprint PPD files to update.\n";
} elsif ($updated_ppd_count > 0) {
my $plural = $updated_ppd_count == 1 ? "" : "s";
- print STDOUT "Updated $updated_ppd_count PPD file${plural}.";
+ print STDOUT "Updated $updated_ppd_count PPD file${plural}";
+ if ($failed_ppd_count > 0) {
+ print STDOUT ", $failed_ppd_count failed";
+ }
+ if ($skipped_ppd_count > 0) {
+ print STDOUT ", $skipped_ppd_count skipped";
+ }
+ print STDOUT ".";
if (!defined $opt_o || $opt_o ne "") {
print STDOUT " Restart cupsd for the changes to take effect.";
}
@@ -247,7 +252,23 @@ sub get_driver_version() {
}
sub parse_options () {
- if (!getopts('d:hnqs:vNo:p:P:r:ifl:')) {
+ Getopt::Long::Configure("bundling");
+ if (!GetOptions("d=i" => \$opt_d,
+ "h" => \$opt_h,
+ "n" => \$opt_n,
+ "q" => \$opt_q,
+ "s=s" => \$opt_s,
+ "p=s" => \$opt_p,
+ "P=s" => \$opt_P,
+ "v" => \$opt_v,
+ "N" => \$opt_N,
+ "o=s" => \$opt_o,
+ "r=s" => \$opt_r,
+ "f" => \$opt_f,
+ "i" => \$opt_i,
+ "l=s" => \$opt_l,
+ "version" => sub { VERSION_MESSAGE(\*STDOUT) },
+ "help" => sub { VERSION_MESSAGE(\*STDOUT); HELP_MESSAGE(\*STDOUT) })) {
help();
}
if ($opt_n) {
@@ -514,7 +535,15 @@ sub update_ppd ($) {
get_ppd_fh($ppd_source_filename, $filename, $driver, $locale, $region);
if (! defined $source_fd) {
- print "Unable to retrieve PPD file!\n";
+ print "Unable to retrieve PPD file for $ppd_source_filename!\n";
+ close ORIG;
+ return 0;
+ }
+
+ my ($ndt, $nopt, $nres, $ndef, $source_data) = get_ppd_data($source_fd, 1, 1, 1, 1, 1);
+ if (! defined $ndt) {
+ print "Unable to retrieve PPD file for $ppd_source_filename!\n";
+ close ORIG;
return 0;
}
@@ -537,14 +566,13 @@ sub update_ppd ($) {
seek(ORIG, 0, 0);
my ($odt, $oopt, $ores, $odef) = get_ppd_data(ORIG, 1, 0, 1, 1, 0);
- my ($ndt, $nopt, $nres, $ndef, $source_data) = get_ppd_data($source_fd, 1, 1, 1, 1, 1);
# Close original and temporary files...
close ORIG;
if (! $server_multicat && ! close $source_fd) {
print "Unable to retrieve new PPD file: $!\n";
- return 0;
+ return -1;
}
my %orig_default_types = %$odt;
@@ -827,6 +855,7 @@ sub find_ppd ($$$$) {
sub get_ppd_data(*$$$$$) {
my ($fh, $types, $opts, $resolutions, $defaults, $data) = @_;
my (%options, %defaults, %resolution_map, %default_types);
+ my ($fileversion_found) = 0;
my $cur_opt = "";
my (@optionlist);
my ($source_data) = "";
@@ -840,6 +869,7 @@ sub get_ppd_data(*$$$$$) {
if ($resolutions || $types || $opts || $defaults || $data) {
while (<$fh>) {
last if $_ eq "*%*%EOFEOF\n";
+ $fileversion_found = 1 if (/^\*FileVersion:/);
$source_data .= $_ if ($data);
chomp;
if (($types || $opts) && m/^\*OpenUI/) {
@@ -870,5 +900,6 @@ sub get_ppd_data(*$$$$$) {
}
}
}
+ return (undef, undef, undef, undef, undef) if (! $fileversion_found);
return (\%default_types, \%options, \%resolution_map, \%defaults, $source_data);
}