2003-12-05 13:25:38 +02:00
|
|
|
use strict;
|
|
|
|
|
|
|
|
sub processURL {
|
|
|
|
my $manifest = shift;
|
|
|
|
my $url = shift;
|
|
|
|
my $storepaths2urls = shift;
|
|
|
|
my $urls2hashes = shift;
|
|
|
|
my $successors = shift;
|
|
|
|
|
|
|
|
$url =~ s/\/$//;
|
|
|
|
print "obtaining list of Nix archives at $url...\n";
|
|
|
|
|
2004-01-16 16:54:39 +02:00
|
|
|
system("curl --fail --silent --show-error " .
|
2004-02-10 18:14:47 +02:00
|
|
|
"'$url' > '$manifest' 2> /dev/null") == 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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
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-01-16 16:54:39 +02:00
|
|
|
$$storepaths2urls{$storepath} = $narurl;
|
|
|
|
$$urls2hashes{$narurl} = $hash;
|
2003-12-05 13:25:38 +02:00
|
|
|
|
|
|
|
foreach my $p (@preds) {
|
|
|
|
$$successors{$p} = $storepath;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
elsif (/^\s*StorePath:\s*(\/\S+)\s*$/) {
|
|
|
|
$storepath = $1;
|
|
|
|
}
|
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;
|