Просмотр исходного кода

Dpkg::ErrorHandling: Add support for format strings

Guillem Jover лет назад: 19
Родитель
Сommit
4dced80cec

+ 9 - 0
ChangeLog

@@ -1,3 +1,12 @@
+2007-10-18  Guillem Jover  <guillem@debian.org>
+
+	* scripts/Dpkg/ErrorHandling.pm (report): New function.
+	(warning, warnerror, failure, syserr, error, internerr, unknown)
+	(usageerr): Use report instead of sprintf. Accept a format string
+	with variable number of arguments. Fix all callers.
+	(subprocerr): Use failure instead of die and sprintf. Accept a
+	format string with variable number of arguments. Fix all callers.
+
 2007-10-18  Guillem Jover  <guillem@debian.org>
 
 	* scripts/dpkg-buildpackage.pl (mustsetvar): Pass $text to sprintf

+ 1 - 0
debian/changelog

@@ -44,6 +44,7 @@ dpkg (1.14.8) UNRELEASED; urgency=low
   * Use shipped perl modules when calling perl programs at build time.
   * Switch perl programs to use the new Dpkg/ErrorHandling module.
   * Switch perl programs to use the new Dpkg/Arch module.
+  * Add support for format strings in Dpkg::ErrorHandling functions.
 
   [ Updated dpkg translations ]
   * Polish (Robert Luberda).

+ 47 - 21
scripts/Dpkg/ErrorHandling.pm

