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

dpkg-gencontrol, dpkg-genchanges, dpkg-source: support multiple -T options

It allows to read substitution variables from multiple files.
Raphaël Hertzog лет назад: 16
Родитель
Сommit
a17570383c

+ 3 - 0
debian/changelog

@@ -46,6 +46,9 @@ dpkg (1.15.6) UNRELEASED; urgency=low
   * dpkg-buildpackage now supports options --source-option=<opt> and
     --changes-option=<opt> to forward arbitrary options to dpkg-source and
     dpkg-genchanges respectively. Closes: #566230
+  * The -T option of dpkg-{source,gencontrol,genchanges} can now be used
+    multiple times to read substitution variables from multiple files.
+    Closes: #363323
 
   [ Guillem Jover ]
   * Handle argument parsing in dpkg-checkbuilddeps and dpkg-scanpackages

+ 3 - 1
man/dpkg-genchanges.1

@@ -81,7 +81,9 @@ the default is
 .BR debian/substvars .
 No variable substitution is done on any of the fields that are output,
 however the special variable \fIFormat\fR will override the field of the
-same name.
+same name. This option can be used multiple times to read substitution
+variables from multiple files.
+
 .TP
 .BI \-D field = value
 Override or add an output control file field.

+ 2 - 0
man/dpkg-gencontrol.1

@@ -48,6 +48,8 @@ Read substitution variables in
 .IR substvarsfile ;
 the default is
 .BR debian/substvars .
+This option can be used multiple times to read substitution variables from
+multiple files.
 .TP
 .BI \-D field = value
 Override or add an output control file field.

+ 2 - 1
man/dpkg-source.1

@@ -110,7 +110,8 @@ See \fBdeb\-substvars\fP(5) for a discussion of output substitution.
 .BI \-T substvarsfile
 Read substitution variables in
 .IR substvarsfile ;
-the default is to not read any file.
+the default is to not read any file. This option can be used multiple
+times to read substitution variables from multiple files.
 .TP
 .BI \-D field = value
 Override or add an output control file field.

+ 4 - 3
scripts/dpkg-genchanges.pl

@@ -40,7 +40,6 @@ my $controlfile = 'debian/control';
 my $changelogfile = 'debian/changelog';
 my $changelogformat;
 my $fileslistfile = 'debian/files';
-my $varlistfile = 'debian/substvars';
 my $uploadfilesdir = '..';
 my $sourcestyle = 'i';
 my $quiet = 0;
@@ -75,6 +74,7 @@ my $forcemaint;
 my $forcechangedby;
 my $since;
 
+my $substvars_loaded = 0;
 my $substvars = Dpkg::Substvars->new();
 $substvars->set("Format", $changes_format);
 
@@ -169,7 +169,8 @@ while (@ARGV) {
     } elsif (m/^-v(.*)$/) {
 	$since = $1;
     } elsif (m/^-T(.*)$/) {
-	$varlistfile = $1;
+	$substvars->load($1) if -e $1;
+	$substvars_loaded = 1;
     } elsif (m/^-m(.*)$/s) {
 	$forcemaint = $1;
     } elsif (m/^-e(.*)$/s) {
@@ -210,7 +211,7 @@ my $control = Dpkg::Control::Info->new($controlfile);
 my $fields = Dpkg::Control->new(type => CTRL_FILE_CHANGES);
 $substvars->set_version_substvars($changelog->{"Version"});
 $substvars->set_arch_substvars();
-$substvars->load($varlistfile) if -e $varlistfile;
+$substvars->load("debian/substvars") if -e "debian/substvars" and not $substvars_loaded;
 
 if (defined($prev_changelog) and
     version_compare_relation($changelog->{"Version"}, REL_LT,

+ 5 - 4
scripts/dpkg-gencontrol.pl

@@ -39,7 +39,6 @@ my $controlfile = 'debian/control';
 my $changelogfile = 'debian/changelog';
 my $changelogformat;
 my $fileslistfile = 'debian/files';
-my $varlistfile = 'debian/substvars';
 my $packagebuilddir = 'debian/tmp';
 
 my $sourceversion;
@@ -50,6 +49,7 @@ my %remove;
 my %override;
 my $oppackage;
 my $substvars = Dpkg::Substvars->new();
+my $substvars_loaded = 0;
 
 
 sub version {
@@ -118,8 +118,9 @@ while (@ARGV) {
     } elsif (m/^-V(\w[-:0-9A-Za-z]*)[=:]/) {
         $substvars->set($1, $');
 	$substvars->no_warn($1);
-    } elsif (m/^-T/) {
-        $varlistfile= $';
+    } elsif (m/^-T(.*)$/) {
+	$substvars->load($1) if -e $1;
+	$substvars_loaded = 1;
     } elsif (m/^-n/) {
         $forcefilename= $';
     } elsif (m/^-(h|-help)$/) {
@@ -139,7 +140,7 @@ $options{"changelogformat"} = $changelogformat if $changelogformat;
 my $changelog = changelog_parse(%options);
 $substvars->set_version_substvars($changelog->{"Version"});
 $substvars->set_arch_substvars();
-$substvars->load($varlistfile) if -e $varlistfile;
+$substvars->load("debian/substvars") if -e "debian/substvars" and not $substvars_loaded;
 $substvars->set("binary:Version", $forceversion) if defined $forceversion;
 my $control = Dpkg::Control::Info->new($controlfile);
 my $fields = Dpkg::Control->new(type => CTRL_PKG_DEB);

+ 1 - 3
scripts/dpkg-source.pl

@@ -49,7 +49,6 @@ use File::Spec;
 
 textdomain("dpkg-dev");
 
-my $varlistfile;
 my $controlfile;
 my $changelogfile;
 my $changelogformat;
@@ -164,7 +163,7 @@ while (@options) {
     } elsif (m/^-V(\w[-:0-9A-Za-z]*)[=:](.*)$/s) {
         $substvars->set($1, $2);
     } elsif (m/^-T(.*)$/) {
-        $varlistfile = $1;
+	$substvars->load($1) if -e $1;
     } elsif (m/^-(h|-help)$/) {
         usage();
         exit(0);
@@ -325,7 +324,6 @@ if ($options{'opmode'} =~ /^(-b|--print-format)$/) {
     # Write the .dsc
     my $dscname = $srcpkg->get_basename(1) . ".dsc";
     info(_g("building %s in %s"), $sourcepackage, $dscname);
-    $substvars->load($varlistfile) if $varlistfile && -e $varlistfile;
     $srcpkg->write_dsc(filename => $dscname,
 		       remove => \%remove,
 		       override => \%override,