summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdgit35
1 files changed, 35 insertions, 0 deletions
diff --git a/dgit b/dgit
index fe1bff5..7708fb5 100755
--- a/dgit
+++ b/dgit
@@ -64,6 +64,7 @@ our $quilt_mode;
our $quilt_modes_re = 'linear|smash|auto|nofix|nocheck|gbp|unapplied';
our $we_are_responder;
our $initiator_tempdir;
+our $patches_applied_dirtily = 00;
our %format_ok = map { $_=>1 } ("1.0","3.0 (native)","3.0 (quilt)");
@@ -3236,6 +3237,29 @@ sub quilt_fixup_editor () {
exit 0;
}
+sub maybe_apply_patches_dirtily () {
+ return unless $quilt_mode =~ m/gbp|unapplied/;
+ print STDERR <<END or die $!;
+
+dgit: Building, or cleaning with rules target, in patches-unapplied tree.
+dgit: Have to apply the patches - making the tree dirty.
+dgit: (Consider specifying --clean=git and (or) using dgit sbuild.)
+
+END
+ $patches_applied_dirtily = 01;
+ $patches_applied_dirtily |= 02 unless stat_exists '.pc';
+ runcmd qw(dpkg-source --before-build .);
+}
+
+sub maybe_unapply_patches_again () {
+ progress "dgit: Unapplying patches again to tidy up the tree."
+ if $patches_applied_dirtily;
+ runcmd qw(dpkg-source --after-build .)
+ if $patches_applied_dirtily & 01;
+ rmtree '.pc'
+ if $patches_applied_dirtily & 02;
+}
+
#----- other building -----
our $clean_using_builder;
@@ -3247,8 +3271,10 @@ our $clean_using_builder;
sub clean_tree () {
return if $clean_using_builder;
if ($cleanmode eq 'dpkg-source') {
+ maybe_apply_patches_dirtily();
runcmd_ordryrun_local @dpkgbuildpackage, qw(-T clean);
} elsif ($cleanmode eq 'dpkg-source-d') {
+ maybe_apply_patches_dirtily();
runcmd_ordryrun_local @dpkgbuildpackage, qw(-d -T clean);
} elsif ($cleanmode eq 'git') {
runcmd_ordryrun_local @git, qw(clean -xdf);
@@ -3270,6 +3296,7 @@ sub cmd_clean () {
badusage "clean takes no additional arguments" if @ARGV;
notpushing();
clean_tree();
+ maybe_unapply_patches_again();
}
sub build_prep () {
@@ -3391,8 +3418,10 @@ sub cmd_build {
}
if ($wantsrc < 2) {
push @dbp, changesopts_version();
+ maybe_apply_patches_dirtily();
runcmd_ordryrun_local @dbp;
}
+ maybe_unapply_patches_again();
printdone "build successful\n";
}
@@ -3423,8 +3452,10 @@ sub cmd_gbp_build {
push @cmd, "--git-debian-branch=".lbranch();
}
push @cmd, changesopts();
+ maybe_apply_patches_dirtily();
runcmd_ordryrun_local @cmd, @ARGV;
}
+ maybe_unapply_patches_again();
printdone "build successful\n";
}
sub cmd_git_build { cmd_gbp_build(); } # compatibility with <= 1.0
@@ -3451,9 +3482,11 @@ sub build_source {
}
$dscfn = dscfn($version);
if ($our_cleanmode eq 'dpkg-source') {
+ maybe_apply_patches_dirtily();
runcmd_ordryrun_local @dpkgbuildpackage, qw(-us -uc -S),
changesopts();
} elsif ($our_cleanmode eq 'dpkg-source-d') {
+ maybe_apply_patches_dirtily();
runcmd_ordryrun_local @dpkgbuildpackage, qw(-us -uc -S -d),
changesopts();
} else {
@@ -3490,6 +3523,7 @@ sub build_source {
sub cmd_build_source {
badusage "build-source takes no additional arguments" if @ARGV;
build_source();
+ maybe_unapply_patches_again();
printdone "source built, results in $dscfn and $sourcechanges";
}
@@ -3532,6 +3566,7 @@ sub cmd_sbuild {
rename "$cf", "$cf.inmulti" or fail "$cf\{,.inmulti}: $!";
}
}
+ maybe_unapply_patches_again();
printdone "build successful, results in $multichanges\n" or die $!;
}