Преглед изворни кода

dpkg-genchanges: Add new -O option

This unifies this command with other commands outputting a generated
file.
Guillem Jover пре 10 година
родитељ
комит
194d3fe7ac
3 измењених фајлова са 16 додато и 4 уклоњено
  1. 1 0
      debian/changelog
  2. 5 1
      man/dpkg-genchanges.1
  3. 10 3
      scripts/dpkg-genchanges.pl

+ 1 - 0
debian/changelog

@@ -79,6 +79,7 @@ dpkg (1.18.5) UNRELEASED; urgency=medium
     “full”) in dpkg-genchanges and dpkg-buildpackage.
   * Add new -I option to dpkg-shlibdeps to ignore package build directories.
     Closes: #821025
+  * Add new -O option to dpkg-genchanges.
   * Portability:
     - Move DPKG_ADMINDIR environment variable name out from update-alternatives
       code, to make life easier for non-dpkg-based systems.

+ 5 - 1
man/dpkg-genchanges.1

@@ -2,7 +2,7 @@
 .\"
 .\" Copyright © 1995-1996 Ian Jackson <ijackson@chiark.greenend.org.uk>
 .\" Copyright © 2000 Wichert Akkerman <wakkerma@debian.org>
-.\" Copyright © 2006-2015 Guillem Jover <guillem@debian.org>
+.\" Copyright © 2006-2016 Guillem Jover <guillem@debian.org>
 .\" Copyright © 2008-2010 Raphaël Hertzog <hertzog@debian.org>
 .\"
 .\" This is free software; you can redistribute it and/or modify
@@ -179,6 +179,10 @@ how many of the package's source files are being uploaded.
 .B \-q
 suppresses these messages.
 .TP
+.BR \-O [\fIfilename\fP]
+Print the changes file to standard output (the default) or to \fIfilename\fP
+if specified (since dpkg 1.18.5).
+.TP
 .BR \-? ", " \-\-help
 Show the usage message and exit.
 .TP

+ 10 - 3
scripts/dpkg-genchanges.pl

@@ -51,6 +51,7 @@ my $controlfile = 'debian/control';
 my $changelogfile = 'debian/changelog';
 my $changelogformat;
 my $fileslistfile = 'debian/files';
+my $outputfile;
 my $uploadfilesdir = '..';
 my $sourcestyle = 'i';
 my $quiet = 0;
@@ -119,6 +120,7 @@ sub usage {
   -T<substvars-file>       read variables here, not debian/substvars.
   -D<field>=<value>        override or add a field and value.
   -U<field>                remove a field.
+  -O[<filename>]           write to stdout (default) or <filename>.
   -?, --help               show this help message.
       --version            show the version.
 "), $Dpkg::PROGNAME;
@@ -172,6 +174,8 @@ while (@ARGV) {
         $remove{$1} = 1;
     } elsif (m/^-V(\w[-:0-9A-Za-z]*)[=:](.*)$/s) {
 	$substvars->set($1, $2);
+    } elsif (m/^-O(.*)$/) {
+        $outputfile = $1;
     } elsif (m/^-(?:\?|-help)$/) {
 	usage();
 	exit(0);
@@ -183,8 +187,11 @@ while (@ARGV) {
     }
 }
 
-# Do not pollute STDOUT with info messages.
-report_options(info_fh => \*STDERR, quiet_warnings => $quiet);
+# Do not pollute STDOUT with info messages if the .changes file goes there.
+if (not defined $outputfile) {
+    report_options(info_fh => \*STDERR, quiet_warnings => $quiet);
+    $outputfile = '-';
+}
 
 # Retrieve info from the current changelog entry
 my %options = (file => $changelogfile);
@@ -500,4 +507,4 @@ for my $f (keys %remove) {
 
 # Note: do not perform substitution of variables, one of the reasons is that
 # they could interfere with field values, for example the Changes field.
-$fields->output(\*STDOUT);
+$fields->save($outputfile);