[devscripts] 03/03: debuild: Require a -- between debuild options and rules target

James McCoy jamessan at debian.org
Thu Nov 24 19:31:51 UTC 2016


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

jamessan pushed a commit to branch master
in repository devscripts.

commit 6d49d2f0504c460e45f2d84b8bbd551b07f45778
Author: James McCoy <jamessan at debian.org>
Date:   Thu Nov 24 14:31:14 2016 -0500

    debuild: Require a -- between debuild options and rules target
    
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 debian/NEWS         |  10 +++
 debian/changelog    |   2 +
 scripts/debclean.sh |   2 +-
 scripts/debuild.1   |   2 +-
 scripts/debuild.pl  | 175 +++++++++++++++++++++++++++++-----------------------
 5 files changed, 111 insertions(+), 80 deletions(-)

diff --git a/debian/NEWS b/debian/NEWS
index 1590319..11a7dad 100644
--- a/debian/NEWS
+++ b/debian/NEWS
@@ -1,3 +1,13 @@
+devscripts (2.16.10) UNRELEASED; urgency=medium
+
+  debuild's target mode (i.e. where it runs the specified debian/rules
+  targets) now requires a '--' between the debuild options and the targets
+  that need to be run.
+
+  For example, "debuild -d -- build-arch binary-arch".
+
+ -- James McCoy <jamessan at debian.org>  Thu, 24 Nov 2016 14:25:12 -0500
+
 devscripts (2.14.0) unstable; urgency=medium
 
   uscan now looks for upstream's keyring under debian/upstream/ as either
diff --git a/debian/changelog b/debian/changelog
index 7a51506..a5a7ed7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,8 @@ devscripts (2.16.10) UNRELEASED; urgency=medium
     + Fix mapping of debuild final-clean hook to dpkg-buildpackage's
       postclean.
     + Preserve SOURCE_DATE_EPOCH in the environment.
+    + Require a '--' between debuild options and debian/rules target so we
+      know where options end.
 
  -- Afif Elghraoui <afif at debian.org>  Wed, 23 Nov 2016 23:50:46 -0800
 
diff --git a/scripts/debclean.sh b/scripts/debclean.sh
index 45510a9..a239d20 100755
--- a/scripts/debclean.sh
+++ b/scripts/debclean.sh
@@ -194,7 +194,7 @@ for i in `find . -type d -name "debian"`; do
     fi
 
     # We now know we're OK and debuild won't complain about the dirname
-    debuild $CHECKBUILDDEP clean
+    debuild $CHECKBUILDDEP -- clean
 
     # Clean up the package related files
     if [ "$DEBCLEAN_CLEANDEBS" = yes ]; then
diff --git a/scripts/debuild.1 b/scripts/debuild.1
index 4e8445f..da55ec0 100644
--- a/scripts/debuild.1
+++ b/scripts/debuild.1
@@ -5,7 +5,7 @@ debuild \- build a Debian package
 \fBdebuild\fR [\fIdebuild options\fR] [\fIdpkg-buildpackage options\fR]
 [\fB\-\-lintian-opts\fR \fIlintian options\fR]
 .br
-\fBdebuild\fR [\fIdebuild options\fR]
+\fBdebuild\fR [\fIdebuild options\fR] \-\-
 \fBbinary\fR|\fBbinary-arch\fR|\fBbinary-indep\fR|\fBclean\fR ...
 .SH DESCRIPTION
 \fBdebuild\fR creates all the files necessary for uploading a Debian
diff --git a/scripts/debuild.pl b/scripts/debuild.pl
index 2f4a598..9c13961 100755
--- a/scripts/debuild.pl
+++ b/scripts/debuild.pl
@@ -21,7 +21,7 @@
 # We will do simple option processing.  The calling syntax of this
 # program is:
 #
-#   debuild [<debuild options>] binary|binary-arch|binary-indep|clean ...
+#   debuild [<debuild options>] -- binary|binary-arch|binary-indep|clean ...
 # or
 #   debuild [<debuild options>] [<dpkg-buildpackage options>]
 #            [--lintian-opts <lintian options>]
@@ -847,6 +847,9 @@ while ($_=shift) {
 	unshift @ARGV, $_;
 	last;
     }
