chiark / gitweb /
Introduce --rm-old-changes to delete previous builds' changes files.
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 7 Nov 2015 13:09:56 +0000 (13:09 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 1 Jul 2016 22:53:45 +0000 (23:53 +0100)
debian/changelog
dgit
dgit.1

index 9b5230dbc24aa0118403a3bcd40c99e2d276e4d4..5d9e8cb064bdf2222de78e7fa4a930fd6c64ee88 100644 (file)
@@ -15,6 +15,7 @@ dgit (1.5~~) unstable; urgency=medium
     avoid accidental  use of the wrong one (by software, or by users).
   * dgit sbuild: Check that the binary .changes file doesn't contain a
     .dsc.
+  * Introduce --rm-old-changes to delete previous builds' changes files.
 
   Documentation:
   * Document the dgit-distro.DISTRO.quilt-mode config setting.
diff --git a/dgit b/dgit
index 51df7c30defe743bd435f8318a718bf4b7e36229..38c1497f808cd9ec990a02a4b230ccad74c643df 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -59,6 +59,7 @@ our %previously;
 our $existing_package = 'dpkg';
 our $cleanmode;
 our $changes_since_version;
+our $rmchanges;
 our $quilt_mode;
 our $quilt_modes_re = 'linear|smash|auto|nofix|nocheck';
 our $we_are_responder;
@@ -3013,6 +3014,16 @@ sub build_prep () {
     $package = getfield $clogp, 'Source';
     $version = getfield $clogp, 'Version';
     build_maybe_quilt_fixup();
+    if ($rmchanges) {
+       my $pat = changespat $version;
+       foreach my $f (glob "$buildproductsdir/$pat") {
+           if (act_local()) {
+               unlink $f or fail "remove old changes file $f: $!";
+           } else {
+               progress "would remove $f";
+           }
+       }
+    }
 }
 
 sub changesopts_initial () {
@@ -3332,6 +3343,9 @@ sub parseopts () {
            } elsif (m/^--no-rm-on-error$/s) {
                push @ropts, $_;
                $rmonerror = 0;
+           } elsif (m/^--(no-)?rm-old-changes$/s) {
+               push @ropts, $_;
+               $rmchanges = !$1;
            } elsif (m/^--deliberately-($deliberately_re)$/s) {
                push @ropts, $_;
                push @deliberatelies, $&;
@@ -3438,6 +3452,11 @@ if (!@ARGV) {
 my $cmd = shift @ARGV;
 $cmd =~ y/-/_/;
 
+if (!defined $rmchanges) {
+    local $access_forpush;
+    $rmchanges = access_cfg_bool(0, 'rm-old-changes');
+}
+
 if (!defined $quilt_mode) {
     local $access_forpush;
     $quilt_mode = cfg('dgit.force.quilt-mode', 'RETURN-UNDEF')
diff --git a/dgit.1 b/dgit.1
index 8235b059fcd63164db25c54b1504b511bb866704..d3f37029679076514a426fa6900f1c7f9661621f 100644 (file)
--- a/dgit.1
+++ b/dgit.1
@@ -526,6 +526,18 @@ otherwise, the changes file is expected in that directory (by
 default, in
 .BR .. ).
 .TP
+.B --rm-old-changes
+When doing a build, delete any changes files matching
+.IB package _ version _*.changes
+before starting.  This ensures that
+dgit push (and dgit sbuild) will be able to unambigously
+identify the relevant changes files from the most recent build, even
+if there have been previous builds with different tools or options.
+The default is not to remove, but
+.B \-\-no-rm-old-changes
+can be used to override a previous \-\-rm-old-changes
+or the .rm-old-changes configuration setting.
+.TP
 .BI --build-products-dir= directory
 Specifies where to find the built files to be uploaded.
 By default, dgit looks in the parent directory
@@ -647,6 +659,10 @@ One of the values for the command line --clean= option; used if
 One of the values for the command line --quilt= option; used if
 --quilt is not specified.
 .TP
+.BR dgit-distro. \fIdistro\fR .rm-old-changes
+Boolean, used if neither \-\-rm-old-changes nor \-\-no-rm-old-changes
+is specified.  The default is not to remove.
+.TP
 .BR dgit-distro. \fIdistro\fR .readonly " " auto | a " | " true | t | y | 1 " | " false | f | n | 0
 Whether you have push access to the distro.
 For Debian, it is OK to use auto, which uses readonly mode if you are