chiark / gitweb /
With dgit sbuild, pass our -d before the user's arguments, so that the user can overr...
[dgit.git] / dgit
diff --git a/dgit b/dgit
index 4675944fc3c30a4400c0ea741f8f8b79fa9c9919..7b447dedaf3db59f1778918c9f6204e81db5266e 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -1762,8 +1762,10 @@ sub check_not_dirty () {
        failedcmd @cmd;
     }
 
-    if (stat_exists "debian/source/local-options") {
-       fail "git tree contains debian/source/local-options";
+    foreach my $f (qw(local-options local-patch-header)) {
+       if (stat_exists "debian/source/$f") {
+           fail "git tree contains debian/source/$f";
+       }
     }
 }
 
@@ -2754,8 +2756,7 @@ sub build_maybe_quilt_fixup () {
     $upstreamversion =~ s/-[^-]*$//;
 
     if ($fopts->{'single-debian-patch'}) {
-       #quilt_fixup_singlepatch($clogp, $headref, $upstreamversion);
-       die;
+       quilt_fixup_singlepatch($clogp, $headref, $upstreamversion);
     } else {
        quilt_fixup_multipatch($clogp, $headref, $upstreamversion);
     }
@@ -2774,9 +2775,60 @@ sub quilt_fixup_mkwork ($) {
     runcmd @git, qw(reset --hard), $headref;
 }
 
+sub quilt_fixup_linkorigs ($$) {
+    my ($upstreamversion, $fn) = @_;
+    # calls $fn->($leafname);
+
+    foreach my $f (<../../../../*>) { #/){
+       my $b=$f; $b =~ s{.*/}{};
+       {
+           local ($debuglevel) = $debuglevel-1;
+           printdebug "QF linkorigs $b, $f ?\n";
+       }
+       next unless is_orig_file $b, srcfn $upstreamversion,'';
+       printdebug "QF linkorigs $b, $f Y\n";
+       link_ltarget $f, $b or die "$b $!";
+        $fn->($b);
+    }
+}
+
+sub quilt_fixup_delete_pc () {
+    runcmd @git, qw(rm -rqf .pc);
+    commit_admin "Commit removal of .pc (quilt series tracking data)";
+}
+
+sub quilt_fixup_singlepatch ($$$) {
+    my ($clogp, $headref, $upstreamversion) = @_;
+
+    progress "starting quiltify (single-debian-patch)";
+
+    # dpkg-source --commit generates new patches even if
+    # single-debian-patch is in debian/source/options.  In order to
+    # get it to generate debian/patches/debian-changes, it is
+    # necessary to build the source package.
+
+    quilt_fixup_linkorigs($upstreamversion, sub { });
+    quilt_fixup_mkwork($headref);
+
+    rmtree("debian/patches");
+
+    runcmd @dpkgsource, qw(-b .);
+    chdir "..";
+    runcmd @dpkgsource, qw(-x), (srcfn $version, ".dsc");
+    rename srcfn("$upstreamversion", "/debian/patches"), 
+           "work/debian/patches";
+
+    chdir "work";
+    commit_quilty_patch();
+
+    
+}
+
 sub quilt_fixup_multipatch ($$$) {
     my ($clogp, $headref, $upstreamversion) = @_;
 
+    progress "starting quiltify (multiple patches, $quilt_mode mode)";
+
     # Our objective is:
     #  - honour any existing .pc in case it has any strangeness
     #  - determine the git commit corresponding to the tip of
@@ -2844,12 +2896,7 @@ END
        print $fakedsc " ".$md->hexdigest." $size $b\n" or die $!;
     };
 
-    foreach my $f (<../../../../*>) { #/){
-       my $b=$f; $b =~ s{.*/}{};
-       next unless is_orig_file $b, srcfn $upstreamversion,'';
-       link_ltarget $f, $b or die "$b $!";
-        $dscaddfile->($b);
-    }
+    quilt_fixup_linkorigs($upstreamversion, $dscaddfile);
 
     my @files=qw(debian/source/format debian/rules);
     foreach my $maybe (qw(debian/patches debian/source/options)) {
@@ -2890,8 +2937,7 @@ END
     commit_quilty_patch();
 
     if ($mustdeletepc) {
-        runcmd @git, qw(rm -rqf .pc);
-        commit_admin "Commit removal of .pc (quilt series tracking data)";
+        quilt_fixup_delete_pc();
     }
 }
 
@@ -3093,7 +3139,7 @@ sub cmd_sbuild {
            unlink $cf or fail "remove $cf: $!";
        }
     }
-    runcmd_ordryrun_local @sbuild, @ARGV, qw(-d), $isuite, $dscfn;
+    runcmd_ordryrun_local @sbuild, qw(-d), $isuite, @ARGV, $dscfn;
     my @changesfiles = glob $pat;
     @changesfiles = sort {
        ($b =~ m/_source\.changes$/ <=> $a =~ m/_source\.changes$/)