Ver código fonte

Dpkg::Changelog::Parse: Always pass the filename to the changelog parser

This allows the parser to handle compressed files transparently, instead
of opening them and passing the contents through standard input.

Closes: #684196
Guillem Jover 14 anos atrás
pai
commit
c4cca9674d
2 arquivos alterados com 7 adições e 9 exclusões
  1. 1 0
      debian/changelog
  2. 6 9
      scripts/Dpkg/Changelog/Parse.pm

+ 1 - 0
debian/changelog

@@ -107,6 +107,7 @@ dpkg (1.17.0) UNRELEASED; urgency=low
   * Switch program usage errors to not print entire --help output.
     Closes: #681371
   * Document that «dpkg-parsechangelog -l-» can be used to read from stdin.
+  * Support parsing compressed changelog files transparently. Closes: #684196
 
   [ Updated programs translations ]
   * Fix typo in Spanish translation of update-alternatives.

+ 6 - 9
scripts/Dpkg/Changelog/Parse.pm

@@ -78,7 +78,6 @@ sub changelog_parse {
                       "$Dpkg::LIBDIR/parsechangelog",
                       '/usr/lib/dpkg/parsechangelog');
     my $format = 'debian';
-    my $changelogfile = 'debian/changelog';
     my $force = 0;
 
     # Extract and remove options that do not concern the changelog parser
@@ -87,16 +86,18 @@ sub changelog_parse {
 	unshift @parserpath, $options{libdir};
 	delete $options{libdir};
     }
-    if (exists $options{file}) {
-	$changelogfile = $options{file};
-	delete $options{file};
-    }
     if (exists $options{changelogformat}) {
 	$format = $options{changelogformat};
 	delete $options{changelogformat};
 	$force = 1;
     }
 
+    # Set a default filename
+    if (not exists $options{file}) {
+	$options{file} = 'debian/changelog';
+    }
+    my $changelogfile = $options{file};
+
     # Extract the format from the changelog file if possible
     unless($force or ($changelogfile eq '-')) {
 	open(my $format_fh, '-|', 'tail', '-n', '40', $changelogfile);
@@ -137,10 +138,6 @@ sub changelog_parse {
     my $pid = open(my $parser_fh, '-|');
     syserr(_g('cannot fork for %s'), $parser) unless defined $pid;
     if (not $pid) {
-	if ($changelogfile ne '-') {
-	    open(STDIN, '<', $changelogfile) or
-		syserr(_g('cannot open %s'), $changelogfile);
-	}
 	exec(@exec) || syserr(_g('cannot exec format parser: %s'), $parser);
     }