chiark / gitweb /
When we are using dpkg-buildpackage to clean before using it to also do the build...
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 27 Jul 2015 02:46:32 +0000 (03:46 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 27 Jul 2015 12:11:46 +0000 (13:11 +0100)
debian/changelog
dgit

index ecdd9916d1e30f3eca0be843f97a8652078ef17f..2f296309086665ec6593209448df87faa2930a8b 100644 (file)
@@ -56,6 +56,11 @@ dgit (1.1~~) unstable; urgency=low
   * Rename `git-build' operation to `gbp-build' to make it clearer what
     it's for.  Keep the old name as an alias.
   * Show `dgit sbuild' in usage message.
+  * When we are using dpkg-buildpackage to clean before using it to also
+    do the build, let it do its cleaning thing as part of its run, rather
+    than running it twice.  When we are _not_ supposed to be using
+    dpkg-buildpackage to clean, but we are running it to do the build,
+    pass -nc.
 
  --
 
diff --git a/dgit b/dgit
index 773f19d09d1cdc3392ae3e86f34d1c250f7f8c43..22a1ccd0fbd682c2796aec05f801a12248e79997 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -2867,7 +2867,10 @@ sub quilt_fixup_editor () {
 
 #----- other building -----
 
+our $suppress_clean;
+
 sub clean_tree () {
+    return if $suppress_clean;
     if ($cleanmode eq 'dpkg-source') {
        runcmd_ordryrun_local @dpkgbuildpackage, qw(-T clean);
     } elsif ($cleanmode eq 'dpkg-source-d') {
@@ -2906,8 +2909,11 @@ sub build_prep () {
     build_maybe_quilt_fixup();
 }
 
-sub changesopts () {
+sub changesopts_initial () {
     my @opts =@changesopts[1..$#changesopts];
+}
+
+sub changesopts_version () {
     if (!defined $changes_since_version) {
        my @vsns = archive_query('archive_query');
        my @quirk = access_quirk();
@@ -2928,14 +2934,22 @@ sub changesopts () {
        }
     }
     if ($changes_since_version ne '_') {
-       unshift @opts, "-v$changes_since_version";
+       return ("-v$changes_since_version");
+    } else {
+       return ();
     }
-    return @opts;
+}
+
+sub changesopts () {
+    return (changesopts_initial(), changesopts_version());
 }
 
 sub massage_dbp_args ($) {
     my ($cmd) = @_;
-    return unless $cleanmode =~ m/git|none/;
+    if ($cleanmode eq 'dpkg-source') {
+       $suppress_clean = 1;
+       return;
+    }
     debugcmd '#massaging#', @$cmd if $debuglevel>1;
     my @newcmd = shift @$cmd;
     # -nc has the side effect of specifying -b if nothing else specified
@@ -2948,17 +2962,18 @@ sub massage_dbp_args ($) {
 }
 
 sub cmd_build {
-    build_prep();
-    my @dbp = (@dpkgbuildpackage, qw(-us -uc), changesopts(), @ARGV);
+    my @dbp = (@dpkgbuildpackage, qw(-us -uc), changesopts_initial(), @ARGV);
     massage_dbp_args \@dbp;
+    build_prep();
+    push @dbp, changesopts_version();
     runcmd_ordryrun_local @dbp;
     printdone "build successful\n";
 }
 
 sub cmd_gbp_build {
-    build_prep();
     my @dbp = @dpkgbuildpackage;
     massage_dbp_args \@dbp;
+    build_prep();
     my @cmd =
        (qw(git-buildpackage -us -uc --git-no-sign-tags),
         "--git-builder=@dbp");
@@ -2973,6 +2988,10 @@ sub cmd_gbp_build {
 sub cmd_git_build { cmd_gbp_build(); } # compatibility with <= 1.0
 
 sub build_source {
+    if ($cleanmode =~ m/^dpkg-source/) {
+       # dpkg-source will clean, so we shouldn't
+       $suppress_clean = 1;
+    }
     build_prep();
     $sourcechanges = "${package}_".(stripepoch $version)."_source.changes";
     $dscfn = dscfn($version);