chiark / gitweb /
dgit build, by default, uses the archive to find out what the correct -v<version...
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 53083860f84920f5599583bff0fe0ccb9819c9da..254e3fbf5f588bc1f1bc6a7c20f41492cdd09ab2 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -45,6 +45,7 @@ our $ignoredirty = 0;
 our $noquilt = 0;
 our $existing_package = 'dpkg';
 our $cleanmode = 'dpkg-source';
+our $changes_since_version;
 our $we_are_responder;
 our $initiator_tempdir;
 
@@ -113,8 +114,6 @@ sub dscfn ($) {
     return "${package}_".(stripepoch $vsn).".dsc";
 }
 
-sub changesopts () { return @changesopts[1..$#changesopts]; }
-
 our $us = 'dgit';
 our $debugprefix = '';
 
@@ -1515,12 +1514,13 @@ sub i_resp_progress ($) {
 sub i_resp_complete {
     my $pid = $i_child_pid;
     $i_child_pid = undef; # prevents killing some other process with same pid
-    printdebug "waiting for remote child $pid...";
+    printdebug "waiting for remote child $pid...\n";
     my $got = waitpid $pid, 0;
     die $! unless $got == $pid;
     die "remote child failed $?" if $?;
 
     i_cleanup();
+    printdebug "all done\n";
     exit 0;
 }
 
@@ -1689,6 +1689,26 @@ sub build_prep () {
     build_maybe_quilt_fixup();
 }
 
+sub changesopts () {
+    my @opts =@changesopts[1..$#changesopts];
+    if (!defined $changes_since_version) {
+       my @vsns = archive_query('archive_query');
+       if (@vsns) {
+           @vsns = map { $_->[0] } @vsns;
+           @vsns = sort { version_compare_string($a, $b) } @vsns;
+           $changes_since_version = $vsns[0];
+           progress "changelog will contain changes since $vsns[0]";
+       } else {
+           $changes_since_version = '_';
+           progress "package seems new, not specifying -v<version>";
+       }
+    }
+    if ($changes_since_version ne '_') {
+       unshift @opts, "-v$changes_since_version";
+    }
+    return @opts;
+}
+
 sub cmd_build {
     badusage "dgit build implies --clean=dpkg-source"
        if $cleanmode ne 'dpkg-source';
@@ -1758,7 +1778,14 @@ sub cmd_sbuild {
        }
     }
     runcmd_ordryrun_local @sbuild, @ARGV, qw(-d), $isuite, $dscfn;
-    runcmd_ordryrun_local @mergechanges, glob $pat;
+    my @changesfiles = glob $pat;
+    @changesfiles = sort {
+       ($b =~ m/_source\.changes$/ <=> $a =~ m/_source\.changes$/)
+           or $a cmp $b
+    } @changesfiles;
+    fail "wrong number of different changes files (@changesfiles)"
+       unless @changesfiles;
+    runcmd_ordryrun_local @mergechanges, @changesfiles;
     my $multichanges = "${package}_".(stripepoch $version)."_multi.changes";
     if (act_local()) {
        stat $multichanges or fail "$multichanges: $!";
@@ -1810,6 +1837,9 @@ sub parseopts () {
            } elsif (m/^--new$/) {
                push @ropts, $_;
                $new_package=1;
+           } elsif (m/^--since-version=([^_]+|_)$/) {
+               push @ropts, $_;
+               $changes_since_version = $1;
            } elsif (m/^--(\w+)=(.*)/s &&
                     ($om = $opts_opt_map{$1}) &&
                     length $om->[0]) {
@@ -1863,7 +1893,10 @@ sub parseopts () {
                } elsif (s/^-N/-/) {
                    push @ropts, $&;
                    $new_package=1;
-               } elsif (m/^-[vm]/) {
+               } elsif (s/^-v([^_]+|_)$//s) {
+                   push @ropts, $&;
+                   $changes_since_version = $1;
+               } elsif (m/^-m/) {
                    push @ropts, $&;
                    push @changesopts, $_;
                    $_ = '';