chiark / gitweb /
Also suppress spurious runs of the clean target when building using git-buildpackage.
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 773f19d09d1cdc3392ae3e86f34d1c250f7f8c43..ad460d14add2d9e696f9d10e416c784cbb4d8958 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,20 +2962,26 @@ 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;
     my @cmd =
        (qw(git-buildpackage -us -uc --git-no-sign-tags),
         "--git-builder=@dbp");
+    if ($cleanmode eq 'dpkg-source') {
+       $suppress_clean = 1;
+    } else {
+       push @cmd, '--git-cleaner=true';
+    }
+    build_prep();
     unless (grep { m/^--git-debian-branch|^--git-ignore-branch/ } @ARGV) {
        canonicalise_suite();
        push @cmd, "--git-debian-branch=".lbranch();
@@ -2973,6 +2993,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);