chiark / gitweb /
dgit: New quilt mode "baredebian+tarball"
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 29 Jun 2019 16:08:25 +0000 (17:08 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 30 Jun 2019 20:11:17 +0000 (21:11 +0100)
No documentation yet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
dgit

diff --git a/dgit b/dgit
index c5ff37b53406b91740f39115357a956a0eef4b7e..f0a9ead7e5a1c08db52ad693bbfe2c3aafddc2cd 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -82,7 +82,7 @@ our $quilt_mode;
 our $quilt_upstream_commitish;
 our $quilt_upstream_commitish_used;
 our $quilt_upstream_commitish_message;
-our $quilt_options_re = 'gbp|dpm|baredebian';
+our $quilt_options_re = 'gbp|dpm|baredebian(?:\+tarball)?';
 our $quilt_modes_re = "linear|smash|auto|nofix|nocheck|unapplied|$quilt_options_re";
 our $splitview_mode;
 our $splitview_modes_re = qr{auto|always|never};
@@ -6067,6 +6067,30 @@ sub quilt_check_splitbrain_cache ($$) {
     return (undef, $splitbrain_cachekey);
 }
 
+sub baredebian_origtarballs_scan ($$$) {
+    my ($fakedfi, $upstreamversion, $dir) = @_;
+    if (!opendir OD, $dir) {
+       return if $! == ENOENT;
+       fail "opendir $dir (origs): $!";
+    }
+
+    while ($!=0, defined(my $leaf = readdir OD)) {
+       {
+           local ($debuglevel) = $debuglevel-1;
+           printdebug "BDOS $dir $leaf ?\n";
+       }
+       next unless is_orig_file_of_vsn $leaf, $upstreamversion;
+       next if grep { $_->{Filename} eq $leaf } @$fakedfi;
+       push @$fakedfi, {
+            Filename => $leaf,
+            Path => "$dir/$leaf",
+                       };
+    }
+
+    die "$dir; $!" if $!;
+    closedir OD;
+}
+
 sub quilt_fixup_multipatch ($$$) {
     my ($clogp, $headref, $upstreamversion, $splitbrain_cachekey) = @_;
 
@@ -6220,7 +6244,74 @@ END
     my $uheadref = $headref;
     my $uhead_whatshort = 'HEAD';
 
-    if ($quilt_mode =~ m/baredebian/) {
+    if ($quilt_mode =~ m/baredebian\+tarball/) {
+       # We need to make a tarball import.  Yuk.
+       # We want to do this here so that we have a $uheadref value
+
+       my @fakedfi;
+       baredebian_origtarballs_scan \@fakedfi, $upstreamversion, bpd_abs();
+       baredebian_origtarballs_scan \@fakedfi, $upstreamversion,
+           "$maindir/.." unless $buildproductsdir eq '..';
+       changedir '..';
+
+       my @tartrees = import_tarball_tartrees $upstreamversion, \@fakedfi;
+
+       fail __ "baredebian quilt fixup: could not find any origs"
+           unless @tartrees;
+
+       changedir 'work';
+       my ($authline, $r1authline, $clogp,) =
+           import_tarball_commits \@tartrees, $upstreamversion;
+
+       if (@tartrees == 1) {
+           $uheadref = $tartrees[0]{Commit};
+           # TRANSLATORS: this translation must fit in the ASCII art
+           # quilt differences display.  The untranslated display
+           # says %9.9s, so with that display it must be at most 9
+           # characters.
+           $uhead_whatshort = __ 'tarball';
+       } else {
+           # on .dsc import we do not make a separate commit, but
+           # here we need to do so
+           rm_subdir_cached '.';
+           my $parents;
+           foreach my $ti (@tartrees) {
+               my $c = $ti->{Commit};
+               if ($ti->{OrigPart} eq 'orig') {
+                   runcmd qw(git read-tree), $c;
+               } elsif ($ti->{OrigPart} =~ m/orig-/) {
+                   read_tree_subdir $', $c;
+               } else {
+                   confess "$ti->OrigPart} ?"
+               }
+               $parents .= "parent $c\n";
+           }
+           my $tree = git_write_tree();
+           my $mbody = f_ 'Combine orig tarballs for %s %s',
+               $package, $upstreamversion;
+           $uheadref = hash_commit_text <<END;
+tree $tree
+${parents}author $r1authline
+committer $r1authline
+
+$mbody
+
+[dgit import tarballs combine $package $upstreamversion]
+END
+           # TRANSLATORS: this translation must fit in the ASCII art
+           # quilt differences display.  The untranslated display
+           # says %9.9s, so with that display it must be at most 9
+           # characters.  This fragmentt is referring to multiple
+           # orig tarballs in a source package.
+           $uhead_whatshort = __ 'tarballs';
+
+           runcmd @git, qw(reset -q);
+       }
+       $quilt_upstream_commitish = $uheadref;
+       $quilt_upstream_commitish_used = '*orig*';
+       $quilt_upstream_commitish_message = '';
+    }
+    if ($quilt_mode =~ m/baredebian$/) {
        $uheadref = $quilt_upstream_commitish;
        # TRANSLATORS: this translation must fit in the ASCII art
        # quilt differences display.  The untranslated display
@@ -6255,9 +6346,10 @@ END
     # TRANSLATORS: Try to keep this ascii-art layout right.  The 0s in
     # %9.00009s will be ignored and are there to make the format the
     # same length (9 characters) as the output it generates.  If you
-    # change the value 9, your translation of "upstream" must fit into
-    # the new length, and you should change the number of 0s.  Do
-    # not reduce it below 4 as HEAD has to fit too.
+    # change the value 9, your translations of "upstream" and
+    # 'tarball' must fit into the new length, and you should change
+    # the number of 0s.  Do not reduce it below 4 as HEAD has to fit
+    # too.
     progress f_
 "%s: quilt differences: src:  %s orig %s     gitignores:  %s orig %s\n".
 "%s: quilt differences: %9.00009s %s o+d/p          %9.00009s %s o+d/p",