summaryrefslogtreecommitdiff
path: root/dgit
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2015-01-18 17:59:23 +0000
committerIan Jackson <ijackson@chiark.greenend.org.uk>2015-03-22 15:18:52 +0000
commit7efe0539417015b5b0da6549dd79b411536bbd7d (patch)
treed5c68ef52ee583df5cab6561c648b0b0a1652c35 /dgit
parent691b384b2a9c582f1fa872f2a23bc6ba0b0c3381 (diff)
dgit: Provide internal archive-api-query command
Diffstat (limited to 'dgit')
-rwxr-xr-xdgit31
1 files changed, 31 insertions, 0 deletions
diff --git a/dgit b/dgit
index 7cbef4e..02ed55d 100755
--- a/dgit
+++ b/dgit
@@ -528,6 +528,9 @@ our %defcfg = ('dgit.default.distro' => 'debian',
'dgit-distro.debian.git-user-force' => 'dgit',
'dgit-distro.debian.git-proto' => 'git+ssh://',
'dgit-distro.debian.git-path' => '/dgit/debian/repos',
+ 'dgit-distro.debian.archive-query-url', 'https://api.ftp-master.debian.org/',
+ 'dgit-distro.debian.archive-query-tls-key',
+ '/etc/ssl/certs/%HOST%.pem:/etc/dgit/%HOST%.pem',
'dgit-distro.debian.diverts.alioth' => '/alioth',
'dgit-distro.debian/alioth.git-host' => 'git.debian.org',
'dgit-distro.debian/alioth.git-user-force' => '',
@@ -775,6 +778,27 @@ sub must_getcwd () {
return $d;
}
+sub archive_api_query_cmd ($) {
+ my ($subpath) = @_;
+ my @cmd = qw(curl -sS);
+ my $url = access_cfg('archive-query-url');
+ if ($url =~ m#^https://([-.0-9a-z]+)/#) {
+ my $host = $1;
+ my $keys = access_cfg('archive-query-tls-key','RETURN-UNDEF');
+ foreach my $key (split /\:/, $keys) {
+ $key =~ s/\%HOST\%/$host/g;
+ if (!stat $key) {
+ fail "for $url: stat $key: $!" unless $!==ENOENT;
+ next;
+ }
+ push @cmd, "--ca-certificate=$key", "--ca-directory=/dev/enoent";
+ last;
+ }
+ }
+ push @cmd, $url.$subpath;
+ return @cmd;
+}
+
our %rmad;
sub archive_query ($) {
@@ -2604,6 +2628,13 @@ sub cmd_quilt_fixup {
build_maybe_quilt_fixup();
}
+sub cmd_archive_api_query {
+ badusage "need only 1 subpath argument" unless @ARGV==1;
+ my ($subpath) = @ARGV;
+ my @cmd = archive_api_query_cmd($subpath);
+ exec @cmd or fail "exec curl: $!\n";
+}
+
#---------- argument parsing and main program ----------
sub cmd_version {