[dpkg] 56/200: dpkg-buildpackage: Add support for multiple targets on -T

Ximin Luo infinity0 at debian.org
Wed Apr 5 15:17:16 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository dpkg.

commit 507d2533461f5f81dd013e028e738ef424aeeae0
Author: Guillem Jover <guillem at debian.org>
Date:   Fri Nov 25 03:09:43 2016 +0100

    dpkg-buildpackage: Add support for multiple targets on -T
    
    This makes it possible to run several desired targets in a single run,
    which avoids the overhead of the rest of the steps run. It also makes
    it possible to test if packages can be built twice in a row.
    
    Closes: #671074
---
 debian/changelog             |  2 ++
 man/dpkg-buildpackage.man    | 19 ++++++++++---------
 scripts/dpkg-buildpackage.pl | 13 +++++++------
 3 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index fec3969..13b8710 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,8 @@
 dpkg (1.18.16) UNRELEASED; urgency=medium
 
   [ Guillem Jover ]
+  * Add support for specifying multiple targets on «dpkg-buildpackage -T»
+    which will be run successively. Closes: #671074
   * Perl modules:
     - Whitelist DPKG_GENSYMBOLS_CHECK_LEVEL, DPKG_ROOT, DPKG_ADMINDIR and
       DPKG_DATADIR environment variables in Dpkg::Build::Info.
diff --git a/man/dpkg-buildpackage.man b/man/dpkg-buildpackage.man
index 77db2b4..9024e0b 100644
--- a/man/dpkg-buildpackage.man
+++ b/man/dpkg-buildpackage.man
@@ -41,9 +41,9 @@ has been used).
 It checks that the build-dependencies and build-conflicts
 are satisfied (unless \fB\-d\fP or \fB\-\-no\-check\-builddeps\fP is specified).
 .IP \fB3.\fP 3
-If a specific target has been selected with the \fB\-T\fP or \fB\-\-target\fP
-option, it calls that target and stops here. Otherwise it runs the
-\fBpreclean\fP hook and calls \fBfakeroot debian/rules clean\fP to
+If one or more specific targets have been selected with the \fB\-T\fP or
+\fB\-\-target\fP option, it calls those targets and stops here. Otherwise it
+runs the \fBpreclean\fP hook and calls \fBfakeroot debian/rules clean\fP to
 clean the build-tree (unless \fB\-nc\fP or \fB\-\-no\-pre\-clean\fP
 is specified).
 .IP \fB4.\fP 3
@@ -159,14 +159,15 @@ Equivalent to \fB\-\-build=source\fP.
 Equivalent to \fB\-\-build=full\fP, \fB\-\-build=source,binary\fP or
 \fB\-\-build=source,any,all\fP (since dpkg 1.15.8).
 .TP
-.BI \-\-target= target
+.BR \-\-target= \fItarget\fP[,...]
 .TQ
-.BI "\-\-target " target
+.BR "\-\-target " \fItarget\fP[,...]
 .TQ
-.BR \-T ", " \-\-rules\-target= \fItarget\fP
-Calls \fBdebian/rules\fP \fItarget\fP after having setup the build
-environment and stops the package build process here (since dpkg 1.15.0,
-long option since dpkg 1.18.8).
+.BR \-T ", " \-\-rules\-target= \fItarget\fP[,...]
+Calls \fBdebian/rules\fP \fItarget\fP once per target specified, after
+having setup the build environment, and stops the package build process
+here (since dpkg 1.15.0, long option since dpkg 1.18.8, multi-target
+support since dpkg 1.18.16).
 If \fB\-\-as\-root\fP is also given, then the command is executed
 as root (see \fB\-\-root\-command\fP).
 Note that known targets that are required to
diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl
index 9ec0d84..f3d734a 100755
--- a/scripts/dpkg-buildpackage.pl
+++ b/scripts/dpkg-buildpackage.pl
@@ -165,7 +165,7 @@ my $host_type = '';
 my $target_arch = '';
 my $target_type = '';
 my @build_profiles = ();
-my $call_target = '';
+my @call_target = ();
 my $call_target_as_root = 0;
 my $since;
 my $maint;
@@ -287,9 +287,10 @@ while (@ARGV) {
     } elsif (/^--target-type=(.*)$/) {
 	$target_type = $1;
     } elsif (/^(?:--target|--rules-target|-T)$/) {
-        $call_target = shift @ARGV;
+        push @call_target, split /,/, shift @ARGV;
     } elsif (/^(?:--target=|--rules-target=|-T)(.+)$/) {
-        $call_target = $1;
+        my $arg = $1;
+        push @call_target, split /,/, $arg;
     } elsif (/^--as-root$/) {
         $call_target_as_root = 1;
     } elsif (/^--pre-clean$/) {
@@ -490,7 +491,7 @@ if (not -x 'debian/rules') {
     chmod(0755, 'debian/rules'); # No checks of failures, non fatal
 }
 
-unless ($call_target) {
+if (scalar @call_target == 0) {
     chdir('..') or syserr('chdir ..');
     withecho('dpkg-source', @source_opts, '--before-build', $dir);
     chdir($dir) or syserr("chdir $dir");
@@ -514,7 +515,7 @@ if ($checkbuilddep) {
     }
 }
 
-if ($call_target) {
+foreach my $call_target (@call_target) {
     if ($call_target_as_root or
         $call_target =~ /^(clean|binary(|-arch|-indep))$/)
     {
@@ -522,8 +523,8 @@ if ($call_target) {
     } else {
         withecho(@debian_rules, $call_target);
     }
-    exit 0;
 }
+exit 0 if scalar @call_target;
 
 run_hook('preclean', ! $noclean);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list