mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 09:06:15 +02:00
03f1d1ecb5
* Made the dependencies on bzip2 and the shell explicit.
72 lines
1.6 KiB
Perl
72 lines
1.6 KiB
Perl
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";
|
|
|
|
system("@curl@ --fail --silent --show-error --location --max-redirs 20 " .
|
|
"'$url' > '$manifest' 2> /dev/null") == 0
|
|
or die "curl failed: $?";
|
|
|
|
open MANIFEST, "<$manifest";
|
|
|
|
my $inside = 0;
|
|
|
|
my $storepath;
|
|
my $narurl;
|
|
my $hash;
|
|
my @preds;
|
|
|
|
while (<MANIFEST>) {
|
|
chomp;
|
|
s/\#.*$//g;
|
|
next if (/^$/);
|
|
|
|
if (!$inside) {
|
|
if (/^\{$/) {
|
|
$inside = 1;
|
|
undef $storepath;
|
|
undef $narurl;
|
|
undef $hash;
|
|
@preds = ();
|
|
}
|
|
else { die "bad line: $_"; }
|
|
} else {
|
|
if (/^\}$/) {
|
|
$inside = 0;
|
|
|
|
$$storepaths2urls{$storepath} = $narurl;
|
|
$$urls2hashes{$narurl} = $hash;
|
|
|
|
foreach my $p (@preds) {
|
|
$$successors{$p} = $storepath;
|
|
}
|
|
|
|
}
|
|
elsif (/^\s*StorePath:\s*(\/\S+)\s*$/) {
|
|
$storepath = $1;
|
|
}
|
|
elsif (/^\s*NarURL:\s*(\S+)\s*$/) {
|
|
$narurl = $1;
|
|
}
|
|
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;
|