chiark / gitweb /
changelog: start 8.5~
[dgit.git] / dgit
diff --git a/dgit b/dgit
index b6bfd5605684ae5fbebb3343175ccc2bd5c2ac4f..a0d2e0a0f86034b6accf6fe81fb4f8556c65d9b3 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -32,6 +32,7 @@ use Data::Dumper;
 use LWP::UserAgent;
 use Dpkg::Control::Hash;
 use File::Path;
+use File::Spec;
 use File::Temp qw(tempdir);
 use File::Basename;
 use Dpkg::Version;
@@ -164,6 +165,7 @@ our %opts_cfg_insertpos = map {
 } keys %opts_opt_map;
 
 sub parseopts_late_defaults();
+sub quiltify_trees_differ ($$;$$$);
 sub setup_gitattrs(;$);
 sub check_gitattrs($$);
 
@@ -396,7 +398,9 @@ sub branch_is_gdr ($) {
            return 0;
        }
        if ($tip_patches eq '' and
-           !defined git_cat_file "$walk:debian") {
+           !defined git_cat_file "$walk~:debian" and
+           !quiltify_trees_differ "$walk~", $walk
+          ) {
            # (gdr classification of parent: BreakwaterStart
            printdebug "branch_is_gdr  $walk unmarked BreakwaterStart YES\n";
            return 1;
@@ -2233,7 +2237,7 @@ sub dotdot_bpd_transfer_origs ($$$) {
            "check orig file %s in ..: %s", $leaf, $!;
        if (-l _) {
            stat "$dotdot/$leaf" or fail f_
-               "check targe of orig symlink %s in ..: %s", $leaf, $!;
+               "check target of orig symlink %s in ..: %s", $leaf, $!;
            my $ltarget = readlink "$dotdot/$leaf" or
                die "readlink $dotdot/$leaf: $!";
            if ($ltarget !~ m{^/}) {
@@ -7003,29 +7007,49 @@ END
     my @dfi = dsc_files_info();
     foreach my $fi (@dfi) {
        my $f = $fi->{Filename};
+       # We transfer all the pieces of the dsc to the bpd, not just
+       # origs.  This is by analogy with dgit fetch, which wants to
+       # keep them somewhere to avoid downloading them again.
+       # We make symlinks, though.  If the user wants copies, then
+       # they can copy the parts of the dsc to the bpd using dcmd,
+       # or something.
        my $here = "$buildproductsdir/$f";
        if (lstat $here) {
-           next if stat $here;
+           if (stat $here) {
+               next;
+           }
            fail f_ "lstat %s works but stat gives %s !", $here, $!;
        }
        fail f_ "stat %s: %s", $here, $! unless $! == ENOENT;
+       printdebug "not in bpd, $f ...\n";
+       # $f does not exist in bpd, we need to transfer it
        my $there = $dscfn;
-       if ($dscfn =~ m#^(?:\./+)?\.\./+#) {
-           $there = $';
-       } elsif ($dscfn =~ m#^/#) {
-           $there = $dscfn;
+       $there =~ s{[^/]+$}{$f} or confess "$there ?";
+       # $there is file we want, relative to user's cwd, or abs
+       printdebug "not in bpd, $f, test $there ...\n";
+       stat $there or fail f_
+           "import %s requires %s, but: %s", $dscfn, $there, $!;
+       if ($there =~ m#^(?:\./+)?\.\./+#) {
+           # $there is relative to user's cwd
+           my $there_from_parent = $';
+           if ($buildproductsdir !~ m{^/}) {
+               # abs2rel, despite its name, can take two relative paths
+               $there = File::Spec->abs2rel($there,$buildproductsdir);
+               # now $there is relative to bpd, great
+               printdebug "not in bpd, $f, abs2rel, $there ...\n";
+           } else {
+               $there = (dirname $maindir)."/$there_from_parent";
+               # now $there is absoute
+               printdebug "not in bpd, $f, rel2rel, $there ...\n";
+           }
+       } elsif ($there =~ m#^/#) {
+           # $there is absolute already
+           printdebug "not in bpd, $f, abs, $there ...\n";
        } else {
            fail f_
                "cannot import %s which seems to be inside working tree!",
                $dscfn;
        }
-       $there =~ s#/+[^/]+$## or fail f_
-           "import %s requires .../%s, but it does not exist",
-           $dscfn, $f;
-       $there .= "/$f";
-       my $test = $there =~ m{^/} ? $there : "../$there";
-       stat $test or fail f_
-           "import %s requires %s, but: %s", $dscfn, $test, $!;
        symlink $there, $here or fail f_
            "symlink %s to %s: %s", $there, $here, $!;
        progress f_ "made symlink %s -> %s", $here, $there;