]> git.donarmstrong.com Git - debhelper.git/commitdiff
dh: Use minimal sequences if delegating work
authorRoger Leigh <rleigh@debian.org>
Sun, 12 Jun 2011 19:22:43 +0000 (20:22 +0100)
committerJoey Hess <joey@kitenet.net>
Mon, 13 Jun 2011 19:35:32 +0000 (15:35 -0400)
The build and install rules run a minimal sequence if the build-arch or
build-indep, or install-arch or install-indep targets, respectively,
are present in debian/rules.  The purpose is to not do work ahead of
time, such as building before the build-arch or build-indep targets are
built, which could potentially lead to misbuilds.  If the targets are
not defined, the sequences may be run directly which is faster due to
being able to run the arch and indep commands together.

dh

diff --git a/dh b/dh
index 75070ea8ba9046c7cdde1512ab1c76fcfd4b5fff..8af408c453046e3c8e8a6f2fd5973023ac1fd993 100755 (executable)
--- a/dh
+++ b/dh
@@ -338,6 +338,10 @@ if (is_make_jobserver_unavailable()) {
 
 # Definitions of sequences.
 my %sequences;
+my @bd_minimal = qw{
+       dh_testdir
+       dh_auto_configure
+};
 my @bd = qw{
        dh_testdir
        dh_auto_configure
@@ -357,6 +361,9 @@ $sequences{clean} = [qw{
        dh_auto_clean
        dh_clean
 }];
+my @i_minimal = qw{
+       dh_testroot
+};
 my @i = qw{
        dh_testroot
        dh_prep
@@ -550,6 +557,23 @@ elsif (! exists $sequences{$sequence}) {
        error "Unknown sequence $sequence (choose from: ".
                join(" ", sort keys %sequences).")";
 }
+
+# Note: it's not safe to run rules_explicit_target before this point
+# due to dh being recursively invoked with debhelper-fail-me as the
+# sequence
+# If debian/rules defines build-arch or build-indep, run sequences
+# separately.
+if (rules_explicit_target('build-arch') ||
+    rules_explicit_target('build-indep')) {
+    $sequences{build} = [@bd_minimal, 'rules:build-arch', 'rules:build-indep'];
+}
+# If debian/rules defines install-arch or install-indep, run sequences
+# separately.
+if (rules_explicit_target('install-arch') ||
+    rules_explicit_target('install-indep')) {
+       $sequences{'install'} = ['rules:build', @i_minimal, 'rules:install-arch', 'rules:install-indep'];
+}
+
 my @sequence=@{$sequences{$sequence}};
 
 # The list of all packages that can be acted on.