[devscripts] 01/01: debuild: Handle difference in where dpkg-bp/debuild run hooks

James McCoy jamessan at debian.org
Fri Nov 25 22:10:15 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 3e71ba36160b9fb5d03d755f94da14093e742a4b
Author: James McCoy <jamessan at debian.org>
Date:   Fri Nov 25 16:15:36 2016 -0500

    debuild: Handle difference in where dpkg-bp/debuild run hooks
    
    Document where each debuild hook is executed (either in unpacked source
    or its parent directory).
    
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 debian/changelog   |  3 +++
 scripts/debuild.1  | 20 +++++++++++++++++++
 scripts/debuild.pl | 58 +++++++++++++++++++++++++++++++++++++++++++++++-------
 3 files changed, 74 insertions(+), 7 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index ae2b897..5afcb9d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -15,6 +15,9 @@ devscripts (2.16.10) UNRELEASED; urgency=medium
     + Preserve SOURCE_DATE_EPOCH in the environment.
     + Require a '--' between debuild options and debian/rules target so we
       know where options end.  (Closes: #845566)
+    + Adjust hook commands to account for dpkg-buildpackage running from a
+      different directory than debuild used for the lintian, signing, and
+      post-dpkg-buildpackage hooks.  (Closes: #845628)
 
  -- Afif Elghraoui <afif at debian.org>  Wed, 23 Nov 2016 23:50:46 -0800
 
diff --git a/scripts/debuild.1 b/scripts/debuild.1
index da55ec0..1e8938a 100644
--- a/scripts/debuild.1
+++ b/scripts/debuild.1
@@ -155,6 +155,8 @@ hooks are as follows:
 \fBdpkg-buildpackage-hook
 Run before \fBdpkg-buildpackage\fR begins by calling \fBdpkg-checkbuilddeps\fR.
 .IP
+Hook is run inside the unpacked source.
+.IP
 Corresponds to \fBdpkg\fR's \fBinit\fR hook.
 .TP
 \fBclean-hook
@@ -162,12 +164,16 @@ Run before \fBdpkg-buildpackage\fR runs \fBdebian/rules clean\fR to clean the
 source tree.  (Run even if the tree is not being cleaned because \fB\-nc\fR
 is used.)
 .IP
+Hook is run inside the unpacked source.
+.IP
 Corresponds to \fBdpkg\fR's \fBpreclean\fR hook.
 .TP
 \fBdpkg-source-hook
 Run after cleaning the tree and before running \fBdpkg-source\fR.  (Run even
 if \fBdpkg-source\fR is not being called because \fB\-b\fR, \fB\-B\fR, or \fB\-A\fR is used.)
 .IP
+Hook is run inside the unpacked source.
+.IP
 Corresponds to \fBdpkg\fR's \fBsource\fR hook.
 .TP
 \fBdpkg-build-hook\fR
@@ -175,18 +181,24 @@ Run after \fBdpkg-source\fR and before calling \fBdebian/rules build\fR.  (Run
 even if this is a source-only build, so \fBdebian/rules build\fR is not
 being called.)
 .IP
+Hook is run inside the unpacked source.
+.IP
 Corresponds to \fBdpkg\fR's \fBbuild\fR hook.
 .TP
 \fBdpkg-binary-hook
 Run between \fBdebian/rules build\fR and \fBdebian/rules binary\fR(\fB\-arch\fR).  Run
 \fBonly\fR if a binary package is being built.
 .IP
+Hook is run inside the unpacked source.
+.IP
 Corresponds to \fBdpkg\fR's \fBbinary\fR hook.
 .TP
 \fBdpkg-genchanges-hook
 Run after the binary package is built and before calling
 \fBdpkg-genchanges\fR.
 .IP
+Hook is run inside the unpacked source.
+.IP
 Corresponds to \fBdpkg\fR's \fBchanges\fR hook.
 .TP
 \fBfinal-clean-hook
@@ -194,23 +206,31 @@ Run after \fBdpkg-genchanges\fR and before the final \fBdebian/rules clean\fR.
 (Run even if we are not cleaning the tree post-build, which is the
 default.)
 .IP
+Hook is run inside the unpacked source.
+.IP
 Corresponds to \fBdpkg\fR's \fBpostclean\fR hook.
 .TP
 \fBlintian-hook
 Run (once) before calling \fBlintian\fR.  (Run even if we are
 not calling \fBlintian\fR.)
 .IP
+Hook is run from parent directory of unpacked source.
+.IP
 Corresponds to \fBdpkg\fR's \fBcheck\fR hook.
 .TP
 \fBsigning-hook
 Run after calling \fBlintian\fR before any signing takes place.
 (Run even if we are not signing anything.)
 .IP
+Hook is run from parent directory of unpacked source.
+.IP
 Corresponds to \fBdpkg\fR's \fBsign\fR hook, but is run by \fBdebuild\fR.
 .TP
 \fBpost-dpkg-buildpackage-hook
 Run after everything has finished.
 .IP
+Hook is run from parent directory of unpacked source.
+.IP
 Corresponds to \fBdpkg\fR's \fBdone\fR hook, but is run by \fBdebuild\fR.
 .PP
 A hook command can be specified either in the configuration file as,
diff --git a/scripts/debuild.pl b/scripts/debuild.pl
index 9c13961..b40c412 100755
--- a/scripts/debuild.pl
+++ b/scripts/debuild.pl
@@ -63,6 +63,8 @@ my $modified_conf_msg;
 my @warnings;
 
 # Predeclare functions
+sub setDebuildHook;
+sub setDpkgHook;
 sub system_withecho(@);
 sub run_hook ($$);
 sub fatal($);
@@ -187,8 +189,19 @@ my $username='';
 my @hooks = (qw(dpkg-buildpackage clean dpkg-source build binary dpkg-genchanges
 		final-clean lintian signing post-dpkg-buildpackage));
 my %hook;
-$hook{@hooks} = ('') x @hooks;
-
+ at hook{@hooks} = ('') x @hooks;
+# dpkg-buildpackage runs all hooks in the source tree, while debuild runs some
+# in the parent directory.  Use %externalHook to check which run out of tree
+my %externalHook;
+ at externalHook{@hooks} = (0) x @hooks;
+$externalHook{lintian} = 1;
+$externalHook{signing} = 1;
+$externalHook{'post-dpkg-buildpackage'} = 1;
+# Track which hooks are run by dpkg-buildpackage vs. debuild
+my %dpkgHook;
+ at dpkgHook{@hooks} = (1) x @hooks;
+$dpkgHook{signing} = 0;
+$dpkgHook{'post-dpkg-buildpackage'} = 0;
 
 # First handle private options from cvs-debuild
 my ($cvsdeb_file, $cvslin_file);
@@ -331,7 +344,7 @@ if (@ARGV and $ARGV[0] =~ /^--no-?conf$/) {
     for my $hookname (@hooks) {
 	my $config_name = uc "debuild_${hookname}_hook";
 	$config_name =~ tr/-/_/;
-	$hook{$hookname} = $config_vars{$config_name};
+	setDebuildHook($hookname, $config_vars{$config_name});
     }
 
     # Now parse the opts lists
@@ -561,7 +574,8 @@ my @preserve_vars = qw(TERM HOME LOGNAME PGPPATH GNUPGHOME GPG_AGENT_INFO
 	    unless (defined ($opt = shift)) {
 		fatal "$arg requires an argument,\nrun $progname --help for usage information";
 	    }
-	    $hook{$argkey} = $opt;
+
+	    setDebuildHook($argkey, $opt);
 	    next;
 	}
 
@@ -573,7 +587,7 @@ my @preserve_vars = qw(TERM HOME LOGNAME PGPPATH GNUPGHOME GPG_AGENT_INFO
 		fatal "unknown hook option $arg,\nrun $progname --help for usage information";
 	    }
 
-	    $hook{$argkey} = $opt;
+	    setDebuildHook($argkey, $opt);
 	    next;
 	}
 
@@ -584,10 +598,10 @@ my @preserve_vars = qw(TERM HOME LOGNAME PGPPATH GNUPGHOME GPG_AGENT_INFO
 		fatal "$arg requires an argmuent,\nrun $progname --help for usage information";
 	    }
 	    if ($name eq 'sign') {
-		$hook{signing} = $opt;
+		setDpkgHook('signing', $opt);
 	    }
 	    else {
-		$hook{'post-dpkg-buildpackage'} = $opt;
+		setDpkgHook('post-dpkg-buildpackage', $opt);
 	    }
 	    next;
 	}
@@ -1050,6 +1064,36 @@ exit 0;
 
 ###### Subroutines
 
+sub setDebuildHook() {
+    my ($name, $val) = @_;
+
+    unless (grep /^$name$/, @hooks) {
+	fatal "unknown hook $name,\nrun $progname --help for usage information";
+    }
+
+    if ($externalHook{$name} && $dpkgHook{$name}) {
+	$hook{$name} = 'cd ..; '.$val;
+    }
+    else {
+	$hook{$name} = $val;
+    }
+}
+
+sub setDpkgHook() {
+    my ($name, $val) = @_;
+
+    unless (grep /^$name$/, @hooks) {
+	fatal "unknown hook $name,\nrun $progname --help for usage information";
+    }
+
+    if ($externalHook{$name} && !$dpkgHook{$name}) {
+	$hook{$name} = 'cd ..; '.$val;
+    }
+    else {
+	$hook{$name} = $val;
+    }
+}
+
 sub system_withecho(@) {
     print STDERR " ", join(" ", @_), "\n";
     system(@_);

-- 
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