chiark / gitweb /
dummyapicat: New archive query method
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 22 Oct 2016 23:05:07 +0000 (00:05 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 30 Oct 2016 16:35:58 +0000 (16:35 +0000)
Like ftpmasterapi but knows that actually behind the scenes it's just
mostly cat.  Ths is relevant because file_in_archive_dummycatapi has
to be different.

(This is because the test suite can't sensibly predict what queries
dgit might make, because the relevant bits of the test suite don't
actually really know what .origs might be supposed to exist.)

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

diff --git a/dgit b/dgit
index abe636df98ef30c0f9e0dbc872a2c0fa468ab376..1b32fa7c1cc632d9d7ae2d117e7a78756d47a4e1 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -1089,6 +1089,33 @@ sub file_in_archive_ftpmasterapi {
     my $info = api_query($data, "file_in_archive/$pat", 1);
 }
 
+#---------- `dummyapicat' archive query method ----------
+
+sub archive_query_dummycatapi { archive_query_ftpmasterapi @_; }
+sub canonicalise_suite_dummycatapi { canonicalise_suite_ftpmasterapi @_; }
+
+sub file_in_archive_dummycatapi ($$$) {
+    my ($proto,$data,$filename) = @_;
+    my $mirror = access_cfg('mirror');
+    $mirror =~ s#^file://#/# or die "$mirror ?";
+    my @out;
+    my @cmd = (qw(sh -ec), '
+            cd "$1"
+            find -name "$2" -print0 |
+            xargs -0r sha256sum
+        ', qw(x), $mirror, $filename);
+    debugcmd "-|", @cmd;
+    open FIA, "-|", @cmd or die $!;
+    while (<FIA>) {
+       chomp or die;
+       printdebug "| $_\n";
+       m/^(\w+)  (\S+)$/ or die "$_ ?";
+       push @out, { sha256sum => $1, filename => $2 };
+    }
+    close FIA or die failedcmd @cmd;
+    return \@out;
+}
+
 #---------- `madison' archive query method ----------
 
 sub archive_query_madison {