From: Ian Jackson Date: Mon, 27 Jul 2015 02:46:32 +0000 (+0100) Subject: When we are using dpkg-buildpackage to clean before using it to also do the build... X-Git-Tag: debian/1.1~15 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=dgit.git;a=commitdiff_plain;h=dbb093b1db7b27bf922f6ad58576cab4fbc342cf 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/debian/changelog b/debian/changelog index ecdd9916..2f296309 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 773f19d0..22a1ccd0 100755 --- 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);