@@ -10,19 +10,20 @@ our @EXPORT_OK = qw(warning warnerror error failure unknown syserr internerr
 our $warnable_error = 1;
 our $quiet_warnings = 0;
 
-sub failure { die sprintf(_g("%s: failure: %s"), $progname, $_[0])."\n"; }
-sub syserr { die sprintf(_g("%s: failure: %s: %s"), $progname, $_[0], $!)."\n"; }
-sub error { die sprintf(_g("%s: error: %s"), $progname, $_[0])."\n"; }
-sub internerr { die sprintf(_g("%s: internal error: %s"), $progname, $_[0])."\n"; }
+sub report(@)
+{
+    my ($type, $msg) = (shift, shift);
+
+    $msg = sprintf($msg, @_) if (@_);
+    return "$progname: $type: $msg\n";
+}
 
-sub warning
+sub warning($;@)
 {
-    if (!$quiet_warnings) {
-	warn sprintf(_g("%s: warning: %s"), $progname, $_[0])."\n";
-    }
+    warn report(_g("warning"), @_) if (!$quiet_warnings);
 }
 
-sub warnerror
+sub warnerror(@)
 {
     if ($warnable_error) {
 	warning(@_);
@@ -31,28 +32,53 @@ sub warnerror
     }
 }
 
-sub unknown {
+sub failure($;@)
+{
+    die report(_g("failure"), @_);
+}
+
+sub syserr($;@)
+{
+    my $msg = shift;
+    die report(_g("failure"), "$msg: $!", @_);
+}
+
+sub error($;@)
+{
+    die report(_g("error"), @_);
+}
+
+sub internerr($;@)
+{
+    die report(_g("internal error"), @_);
+}
+
+sub unknown($)
+{
+    # XXX: implicit argument
     my $field = $_;
-    warning(sprintf(_g("unknown information field '%s' in input data in %s"),
-                    $field, $_[0]));
+    warning(_g("unknown information field '%s' in input data in %s"),
+            $field, $_[0]);
 }
 
-sub subprocerr {
-    my ($p) = @_;
+sub subprocerr(@)
+{
+    my ($p) = (shift);
+
+    $p = sprintf($p, @_) if (@_);
+
     require POSIX;
+
     if (POSIX::WIFEXITED($?)) {
-	die sprintf(_g("%s: failure: %s gave error exit status %s"),
-		    $progname, $p, POSIX::WEXITSTATUS($?))."\n";
+	failure(_g("%s gave error exit status %s"), $p, POSIX::WEXITSTATUS($?));
     } elsif (POSIX::WIFSIGNALED($?)) {
-	die sprintf(_g("%s: failure: %s died from signal %s"),
-		    $progname, $p, POSIX::WTERMSIG($?))."\n";
+	failure(_g("%s died from signal %s"), $p, POSIX::WTERMSIG($?));
     } else {
-	die sprintf(_g("%s: failure: %s failed with unknown exit code %d"),
-		    $progname, $p, $?)."\n";
+	failure(_g("%s failed with unknown exit code %d"), $p, $?);
     }
 }
 
-sub usageerr
+sub usageerr(@)
 {
     printf(STDERR "%s: %s\n\n", $progname, "@_");
     # XXX: access to main namespace

+ 27 - 21
scripts/controllib.pl

@@ -68,7 +68,8 @@ sub getfowner
 	    die(sprintf(_g('unable to get login information for username "%s"'), $getlogin));
 	}
     } else {
-	warning(sprintf(_g('no utmp entry available and LOGNAME not defined; using uid of process (%d)'), $<));
+	warning(_g('no utmp entry available and LOGNAME not defined; ' .
+	           'using uid of process (%d)'), $<);
 	@fowner = getpwuid($<);
 	if (!@fowner) {
 	    die (sprintf(_g('unable to get login information for uid %d'), $<));
@@ -97,13 +98,13 @@ sub substvars {
         $count= 0 if (length($POSTMATCH) < length($rhs));
 
         $count < $maxsubsts ||
-            &error(sprintf(_g("too many substitutions - recursive ? - in \`%s'"), $v));
+            error(_g("too many substitutions - recursive ? - in \`%s'"), $v);
         $lhs=$`; $vn=$1; $rhs=$';
         if (defined($substvar{$vn})) {
             $v= $lhs.$substvar{$vn}.$rhs;
             $count++;
         } else {
-	    warning(sprintf(_g("unknown substitution variable \${%s}"), $vn));
+	    warning(_g("unknown substitution variable \${%s}"), $vn);
             $v= $lhs.$rhs;
         }
     }
@@ -150,9 +151,13 @@ sub outputclose {
 	    $v= &substvars($v);
 	}
         $v =~ m/\S/ || next; # delete whitespace-only fields
-        $v =~ m/\n\S/ && &internerr(sprintf(_g("field %s has newline then non whitespace >%s<"), $f, $v));
-        $v =~ m/\n[ \t]*\n/ && &internerr(sprintf(_g("field %s has blank lines >%s<"), $f, $v));
-        $v =~ m/\n$/ && &internerr(sprintf(_g("field %s has trailing newline >%s<"), $f, $v));
+	$v =~ m/\n\S/ &&
+	    internerr(_g("field %s has newline then non whitespace >%s<"),
+	              $f, $v);
+	$v =~ m/\n[ \t]*\n/ &&
+	    internerr(_g("field %s has blank lines >%s<"), $f, $v);
+	$v =~ m/\n$/ &&
+	    internerr(_g("field %s has trailing newline >%s<"), $f, $v);
 	if (defined($varlistfile)) {
 	   $v =~ s/,[\s,]*,/,/g;
 	   $v =~ s/^\s*,\s*//;
@@ -170,7 +175,8 @@ sub parsecontrolfile {
 
     $controlfile="./$controlfile" if $controlfile =~ m/^\s/;
 
-    open(CDATA,"< $controlfile") || &error(sprintf(_g("cannot read control file %s: %s"), $controlfile, $!));
+    open(CDATA, "< $controlfile") ||
+        error(_g("cannot read control file %s: %s"), $controlfile, $!);
     binmode(CDATA);
     my $indices = parsecdata(\*CDATA, 'C', 1,
 			     sprintf(_g("control file %s"), $controlfile));
@@ -178,9 +184,8 @@ sub parsecontrolfile {
 
     for (my $i = 1; $i < $indices; $i++) {
         defined($fi{"C$i Package"}) ||
-            &error(sprintf(_g("per-package paragraph %d in control ".
-                                   "info file is missing Package line"),
-                           $i));
+            error(_g("per-package paragraph %d in control " .
+                     "info file is missing Package line"), $i);
     }
     defined($fi{"C Source"}) ||
         &error(_g("source paragraph in control info file is ".
@@ -200,14 +205,13 @@ sub parsesubstvars {
                 next if m/^\#/ || !m/\S/;
                 s/\s*\n$//;
                 m/^(\w[-:0-9A-Za-z]*)\=/ ||
-                    &error(sprintf(_g("bad line in substvars file %s at line %d"),
-                                   $varlistfile, $.));
+                    error(_g("bad line in substvars file %s at line %d"),
+                          $varlistfile, $.);
                 $substvar{$1}= $';
             }
             close(SV);
         } elsif ($! != ENOENT ) {
-            &error(sprintf(_g("unable to open substvars file %s: %s"),
-                           $varlistfile, $!));
+            error(_g("unable to open substvars file %s: %s"), $varlistfile, $!);
         }
         $substvarsparsed = 1;
     }
@@ -258,7 +262,7 @@ ALTERNATE:
                 }
             }
             if (length($dep_or)) {
-		warning(sprintf(_g("can't parse dependency %s"), $dep_and));
+		warning(_g("can't parse dependency %s"), $dep_and);
 		return undef;
 	    }
 	    push @or_list, [ $package, $relation, $version, \@arches ];
@@ -329,15 +333,16 @@ sub init_substvar_arch()
 sub checkpackagename {
     my $name = shift || '';
     $name =~ m/[^-+.0-9a-z]/o &&
-        &error(sprintf(_g("source package name `%s' contains illegal character `%s'"), $name, $&));
+        error(_g("source package name `%s' contains illegal character `%s'"),
+              $name, $&);
     $name =~ m/^[0-9a-z]/o ||
-        &error(sprintf(_g("source package name `%s' starts with non-alphanum"), $name));
+        error(_g("source package name `%s' starts with non-alphanum"), $name);
 }
 
 sub checkversion {
     my $version = shift || '';
     $version =~ m/[^-+:.0-9a-zA-Z~]/o &&
-        &error(sprintf(_g("version number contains illegal character `%s'"), $&));
+        error(_g("version number contains illegal character `%s'"), $&);
 }
 
 sub setsourcepackage {
@@ -346,7 +351,8 @@ sub setsourcepackage {
     checkpackagename( $v );
     if (defined($sourcepackage)) {
         $v eq $sourcepackage ||
-            &error(sprintf(_g("source package has two conflicting values - %s and %s"), $sourcepackage, $v));
+            error(_g("source package has two conflicting values - %s and %s"),
+                  $sourcepackage, $v);
     } else {
         $sourcepackage= $v;
     }
@@ -355,7 +361,7 @@ sub setsourcepackage {
 sub readmd5sum {
     (my $md5sum = shift) or return;
     $md5sum =~ s/^([0-9a-f]{32})\s*\*?-?\s*\n?$/$1/o
-	|| &failure(sprintf(_g("md5sum gave bogus output `%s'"), $md5sum));
+        || failure(_g("md5sum gave bogus output `%s'"), $md5sum);
     return $md5sum;
 }
 
@@ -424,7 +430,7 @@ sub parsecdata {
 }
 
 sub syntax {
-    &error(sprintf(_g("syntax error in %s at line %d: %s"), $whatmsg, $., $_[0]));
+    error(_g("syntax error in %s at line %d: %s"), $whatmsg, $., $_[0]);
 }
 
 1;

+ 11 - 4
scripts/dpkg-architecture.pl

@@ -97,7 +97,8 @@ if ($gcc ne '') {
     my (@deb_host_archtriplet) = gnutriplet_to_debtriplet($gcc);
     $deb_host_arch = debtriplet_to_debarch(@deb_host_archtriplet);
     unless (defined $deb_host_arch) {
-	warning(sprintf(_g("Unknown gcc system type %s, falling back to default (native compilation)"), $gcc));
+	warning(_g("Unknown gcc system type %s, falling back to default " .
+	           "(native compilation)"), $gcc);
 	$gcc = '';
     } else {
 	$gcc = $deb_host_gnu_type = debtriplet_to_gnutriplet(@deb_host_archtriplet);
@@ -151,7 +152,7 @@ while (@ARGV) {
        &version;
        exit 0;
     } else {
-	usageerr(sprintf(_g("unknown option \`%s'"), $_));
+	usageerr(_g("unknown option \`%s'"), $_);
     }
 }
 
@@ -170,7 +171,10 @@ if ($req_host_gnu_type ne '' && $req_host_arch ne '') {
     die (sprintf(_g("unknown default GNU system type for Debian architecture %s"),
                  $req_host_arch))
 	unless defined $dfl_host_gnu_type;
-    warning(sprintf(_g("Default GNU system type %s for Debian arch %s does not match specified GNU system type %s"), $dfl_host_gnu_type, $req_host_arch, $req_host_gnu_type)) if $dfl_host_gnu_type ne $req_host_gnu_type;
+    warning(_g("Default GNU system type %s for Debian arch %s does not " .
+               "match specified GNU system type %s"), $dfl_host_gnu_type,
+            $req_host_arch, $req_host_gnu_type)
+        if $dfl_host_gnu_type ne $req_host_gnu_type;
 }
 
 $deb_host_arch = $req_host_arch if $req_host_arch ne '';
@@ -178,7 +182,10 @@ $deb_host_gnu_type = $req_host_gnu_type if $req_host_gnu_type ne '';
 
 #$gcc = `\${CC:-gcc} --print-libgcc-file-name`;
 #$gcc =~ s!^.*gcc-lib/(.*)/\d+(?:.\d+)*/libgcc.*$!$1!s;
-warning(sprintf(_g("Specified GNU system type %s does not match gcc system type %s."), $deb_host_gnu_type, $gcc)) if !($req_is_arch or $req_eq_arch) && ($gcc ne '') && ($gcc ne $deb_host_gnu_type);
+warning(_g("Specified GNU system type %s does not match gcc system type %s."),
+        $deb_host_gnu_type, $gcc)
+    if !($req_is_arch or $req_eq_arch) &&
+       ($gcc ne '') && ($gcc ne $deb_host_gnu_type);
 
 # Split the Debian and GNU names
 my ($deb_host_arch_abi, $deb_host_arch_os, $deb_host_arch_cpu) = debarch_to_debtriplet($deb_host_arch);

+ 7 - 7
scripts/dpkg-buildpackage.pl

@@ -156,7 +156,7 @@ while (@ARGV) {
     } elsif (/^-nc$/) {
 	$noclean = 1;
 	if ($sourceonly) {
-	    usageerr(sprintf(_g("cannot combine %s and %s"), '-nc', '-S'));
+	    usageerr(_g("cannot combine %s and %s"), '-nc', '-S');
 	}
 	unless ($binaryonly) {
 	    $binaryonly = '-b';
@@ -166,20 +166,20 @@ while (@ARGV) {
 	@checkbuilddep_args = ();
 	$binarytarget = 'binary';
 	if ($sourceonly) {
-	    usageerr(sprintf(_g("cannot combine %s and %s"), '-b', '-S'));
+	    usageerr(_g("cannot combine %s and %s"), '-b', '-S');
 	}
     } elsif (/^-B$/) {
 	$binaryonly = '-B';
 	@checkbuilddep_args = ('-B');
 	$binarytarget = 'binary-arch';
 	if ($sourceonly) {
-	    usageerr(sprintf(_g("cannot combine %s and %s"), '-B', '-S'));
+	    usageerr(_g("cannot combine %s and %s"), '-B', '-S');
 	}
     } elsif (/^-S$/) {
 	$sourceonly = '-S';
 	$checkbuilddep = 0;
 	if ($binaryonly) {
-	    usageerr(sprintf(_g("cannot combine %s and %s"), $binaryonly, '-S'));
+	    usageerr(_g("cannot combine %s and %s"), $binaryonly, '-S');
 	}
     } elsif (/^-v(.*)$/) {
 	$since = $1;
@@ -196,7 +196,7 @@ while (@ARGV) {
 	$warnable_error = 0;
 	push @passopts, '-E';
     } else {
-	usageerr(sprintf(_g("unknown option or argument %s"), $_));
+	usageerr(_g("unknown option or argument %s"), $_);
     }
 }
 
@@ -211,7 +211,7 @@ if ($< == 0) {
 	             "package, specify a command with the -r option, " .
 	             "or run this as root"));
 	} else {
-	    error(sprintf(_g("gain-root-commmand '%s' not found"), $rootcommand));
+	    error(_g("gain-root-commmand '%s' not found"), $rootcommand);
 	}
     }
 }
@@ -266,7 +266,7 @@ close CHANGELOG or subprocerr('dpkg-parsechangelog');
 sub mustsetvar {
     my ($var, $text) = @_;
 
-    error(sprintf(_g("unable to determine %s"), $text))
+    error(_g("unable to determine %s"), $text)
 	unless defined($var);
 
     print "$progname: $text $var\n";

+ 1 - 2
scripts/dpkg-checkbuilddeps.pl

@@ -150,8 +150,7 @@ sub check_line {
 	my @unmet=();
 
 	unless(defined($dep_list)) {
-	    &error(sprintf(_g("error occurred while parsing %s"),
-	                   $fieldname));
+	    error(_g("error occurred while parsing %s"), $fieldname);
 	}
 
 	foreach my $dep_and (@$dep_list) {

+ 1 - 1
scripts/dpkg-distaddfile.pl

@@ -51,7 +51,7 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {
     } elsif (m/^--$/) {
         last;
     } else {
-        &usageerr(sprintf(_g("unknown option \`%s'"), $_));
+        usageerr(_g("unknown option \`%s'"), $_);
     }
 }
 

+ 37 - 28
scripts/dpkg-genchanges.pl

@@ -157,7 +157,7 @@ while (@ARGV) {
     } elsif (m/^--version$/) {
         &version; exit(0);
     } else {
-        &usageerr(sprintf(_g("unknown option \`%s'"), $_));
+        usageerr(_g("unknown option \`%s'"), $_);
     }
 }
 
@@ -170,13 +170,15 @@ if (not $sourceonly) {
     while(<FL>) {
 	if (m/^(([-+.0-9a-z]+)_([^_]+)_([-\w]+)\.u?deb) (\S+) (\S+)$/) {
 	    defined($p2f{"$2 $4"}) &&
-		warning(sprintf(_g("duplicate files list entry for package %s (line %d)"), $2, $.));
+		warning(_g("duplicate files list entry for package %s (line %d)"),
+		        $2, $.);
 	    $f2p{$1}= $2;
 	    $p2f{"$2 $4"}= $1;
 	    $p2f{$2}= $1;
 	    $p2ver{$2}= $3;
 	    defined($f2sec{$1}) &&
-		warning(sprintf(_g("duplicate files list entry for file %s (line %d)"), $1, $.));
+		warning(_g("duplicate files list entry for file %s (line %d)"),
+		        $1, $.);
 	    $f2sec{$1}= $5;
 	    $f2pri{$1}= $6;
 	    push(@fileslistfiles,$1);
@@ -188,12 +190,13 @@ if (not $sourceonly) {
 	    push(@fileslistfiles,$1);
 	} elsif (m/^([-+.,_0-9a-zA-Z]+) (\S+) (\S+)$/) {
 	    defined($f2sec{$1}) &&
-		warning(sprintf(_g("duplicate files list entry for file %s (line %d)"), $1, $.));
+		warning(_g("duplicate files list entry for file %s (line %d)"),
+		        $1, $.);
 	    $f2sec{$1}= $2;
 	    $f2pri{$1}= $3;
 	    push(@fileslistfiles,$1);
 	} else {
-	    &error(sprintf(_g("badly formed line in files list file, line %d"), $.));
+	    error(_g("badly formed line in files list file, line %d"), $.);
 	}
     }
     close(FL);
@@ -224,7 +227,8 @@ for $_ (keys %fi) {
 	if (!defined($p2f{$p}) && not $sourceonly) {
 	    if ((debarch_eq('all', $a) && !$archspecific) ||
 		grep(debarch_is($host_arch, $_), split(/\s+/, $a))) {
-		warning(sprintf(_g("package %s in control file but not in files list"), $p));
+		warning(_g("package %s in control file but not in files list"),
+		        $p);
 		next;
 	    }
 	} else {
@@ -277,7 +281,8 @@ for $_ (keys %fi) {
         }
     } elsif (m/^o:.*/) {
     } else {
-        &internerr(sprintf(_g("value from nowhere, with key >%s< and value >%s<"), $_, $v));
+        internerr(_g("value from nowhere, with key >%s< and value >%s<"),
+                  $_, $v);
     }
 }
 
@@ -295,7 +300,8 @@ if ($changesdescription) {
 for my $p (keys %p2f) {
     my ($pp, $aa) = (split / /, $p);
     defined($p2i{"C $pp"}) ||
-	warning(sprintf(_g("package %s listed in files list but not in control info"), $pp));
+	warning(_g("package %s listed in files list but not in control info"),
+	        $pp);
 }
 
 for my $p (keys %p2f) {
@@ -305,20 +311,20 @@ for my $p (keys %p2f) {
     $sec = $sourcedefault{'Section'} if !defined($sec);
     if (!defined($sec)) {
 	$sec = '-';
-	warning(sprintf(_g("missing Section for binary package %s; using '-'"), $p));
+	warning(_g("missing Section for binary package %s; using '-'"), $p);
     }
-    $sec eq $f2sec{$f} || &error(sprintf(_g("package %s has section %s in ".
-                                           "control file but %s in files list"),
-                                 $p, $sec, $f2sec{$f}));
+    $sec eq $f2sec{$f} || error(_g("package %s has section %s in " .
+                                   "control file but %s in files list"),
+                                $p, $sec, $f2sec{$f});
     my $pri = $f2pricf{$f};
     $pri = $sourcedefault{'Priority'} if !defined($pri);
     if (!defined($pri)) {
 	$pri = '-';
-	warning(sprintf(_g("missing Priority for binary package %s; using '-'"), $p));
+	warning(_g("missing Priority for binary package %s; using '-'"), $p);
     }
-    $pri eq $f2pri{$f} || &error(sprintf(_g("package %s has priority %s in ".
-                                           "control file but %s in files list"),
-                                 $p, $pri, $f2pri{$f}));
+    $pri eq $f2pri{$f} || error(_g("package %s has priority %s in " .
+                                   "control file but %s in files list"),
+                                $p, $pri, $f2pri{$f});
 }
 
 &init_substvars;
@@ -340,7 +346,7 @@ if (!$binaryonly) {
 
     (my $sversion = $substvar{'source:Version'}) =~ s/^\d+://;
     $dsc= "$uploadfilesdir/${sourcepackage}_${sversion}.dsc";
-    open(CDATA,"< $dsc") || &error(sprintf(_g("cannot open .dsc file %s: %s"), $dsc, $!));
+    open(CDATA,"< $dsc") || error(_g("cannot open .dsc file %s: %s"), $dsc, $!);
     push(@sourcefiles,"${sourcepackage}_${sversion}.dsc");
 
     parsecdata(\*CDATA, 'S', -1, sprintf(_g("source control file %s"), $dsc));
@@ -349,7 +355,7 @@ if (!$binaryonly) {
     for my $file (split(/\n /, $files)) {
         next if $file eq '';
         $file =~ m/^([0-9a-f]{32})[ \t]+\d+[ \t]+([0-9a-zA-Z][-+:.,=0-9a-zA-Z_~]+)$/
-            || &error(sprintf(_g("Files field contains bad line \`%s'"), $file));
+            || error(_g("Files field contains bad line \`%s'"), $file);
         ($md5sum{$2},$file) = ($1,$2);
         push(@sourcefiles,$file);
     }
@@ -399,19 +405,20 @@ for my $f (@sourcefiles, @fileslistfiles) {
     next if ($archspecific && debarch_eq('all', $p2arch{$f2p{$f}}));
     next if $filedone{$f}++;
     my $uf = "$uploadfilesdir/$f";
-    open(STDIN,"< $uf") || &syserr(sprintf(_g("cannot open upload file %s for reading"), $uf));
-    (my @s = stat(STDIN)) || syserr(sprintf(_g("cannot fstat upload file %s"), $uf));
+    open(STDIN, "< $uf") ||
+        syserr(_g("cannot open upload file %s for reading"), $uf);
+    (my @s = stat(STDIN)) || syserr(_g("cannot fstat upload file %s"), $uf);
     my $size = $s[7];
-    $size || warn(sprintf(_g("upload file %s is empty"), $uf));
+    $size || warning(_g("upload file %s is empty"), $uf);
     my $md5sum = `md5sum`;
-    $? && subprocerr(sprintf(_g("md5sum upload file %s"), $uf));
+    $? && subprocerr(_g("md5sum upload file %s"), $uf);
     $md5sum =~ m/^([0-9a-f]{32})\s*-?\s*$/i ||
-        &failure(sprintf(_g("md5sum upload file %s gave strange output \`%s'"), $uf, $md5sum));
+        failure(_g("md5sum upload file %s gave strange output \`%s'"),
+                $uf, $md5sum);
     $md5sum= $1;
     defined($md5sum{$f}) && $md5sum{$f} ne $md5sum &&
-        &error(sprintf(_g("md5sum of source file %s (%s) is different ".
-                          "from md5sum in %s (%s)"),
-                       $uf, $md5sum, $dsc, $md5sum{$f}));
+        error(_g("md5sum of source file %s (%s) is different from md5sum " .
+                 "in %s (%s)"), $uf, $md5sum, $dsc, $md5sum{$f});
     $f{'Files'}.= "\n $md5sum $size $f2sec{$f} $f2pri{$f} $f";
 }    
 
@@ -424,11 +431,13 @@ $f{'Maintainer'} = $forcemaint if defined($forcemaint);
 $f{'Changed-By'} = $forcechangedby if defined($forcechangedby);
 
 for my $f (qw(Version Distribution Maintainer Changes)) {
-    defined($f{$f}) || &error(sprintf(_g("missing information for critical output field %s"), $f));
+    defined($f{$f}) ||
+        error(_g("missing information for critical output field %s"), $f);
 }
 
 for my $f (qw(Urgency)) {
-    defined($f{$f}) || warning(sprintf(_g("missing information for output field %s"), $f));
+    defined($f{$f}) ||
+        warning(_g("missing information for output field %s"), $f);
 }
 
 for my $f (keys %override) {

+ 27 - 22
scripts/dpkg-gencontrol.pl

@@ -86,7 +86,7 @@ while (@ARGV) {
     if (m/^-p([-+0-9a-z.]+)$/) {
         $oppackage= $1;
     } elsif (m/^-p(.*)/) {
-        &error(sprintf(_g("Illegal package name \`%s'"), $1));
+        error(_g("Illegal package name \`%s'"), $1);
     } elsif (m/^-c/) {
         $controlfile= $';
     } elsif (m/^-l/) {
@@ -118,7 +118,7 @@ while (@ARGV) {
     } elsif (m/^--version$/) {
         &version; exit(0);
     } else {
-        &usageerr(sprintf(_g("unknown option \`%s'"), $_));
+        usageerr(_g("unknown option \`%s'"), $_);
     }
 }
 
@@ -129,12 +129,14 @@ parsecontrolfile($controlfile);
 my $myindex;
 
 if (defined($oppackage)) {
-    defined($p2i{"C $oppackage"}) || &error(sprintf(_g("package %s not in control info"), $oppackage));
+    defined($p2i{"C $oppackage"}) ||
+        error(_g("package %s not in control info"), $oppackage);
     $myindex= $p2i{"C $oppackage"};
 } else {
     my @packages = grep(m/^C /, keys %p2i);
     @packages==1 ||
-        &error(sprintf(_g("must specify package since control info has many (%s)"), "@packages"));
+        error(_g("must specify package since control info has many (%s)"),
+              "@packages");
     $myindex=1;
 }
 
@@ -179,17 +181,15 @@ for $_ (keys %fi) {
             } else {
 		my @archlist = split(/\s+/, $v);
 		my @invalid_archs = grep m/[^\w-]/, @archlist;
-		warning(sprintf(ngettext(
-		                  "`%s' is not a legal architecture string.",
-		                  "`%s' are not legal architecture strings.",
-		                  scalar(@invalid_archs)),
-		              join("' `", @invalid_archs)))
+		warning(ngettext("`%s' is not a legal architecture string.",
+		                 "`%s' are not legal architecture strings.",
+		                 scalar(@invalid_archs)),
+		        join("' `", @invalid_archs))
 		    if @invalid_archs >= 1;
 		grep(debarch_is($host_arch, $_), @archlist) ||
-		    error(sprintf(_g("current host architecture '%s' does " .
-		                     "not appear in package's architecture " .
-		                     "list (%s)"),
-		                   $host_arch, "@archlist"));
+		    error(_g("current host architecture '%s' does not " .
+		             "appear in package's architecture list (%s)"),
+		          $host_arch, "@archlist");
 		$f{$_} = $host_arch;
             }
         } elsif (s/^X[CS]*B[CS]*-//i) {
@@ -214,7 +214,7 @@ for $_ (keys %fi) {
         }
     } elsif (m/o:/) {
     } else {
-        &internerr(sprintf(_g("value from nowhere, with key >%s< and value >%s<"), $_, $v));
+        internerr(_g("value from nowhere, with key >%s< and value >%s<"), $_, $v);
     }
 }
 
@@ -232,7 +232,8 @@ for $_ (keys %fi) {
     if (s/^C$myindex //) {
         if (exists($pkg_dep_fields{$_})) {
            my $dep = parsedep(substvars($v), 1, 1);
-           &error(sprintf(_g("error occurred while parsing %s"), $_)) unless defined $dep;
+            error(_g("error occurred while parsing %s"), $_)
+                unless defined $dep;
             $f{$_}= showdep($dep, 0);
         }
     }
@@ -245,10 +246,10 @@ for my $f (qw(Section Priority)) {
 }
 
 for my $f (qw(Package Version)) {
-    defined($f{$f}) || &error(sprintf(_g("missing information for output field %s"), $f));
+    defined($f{$f}) || error(_g("missing information for output field %s"), $f);
 }
 for my $f (qw(Maintainer Description Architecture)) {
-    defined($f{$f}) || warning(sprintf(_g("missing information for output field %s"), $f));
+    defined($f{$f}) || warning(_g("missing information for output field %s"), $f);
 }
 $oppackage= $f{'Package'};
 
@@ -262,15 +263,18 @@ if ($oppackage ne $sourcepackage || $verdiff) {
 if (!defined($substvar{'Installed-Size'})) {
     defined(my $c = open(DU, "-|")) || syserr(_g("fork for du"));
     if (!$c) {
-        chdir("$packagebuilddir") || &syserr(sprintf(_g("chdir for du to \`%s'"), $packagebuilddir));
+        chdir("$packagebuilddir") ||
+            syserr(_g("chdir for du to \`%s'"), $packagebuilddir);
         exec("du","-k","-s",".") or &syserr(_g("exec du"));
     }
     my $duo = '';
     while (<DU>) {
 	$duo .= $_;
     }
-    close(DU); $? && &subprocerr(sprintf(_g("du in \`%s'"), $packagebuilddir));
-    $duo =~ m/^(\d+)\s+\.$/ || &failure(sprintf(_g("du gave unexpected output \`%s'"), $duo));
+    close(DU);
+    $? && subprocerr(_g("du in \`%s'"), $packagebuilddir);
+    $duo =~ m/^(\d+)\s+\.$/ ||
+        failure(_g("du gave unexpected output \`%s'"), $duo);
     $substvar{'Installed-Size'}= $1;
 }
 if (defined($substvar{'Extra-Size'})) {
@@ -321,7 +325,7 @@ if (!$stdout) {
     $cf= "$packagebuilddir/DEBIAN/control";
     $cf= "./$cf" if $cf =~ m/^\s/;
     open(STDOUT,"> $cf.new") ||
-        &syserr(sprintf(_g("cannot open new output control file \`%s'"), "$cf.new"));
+        syserr(_g("cannot open new output control file \`%s'"), "$cf.new");
     binmode(STDOUT);
 }
 
@@ -329,7 +333,8 @@ set_field_importance(@control_fields);
 outputclose($varlistfile);
 
 if (!$stdout) {
-    rename("$cf.new","$cf") || &syserr(sprintf(_g("cannot install output control file \`%s'"), $cf));
+    rename("$cf.new", "$cf") ||
+        syserr(_g("cannot install output control file \`%s'"), $cf);
 }
 
 sub spfileslistvalue {

+ 10 - 8
scripts/dpkg-gensymbols.pl

@@ -88,7 +88,7 @@ while (@ARGV) {
 	    push @files, glob($file);
 	}
     } elsif (m/^-p(.*)/) {
-	&error(sprintf(_g("Illegal package name \`%s'"), $1));
+	error(_g("Illegal package name \`%s'"), $1);
     } elsif (m/^-P(.*)$/) {
 	$packagebuilddir = $1;
 	$packagebuilddir =~ s{/+$}{};
@@ -101,7 +101,7 @@ while (@ARGV) {
     } elsif (m/^--version$/) {
 	&version; exit(0);
     } else {
-	&usageerr(sprintf(_g("unknown option \`%s'"), $_));
+	usageerr(_g("unknown option \`%s'"), $_);
     }
 }
 
@@ -113,7 +113,8 @@ if (not defined($oppackage)) {
     parsecontrolfile($controlfile);
     my @packages = grep(m/^C /, keys %p2i);
     @packages==1 ||
-	&error(sprintf(_g("must specify package since control info has many (%s)"), "@packages"));
+	error(_g("must specify package since control info has many (%s)"),
+	      "@packages");
     $oppackage = $packages[0];
     $oppackage =~ s/^C //;
 }
@@ -140,7 +141,7 @@ if (not scalar @files) {
 	$libdir =~ s{/+}{/}g;
 	next if not -d $libdir;
 	opendir(DIR, "$libdir") ||
-	    syserr(sprintf(_g("Can't read directory %s: %s"), $libdir, $!));
+	    syserr(_g("Can't read directory %s: %s"), $libdir, $!);
 	push @files, grep {
 	    /(\.so\.|\.so$)/ && -f $_ &&
 	    Dpkg::Shlibs::Objdump::is_elf($_);
@@ -155,7 +156,7 @@ foreach my $file (@files) {
     print "Scanning $file for symbol information\n" if $debug;
     my $objid = $od->parse($file);
     unless (defined($objid) && $objid) {
-	warning(sprintf(_g("Objdump couldn't parse %s\n"), $file));
+	warning(_g("Objdump couldn't parse %s\n"), $file);
 	next;
     }
     my $object = $od->get_object($objid);
@@ -222,10 +223,11 @@ if ($compare) {
     $md5_after->addfile($after);
     if ($md5_before->hexdigest() ne $md5_after->hexdigest()) {
 	if (defined($ref_symfile->{file})) {
-	    warning(sprintf(_g("%s doesn't match completely %s\n"),
-		    $output, $ref_symfile->{file}));
+	    warning(_g("%s doesn't match completely %s\n"),
+		    $output, $ref_symfile->{file});
 	} else {
-	    warning(sprintf(_g("no debian/symbols file used as basis for generating %s\n"), $output));
+	    warning(_g("no debian/symbols file used as basis for generating %s\n"),
+	            $output);
 	}
 	my ($a, $b) = ($before->filename, $after->filename);
 	system("diff", "-u", $a, $b) if -x "/usr/bin/diff";

+ 7 - 6
scripts/dpkg-parsechangelog.pl

@@ -62,18 +62,19 @@ while (@ARGV) {
     &usageerr("unknown option \`$_'");
 }
 
-@ARGV && &usageerr(sprintf(_g("%s takes no non-option arguments"), $progname));
+@ARGV && usageerr(_g("%s takes no non-option arguments"), $progname);
 $changelogfile= "./$changelogfile" if $changelogfile =~ m/^\s/;
 
 if (not $force and $changelogfile ne "-") {
     open(STDIN,"< $changelogfile") ||
-        &error(sprintf(_g("cannot open %s to find format: %s"), $changelogfile, $!));
+        error(_g("cannot open %s to find format: %s"), $changelogfile, $!);
     open(P,"tail -n 40 |") || die sprintf(_g("cannot fork: %s"), $!)."\n";
     while(<P>) {
         next unless m/\schangelog-format:\s+([0-9a-z]+)\W/;
         $format=$1;
     }
-    close(P); $? && &subprocerr(sprintf(_g("tail of %s"), $changelogfile));
+    close(P);
+    $? && subprocerr(_g("tail of %s"), $changelogfile);
 }
 
 my ($pa, $pf);
@@ -81,16 +82,16 @@ my ($pa, $pf);
 for my $pd (@parserpath) {
     $pa= "$pd/$format";
     if (!stat("$pa")) {
-        $! == ENOENT || &syserr(sprintf(_g("failed to check for format parser %s"), $pa));
+        $! == ENOENT || syserr(_g("failed to check for format parser %s"), $pa);
     } elsif (!-x _) {
-	warning(sprintf(_g("format parser %s not executable"), $pa));
+	warning(_g("format parser %s not executable"), $pa);
     } else {
         $pf= $pa;
 	last;
     }
 }
         
-defined($pf) || &error(sprintf(_g("format %s unknown"), $pa));
+defined($pf) || error(_g("format %s unknown"), $pa);
 
 if ($changelogfile ne "-") {
     open(STDIN,"< $changelogfile") || die sprintf(_g("cannot open %s: %s"), $changelogfile, $!)."\n";

+ 28 - 25
scripts/dpkg-shlibdeps.pl

@@ -57,12 +57,11 @@ foreach (@ARGV) {
     } elsif (m/^--admindir=(.*)$/) {
 	$admindir = $1;
 	-d $admindir ||
-	    error(sprintf(_g("administrative directory '%s' does not exist"),
-			  $admindir));
+	    error(_g("administrative directory '%s' does not exist"), $admindir);
     } elsif (m/^-d(.*)$/) {
 	$dependencyfield= capit($1);
 	defined($depstrength{$dependencyfield}) ||
-	    warning(sprintf(_g("unrecognised dependency field \`%s'"), $dependencyfield));
+	    warning(_g("unrecognised dependency field \`%s'"), $dependencyfield);
     } elsif (m/^-e(.*)$/) {
 	$exec{$1} = $dependencyfield;
     } elsif (m/^--ignore-missing-info$/) {
@@ -74,7 +73,7 @@ foreach (@ARGV) {
     } elsif (m/^-x(.*)$/) {
 	push @exclude, $1;
     } elsif (m/^-/) {
-	usageerr(sprintf(_g("unknown option \`%s'"), $_));
+	usageerr(_g("unknown option \`%s'"), $_);
     } else {
 	$exec{$_} = $dependencyfield;
     }
@@ -97,7 +96,9 @@ foreach my $file (keys %exec) {
     my %libfiles;
     foreach my $soname (@sonames) {
 	my $lib = my_find_library($soname, $obj->{RPATH}, $obj->{format}, $file);
-	failure(sprintf(_g("couldn't find library %s (note: only packages with 'shlibs' files are looked into)."), $soname)) unless defined($lib);
+	failure(_g("couldn't find library %s (note: only packages with " .
+	           "'shlibs' files are looked into)."), $soname)
+	    unless defined($lib);
 	$libfiles{$lib} = $soname if defined($lib);
     }
     my $file2pkg = find_packages(keys %libfiles);
@@ -141,9 +142,9 @@ foreach my $file (keys %exec) {
 		my $libobj = $dumplibs_wo_symfile->get_object($id);
 		# Only try to generate a dependency for libraries with a SONAME
 		if ($libobj->is_public_library() and not add_shlibs_dep($soname, $pkg)) {
-		    failure(sprintf(
-			_g("No dependency information found for %s (used by %s)."),
-			$soname, $file)) unless $ignore_missing_info;
+		    failure(_g("No dependency information found for %s " .
+		               "(used by %s)."), $soname, $file)
+		        unless $ignore_missing_info;
 		}
 	    }
 	}
@@ -185,9 +186,9 @@ foreach my $file (keys %exec) {
 		    my $print_name = $name;
 		    # Drop the default suffix for readability
 		    $print_name =~ s/\@Base$//;
-		    warning(sprintf(
-			_g("symbol %s used by %s found in none of the libraries."),
-			$print_name, $file)) unless $sym->{weak};
+		    warning(_g("symbol %s used by %s found in none of the " .
+		               "libraries."), $print_name, $file)
+		        unless $sym->{weak};
 		}
 	    } else {
 		$used_sonames{$syminfo->{soname}}++;
@@ -197,9 +198,8 @@ foreach my $file (keys %exec) {
     # Warn about un-NEEDED libraries
     foreach my $soname (@sonames) {
 	unless ($used_sonames{$soname}) {
-	    warning(sprintf(
-		_g("%s shouldn't be linked with %s (it uses none of its symbols)."),
-		$file, $soname));
+	    warning(_g("%s shouldn't be linked with %s (it uses none of its " .
+	               "symbols)."), $file, $soname);
 	}
     }
 }
@@ -210,13 +210,14 @@ if ($stdout) {
     $fh = \*STDOUT;
 } else {
     open(NEW, ">", "$varlistfile.new") ||
-	syserr(sprintf(_g("open new substvars file \`%s'"), "$varlistfile.new"));
+	syserr(_g("open new substvars file \`%s'"), "$varlistfile.new");
     if (-e $varlistfile) {
 	open(OLD, "<", $varlistfile) ||
-	    syserr(sprintf(_g("open old varlist file \`%s' for reading"), $varlistfile));
+	    syserr(_g("open old varlist file \`%s' for reading"), $varlistfile);
 	foreach my $entry (grep { not m/^\Q$varnameprefix\E:/ } (<OLD>)) {
 	    print(NEW $entry) ||
-		syserr(sprintf(_g("copy old entry to new varlist file \`%s'"), "$varlistfile.new"));
+	        syserr(_g("copy old entry to new varlist file \`%s'"),
+	               "$varlistfile.new");
 	}
 	close(OLD);
     }
@@ -275,7 +276,7 @@ foreach my $field (reverse @depfields) {
 if (!$stdout) {
     close($fh);
     rename("$varlistfile.new",$varlistfile) ||
-	syserr(sprintf(_g("install new varlist file \`%s'"), $varlistfile));
+	syserr(_g("install new varlist file \`%s'"), $varlistfile);
 }
 
 ##
@@ -350,19 +351,21 @@ sub extract_from_shlibs {
     } elsif ($soname =~ /^(.*)-(.*)\.so$/) {
 	$libname = $1; $libversion = $2;
     } else {
-	warning(sprintf(_g("Can't extract name and version from library name \`%s'"), $soname));
+	warning(_g("Can't extract name and version from library name \`%s'"),
+	        $soname);
 	return;
     }
     # Open shlibs file
     $shlibfile = "./$shlibfile" if $shlibfile =~ m/^\s/;
-    open(SHLIBS, "<", $shlibfile)
-	|| syserr(sprintf(_g("unable to open shared libs info file \`%s'"), $shlibfile));
+    open(SHLIBS, "<", $shlibfile) ||
+        syserr(_g("unable to open shared libs info file \`%s'"), $shlibfile);
     my $dep;
     while (<SHLIBS>) {
 	s/\s*\n$//;
 	next if m/^\#/;
 	if (!m/^\s*(?:(\S+):\s+)?(\S+)\s+(\S+)\s+(\S.*\S)\s*$/) {
-	    warning(sprintf(_g("shared libs info file \`%s' line %d: bad line \`%s'"), $shlibfile, $., $_));
+	    warning(_g("shared libs info file \`%s' line %d: bad line \`%s'"),
+	            $shlibfile, $., $_);
 	    next;
 	}
 	if (($libname eq $2) && ($libversion eq $3)) {
@@ -400,8 +403,8 @@ sub find_symbols_file {
 
 sub symfile_has_soname {
     my ($file, $soname) = @_;
-    open(SYM_FILE, "<", $file)
-	|| syserr(sprintf(_g("cannot open file %s"), $file));
+    open(SYM_FILE, "<", $file) ||
+        syserr(_g("cannot open file %s"), $file);
     my $result = 0;
     while (<SYM_FILE>) {
 	if (/^\Q$soname\E /) {
@@ -470,7 +473,7 @@ sub find_packages {
 	} elsif (m/^([^:]+): (\S+)$/) {
 	    $pkgmatch->{$2} = [ split(/, /, $1) ];
 	} else {
-	    warning(sprintf(_g("unknown output from dpkg --search: '%s'"), $_));
+	    warning(_g("unknown output from dpkg --search: '%s'"), $_);
 	}
     }
     close(DPKG);

Разница между файлами не показана из-за своего большого размера
+ 250 - 197
scripts/dpkg-source.pl