Sfoglia il codice sorgente

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

It allows to read substitution variables from multiple files.
Raphaël Hertzog 16 anni fa
parent
commit
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
   * dpkg-buildpackage now supports options --source-option=<opt> and
     --changes-option=<opt> to forward arbitrary options to dpkg-source and
     --changes-option=<opt> to forward arbitrary options to dpkg-source and
     dpkg-genchanges respectively. Closes: #566230
     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 ]
   [ Guillem Jover ]
   * Handle argument parsing in dpkg-checkbuilddeps and dpkg-scanpackages
   * 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 .
 .BR debian/substvars .
 No variable substitution is done on any of the fields that are output,
 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
 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
 .TP
 .BI \-D field = value
 .BI \-D field = value
 Override or add an output control file field.
 Override or add an output control file field.

+ 2 - 0
man/dpkg-gencontrol.1

@@ -48,6 +48,8 @@ Read substitution variables in
 .IR substvarsfile ;
 .IR substvarsfile ;
 the default is
 the default is
 .BR debian/substvars .
 .BR debian/substvars .
+This option can be used multiple times to read substitution variables from
+multiple files.
 .TP
 .TP
 .BI \-D field = value
 .BI \-D field = value
 Override or add an output control file field.
 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
 .BI \-T substvarsfile
 Read substitution variables in
 Read substitution variables in
 .IR substvarsfile ;
 .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
 .TP
 .BI \-D field = value
 .BI \-D field = value
 Override or add an output control file field.
 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 $changelogfile = 'debian/changelog';
 my $changelogformat;
 my $changelogformat;
 my $fileslistfile = 'debian/files';
 my $fileslistfile = 'debian/files';
-my $varlistfile = 'debian/substvars';
 my $uploadfilesdir = '..';
 my $uploadfilesdir = '..';
 my $sourcestyle = 'i';
 my $sourcestyle = 'i';
 my $quiet = 0;
 my $quiet = 0;
@@ -75,6 +74,7 @@ my $forcemaint;
 my $forcechangedby;
 my $forcechangedby;
 my $since;
 my $since;
 
 
+my $substvars_loaded = 0;
 my $substvars = Dpkg::Substvars->new();
 my $substvars = Dpkg::Substvars->new();
 $substvars->set("Format", $changes_format);
 $substvars->set("Format", $changes_format);
 
 
@@ -169,7 +169,8 @@ while (@ARGV) {
     } elsif (m/^-v(.*)$/) {
     } elsif (m/^-v(.*)$/) {
 	$since = $1;
 	$since = $1;
     } elsif (m/^-T(.*)$/) {
     } elsif (m/^-T(.*)$/) {
-	$varlistfile = $1;
+	$substvars->load($1) if -e $1;
+	$substvars_loaded = 1;
     } elsif (m/^-m(.*)$/s) {
     } elsif (m/^-m(.*)$/s) {
 	$forcemaint = $1;
 	$forcemaint = $1;
     } elsif (m/^-e(.*)$/s) {
     } elsif (m/^-e(.*)$/s) {
@@ -210,7 +211,7 @@ my $control = Dpkg::Control::Info->new($controlfile);
 my $fields = Dpkg::Control->new(type => CTRL_FILE_CHANGES);
 my $fields = Dpkg::Control->new(type => CTRL_FILE_CHANGES);
 $substvars->set_version_substvars($changelog->{"Version"});
 $substvars->set_version_substvars($changelog->{"Version"});
 $substvars->set_arch_substvars();
 $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
 if (defined($prev_changelog) and
     version_compare_relation($changelog->{"Version"}, REL_LT,
     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 $changelogfile = 'debian/changelog';
 my $changelogformat;
 my $changelogformat;
 my $fileslistfile = 'debian/files';
 my $fileslistfile = 'debian/files';
-my $varlistfile = 'debian/substvars';
 my $packagebuilddir = 'debian/tmp';
 my $packagebuilddir = 'debian/tmp';
 
 
 my $sourceversion;
 my $sourceversion;
@@ -50,6 +49,7 @@ my %remove;
 my %override;
 my %override;
 my $oppackage;
 my $oppackage;
 my $substvars = Dpkg::Substvars->new();
 my $substvars = Dpkg::Substvars->new();
+my $substvars_loaded = 0;
 
 
 
 
 sub version {
 sub version {
@@ -118,8 +118,9 @@ while (@ARGV) {
     } elsif (m/^-V(\w[-:0-9A-Za-z]*)[=:]/) {
     } elsif (m/^-V(\w[-:0-9A-Za-z]*)[=:]/) {
         $substvars->set($1, $');
         $substvars->set($1, $');
 	$substvars->no_warn($1);
 	$substvars->no_warn($1);
-    } elsif (m/^-T/) {
-        $varlistfile= $';
+    } elsif (m/^-T(.*)$/) {
+	$substvars->load($1) if -e $1;
+	$substvars_loaded = 1;
     } elsif (m/^-n/) {
     } elsif (m/^-n/) {
         $forcefilename= $';
         $forcefilename= $';
     } elsif (m/^-(h|-help)$/) {
     } elsif (m/^-(h|-help)$/) {
@@ -139,7 +140,7 @@ $options{"changelogformat"} = $changelogformat if $changelogformat;
 my $changelog = changelog_parse(%options);
 my $changelog = changelog_parse(%options);
 $substvars->set_version_substvars($changelog->{"Version"});
 $substvars->set_version_substvars($changelog->{"Version"});
 $substvars->set_arch_substvars();
 $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;
 $substvars->set("binary:Version", $forceversion) if defined $forceversion;
 my $control = Dpkg::Control::Info->new($controlfile);
 my $control = Dpkg::Control::Info->new($controlfile);
 my $fields = Dpkg::Control->new(type => CTRL_PKG_DEB);
 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");
 textdomain("dpkg-dev");
 
 
-my $varlistfile;
 my $controlfile;
 my $controlfile;
 my $changelogfile;
 my $changelogfile;
 my $changelogformat;
 my $changelogformat;
@@ -164,7 +163,7 @@ while (@options) {
     } elsif (m/^-V(\w[-:0-9A-Za-z]*)[=:](.*)$/s) {
     } elsif (m/^-V(\w[-:0-9A-Za-z]*)[=:](.*)$/s) {
         $substvars->set($1, $2);
         $substvars->set($1, $2);
     } elsif (m/^-T(.*)$/) {
     } elsif (m/^-T(.*)$/) {
-        $varlistfile = $1;
+	$substvars->load($1) if -e $1;
     } elsif (m/^-(h|-help)$/) {
     } elsif (m/^-(h|-help)$/) {
         usage();
         usage();
         exit(0);
         exit(0);
@@ -325,7 +324,6 @@ if ($options{'opmode'} =~ /^(-b|--print-format)$/) {
     # Write the .dsc
     # Write the .dsc
     my $dscname = $srcpkg->get_basename(1) . ".dsc";
     my $dscname = $srcpkg->get_basename(1) . ".dsc";
     info(_g("building %s in %s"), $sourcepackage, $dscname);
     info(_g("building %s in %s"), $sourcepackage, $dscname);
-    $substvars->load($varlistfile) if $varlistfile && -e $varlistfile;
     $srcpkg->write_dsc(filename => $dscname,
     $srcpkg->write_dsc(filename => $dscname,
 		       remove => \%remove,
 		       remove => \%remove,
 		       override => \%override,
 		       override => \%override,