chiark / gitweb /
dgit: dsc download handling: save as ,fetch if need be
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 10 Jan 2017 14:22:55 +0000 (14:22 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 10 Jan 2017 14:57:31 +0000 (14:57 +0000)
* Pass \$refetched to complete_file_from_dsc, so that we refetch files
  whose hashes are wrong.

* When saving files we refetched, save them as F,fetch if saving them
  as F gives EEXIST.  So we can save refetched files.

* When looking for files to reuse, look for F,fetch first.

We do this only here in generate_commits_from_dsc, not in
ensure_we_have_orig.  This is because, in practice, this all won't be
very effective for origs which need to be referred to by various
.dscs.

The main use case is when the user did a build without changing the
version number.  This would otherwise break fetch: Closes:#850824.

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

index 52e54ce8611e3c83c39f23ea442d590bd6a8d13c..607b2cd546abd7e39e85cae6d18703b2621b3a07 100644 (file)
@@ -5,6 +5,9 @@ dgit (3.1~) unstable; urgency=medium
   * dgit: Do not nedlessly re-fetch the rewrite map.
   * dgit: After downloading .debian.* files, save them in `..', too
     (ie do this not just for .origs).
+  * dgit: When fetching, refetch files with hash mismatches (and save them
+    as `...,fetch'), so we can distinguish them from any built locally.
+    Closes:#850824.
 
   Test suite:
   * Add test for import-dsc with default distro.  (Detects #850781.)
diff --git a/dgit b/dgit
index 0cd122ef23aaabec7537c3c4389a51947c89dbab..a51c8782b928196dff51e8d1ac35f0eefc86d941 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -2072,21 +2072,43 @@ sub generate_commits_from_dsc () {
        die "$f ?" if $f =~ m#/|^\.|\.dsc$|\.tmp$#;
        my $upper_f = "../../../../$f";
 
-       printdebug "considering linking $f: ";
-
-       link_ltarget $upper_f, $f
-           or ((printdebug "($!) "), 0)
-           or $!==&ENOENT
-           or die "$f $!";
-
-       printdebug "linked.\n";
+       printdebug "considering reusing $f: ";
+
+       if (link_ltarget "$upper_f,fetch", $f) {
+           printdebug "linked (using ...,fetch).\n";
+       } elsif ((printdebug "($!) "),
+                $! != ENOENT) {
+           fail "accessing ../$f,fetch: $!";
+       } elsif (link_ltarget $upper_f, $f) {
+           printdebug "linked.\n";
+       } elsif ((printdebug "($!) "),
+                $! != ENOENT) {
+           fail "accessing ../$f: $!";
+       } else {
+           printdebug "absent.\n";
+       }
 
-       complete_file_from_dsc('.', $fi)
+       my $refetched;
+       complete_file_from_dsc('.', $fi, \$refetched)
            or next;
 
-       link $f, $upper_f
-           or $!==&EEXIST
-           or die "$f $!";
+       printdebug "considering saving $f: ";
+
+       if (link $f, $upper_f) {
+           printdebug "linked.\n";
+       } elsif ((printdebug "($!) "),
+                $! != EEXIST) {
+           fail "saving ../$f: $!";
+       } elsif (!$refetched) {
+           printdebug "no need.\n";
+       } elsif (link $f, "$upper_f,fetch") {
+           printdebug "linked (using ...,fetch).\n";
+       } elsif ((printdebug "($!) "),
+                $! != EEXIST) {
+           fail "saving ../$f,fetch: $!";
+       } else {
+           printdebug "cannot.\n";
+       }
     }
 
     # We unpack and record the orig tarballs first, so that we only