2003-12-05 13:25:38 +02:00
|
|
|
use strict;
|
|
|
|
|
|
|
|
sub processURL {
|
|
|
|
my $manifest = shift;
|
|
|
|
my $url = shift;
|
2004-06-21 12:51:23 +03:00
|
|
|
my $storePaths2urls = shift;
|
2003-12-05 13:25:38 +02:00
|
|
|
my $urls2hashes = shift;
|
|
|
|
my $successors = shift;
|
|
|
|
|
|
|
|
$url =~ s/\/$//;
|
|
|
|
print "obtaining list of Nix archives at $url...\n";
|
|
|
|
|
2004-04-06 11:18:51 +03:00
|
|
|
system("@curl@ --fail --silent --show-error --location --max-redirs 20 " .
|
2004-10-20 17:05:48 +03:00
|
|
|
"'$url' > '$manifest'") == 0
|
2004-01-16 16:54:39 +02:00
|
|
|
or die "curl failed: $?";
|
2003-12-05 13:25:38 +02:00
|
|
|
|
|
|
|
open MANIFEST, "<$manifest";
|
|
|
|
|
|
|
|
my $inside = 0;
|
|
|
|
|
2004-06-21 12:51:23 +03:00
|
|
|
my $storePath;
|
2004-01-16 16:54:39 +02:00
|
|
|
my $narurl;
|
2003-12-05 13:25:38 +02:00
|
|
|
my $hash;
|
|
|
|
my @preds;
|
|
|
|
|
|
|
|
while (<MANIFEST>) {
|
|
|
|
chomp;
|
|
|
|
s/\#.*$//g;
|
|
|
|
next if (/^$/);
|
|
|
|
|
|
|
|
if (!$inside) {
|
|
|
|
if (/^\{$/) {
|
|
|
|
$inside = 1;
|
2004-06-21 12:51:23 +03:00
|
|
|
undef $storePath;
|
2004-01-16 16:54:39 +02:00
|
|
|
undef $narurl;
|
2003-12-05 13:25:38 +02:00
|
|
|
undef $hash;
|
|
|
|
@preds = ();
|
|
|
|
}
|
|
|
|
else { die "bad line: $_"; }
|
|
|
|
} else {
|
|
|
|
if (/^\}$/) {
|
|
|
|
$inside = 0;
|
|
|
|
|
2004-06-21 12:51:23 +03:00
|
|
|
$$storePaths2urls{$storePath} = $narurl;
|
2004-01-16 16:54:39 +02:00
|
|
|
$$urls2hashes{$narurl} = $hash;
|
2003-12-05 13:25:38 +02:00
|
|
|
|
|
|
|
foreach my $p (@preds) {
|
2004-06-21 12:51:23 +03:00
|
|
|
$$successors{$p} = $storePath;
|
2003-12-05 13:25:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
elsif (/^\s*StorePath:\s*(\/\S+)\s*$/) {
|
2004-06-21 12:51:23 +03:00
|
|
|
$storePath = $1;
|
2003-12-05 13:25:38 +02:00
|
|
|
}
|
2004-01-16 16:54:39 +02:00
|
|
|
elsif (/^\s*NarURL:\s*(\S+)\s*$/) {
|
|
|
|
$narurl = $1;
|
2003-12-05 13:25:38 +02:00
|
|
|
}
|
|
|
|
elsif (/^\s*MD5:\s*(\S+)\s*$/) {
|
|
|
|
$hash = $1;
|
|
|
|
}
|
|
|
|
elsif (/^\s*SuccOf:\s*(\/\S+)\s*$/) {
|
|
|
|
push @preds, $1;
|
|
|
|
}
|
|
|
|
else { die "bad line: $_"; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
close MANIFEST;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 1;
|