+    if ($_ eq '--') {
+      last;
+    }
     push (@dpkg_opts, $_);
 }
 
@@ -861,10 +864,6 @@ if (@ARGV) {
 	shift;
 	push(@lintian_opts, @ARGV);
     }
-    else {
-	# It must be a debian/rules target
-	push(@dpkg_opts, '--target', @ARGV);
-    }
 }
 
 if ($signchanges==1 and $signsource==0) {
@@ -940,93 +939,113 @@ foreach my $flag (@buildflags) {
     }
 }
 
-# We'll need to be a bit cleverer to determine the changes file name;
-# see below
-$build="${pkg}_${sversion}_${arch}.build";
-$changes="${pkg}_${sversion}_${arch}.changes";
-open BUILD, "| tee ../$build" or fatal "couldn't open pipe to tee: $!";
-$logging=1;
-close STDOUT;
-close STDERR;
-open STDOUT, ">&BUILD" or fatal "can't reopen stdout: $!";
-open STDERR, ">&BUILD" or fatal "can't reopen stderr: $!";
-
 if (defined($checkbuilddep)) {
     unshift @dpkg_opts, ($checkbuilddep ? "-D" : "-d");
 }
-if ($run_lintian) {
-    push(@dpkg_opts, '--check-command=lintian',
-	map { "--check-option=$_" } @lintian_opts);
-}
 unshift @dpkg_opts, "-r$root_command" if $root_command;
-system_withecho('dpkg-buildpackage', @dpkg_opts);
-
-chdir '..' or fatal "can't chdir: $!";
-
-open CHANGES, '<', $changes or fatal "can't open $changes for reading: $!";
-my @changefilecontents = <CHANGES>;
-close CHANGES;
-
-# check Ubuntu merge Policy: When merging with Debian, -v must be used
-# and the remaining changes described
-my $ch = join "\n", @changefilecontents;
-if ($sourceonly && $version =~ /ubuntu1$/ && $ENV{'DEBEMAIL'} =~ /ubuntu/ &&
-    $ch =~ /(merge|sync).*Debian/i) {
-    push (@warnings, "Ubuntu merge policy: when merging Ubuntu packages with Debian, -v must be used") unless $since;
-    push (@warnings, "Ubuntu merge policy: when merging Ubuntu packages with Debian, changelog must describe the remaining Ubuntu changes")
-	unless $ch =~ /Changes:.*(remaining|Ubuntu)(.|\n )*(differen|changes)/is;
-}
 
