chiark / gitweb /
Cope properly with `3.0 (quilt)' with single-debian-patch. Closes:#796016.
[dgit.git] / dgit
diff --git a/dgit b/dgit
index e5edd551cefd9ee2859165bb97afbd6283b8ce36..eaba82b4143d2babd6157f89c746184e55ee9a6d 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -2754,8 +2754,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);
     }
@@ -2765,6 +2764,57 @@ sub build_maybe_quilt_fixup () {
         @git, qw(pull --ff-only -q .git/dgit/unpack/work master);
 }
 
+sub quilt_fixup_mkwork ($) {
+    my ($headref) = @_;
+
+    mkdir "work" or die $!;
+    changedir "work";
+    mktree_in_ud_here();
+    runcmd @git, qw(reset --hard), $headref;
+}
+
+sub quilt_fixup_linkorigs ($$) {
+    my ($upstreamversion, $fn) = @_;
+    # calls $fn->($leafname);
+
+    foreach my $f (<../../../../*>) { #/){
+       my $b=$f; $b =~ s{.*/}{};
+       next unless is_orig_file $b, srcfn $upstreamversion,'';
+       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) = @_;
+
+    # 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) = @_;
 
@@ -2835,12 +2885,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)) {
@@ -2859,10 +2904,7 @@ END
     my $fakexdir= $package.'-'.(stripepoch $upstreamversion);
     rename $fakexdir, "fake" or die "$fakexdir $!";
 
-    mkdir "work" or die $!;
-    changedir "work";
-    mktree_in_ud_here();
-    runcmd @git, qw(reset --hard), $headref;
+    quilt_fixup_mkwork($headref);
 
     my $mustdeletepc=0;
     if (stat_exists ".pc") {
@@ -2884,8 +2926,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();
     }
 }