-# They've insisted.  Who knows why?!
-if (($signchanges or $signsource) and $usepause) {
-    print "Press the return key to start signing process\n";
-    <STDIN>;
-}
+if (@ARGV) {
+    # Run each rule
+    for my $target (@ARGV) {
+	system_withecho('dpkg-buildpackage', '--rules-target', $target, @dpkg_opts);
+    }
 
-run_hook('signing', ($signchanges || (! $sourceonly and $signsource)) );
+    # Any warnings?
+    if (@warnings) {
+	# Don't know why we need this, but seems that we do, otherwise,
+	# the warnings get muddled up with the other output.
+	IO::Handle::flush(\*STDOUT);
 
-if ($signchanges) {
-    foreach my $var (keys %store_vars) {
-	$ENV{$var} = $store_vars{$var};
-    }
-    print "Now signing changes and any dsc files...\n";
-    if ($username) {
-	system('debrsign', @debsign_opts, $username, $changes) == 0
-	    or fatal "running debrsign failed";
-    } else {
-	system('debsign', @debsign_opts, $changes) == 0
-	    or fatal "running debsign failed";
+	my $warns = @warnings > 1 ? "S" : "";
+	warn "\nWARNING$warns generated by $progname:\n" .
+	    join("\n", @warnings) . "\n";
     }
 }
-elsif (! $sourceonly and $signsource) {
-    print "Now signing dsc file...\n";
-    if ($username) {
-	system('debrsign', @debsign_opts, $username, $dsc) == 0
-	    or fatal "running debrsign failed";
-    } else {
-	system('debsign', @debsign_opts, $dsc) == 0
-	    or fatal "running debsign failed";
+else {
+    # We'll need to be a bit cleverer to determine the changes file name;
+    # see below
+    $build="${pkg}_${sversion}_${arch}.build";
+    $changes="${pkg}_${sversion}_${arch}.changes";
+    open BUILD, "| tee ../$build" or fatal "couldn't open pipe to tee: $!";
+    $logging=1;
+    close STDOUT;
+    close STDERR;
+    open STDOUT, ">&BUILD" or fatal "can't reopen stdout: $!";
+    open STDERR, ">&BUILD" or fatal "can't reopen stderr: $!";
+
+    if ($run_lintian) {
+	push(@dpkg_opts, '--check-command=lintian',
+	    map { "--check-option=$_" } @lintian_opts);
+    }
+    system_withecho('dpkg-buildpackage', @dpkg_opts);
+
+    chdir '..' or fatal "can't chdir: $!";
+
+    open CHANGES, '<', $changes or fatal "can't open $changes for reading: $!";
+    my @changefilecontents = <CHANGES>;
+    close CHANGES;
+
+    # check Ubuntu merge Policy: When merging with Debian, -v must be used
+    # and the remaining changes described
+    my $ch = join "\n", @changefilecontents;
+    if ($sourceonly && $version =~ /ubuntu1$/ && $ENV{'DEBEMAIL'} =~ /ubuntu/ &&
+	$ch =~ /(merge|sync).*Debian/i) {
+	push (@warnings, "Ubuntu merge policy: when merging Ubuntu packages with Debian, -v must be used") unless $since;
+	push (@warnings, "Ubuntu merge policy: when merging Ubuntu packages with Debian, changelog must describe the remaining Ubuntu changes")
+	    unless $ch =~ /Changes:.*(remaining|Ubuntu)(.|\n )*(differen|changes)/is;
     }
-}
 
-run_hook('post-dpkg-buildpackage', 1);
+    # They've insisted.  Who knows why?!
+    if (($signchanges or $signsource) and $usepause) {
+	print "Press the return key to start signing process\n";
+	<STDIN>;
+    }
+
+    run_hook('signing', ($signchanges || (! $sourceonly and $signsource)) );
+
+    if ($signchanges) {
+	foreach my $var (keys %store_vars) {
+	    $ENV{$var} = $store_vars{$var};
+	}
+	print "Now signing changes and any dsc files...\n";
+	if ($username) {
+	    system('debrsign', @debsign_opts, $username, $changes) == 0
+		or fatal "running debrsign failed";
+	} else {
+	    system('debsign', @debsign_opts, $changes) == 0
+		or fatal "running debsign failed";
+	}
+    }
+    elsif (! $sourceonly and $signsource) {
+	print "Now signing dsc file...\n";
+	if ($username) {
+	    system('debrsign', @debsign_opts, $username, $dsc) == 0
+		or fatal "running debrsign failed";
+	} else {
+	    system('debsign', @debsign_opts, $dsc) == 0
+		or fatal "running debsign failed";
+	}
+    }
 
-# Any warnings?
-if (@warnings) {
-    # Don't know why we need this, but seems that we do, otherwise,
-    # the warnings get muddled up with the other output.
-    IO::Handle::flush(\*STDOUT);
+    run_hook('post-dpkg-buildpackage', 1);
 
-    my $warns = @warnings > 1 ? "S" : "";
-    warn "\nWARNING$warns generated by $progname:\n" .
-	join("\n", @warnings) . "\n";
+    # Any warnings?
+    if (@warnings) {
+	# Don't know why we need this, but seems that we do, otherwise,
+	# the warnings get muddled up with the other output.
+	IO::Handle::flush(\*STDOUT);
+
+	my $warns = @warnings > 1 ? "S" : "";
+	warn "\nWARNING$warns generated by $progname:\n" .
+	    join("\n", @warnings) . "\n";
+    }
+    # close the logging process
+    close STDOUT;
+    close STDERR;
+    close BUILD;
+    open STDOUT, ">&", \*OLDOUT;
+    open STDERR, ">&", \*OLDERR;
 }
-# close the logging process
-close STDOUT;
-close STDERR;
-close BUILD;
-open STDOUT, ">&", \*OLDOUT;
-open STDERR, ">&", \*OLDERR;
 exit 0;
 
 ###### Subroutines

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list