nix-gh/scripts/readmanifest.pm.in
Eelco Dolstra 0d157eed99 * Don't barf on lines in nix-pull manifests that we don't recognise.
Necessary for compatibility with 0.7 patch deployment.
* Bumped version number to 0.6.1.
2004-12-21 13:05:25 +00:00

78 lines
1.7 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'") == 0
or die "curl failed: $?";
open MANIFEST, "<$manifest";
my $inside = 0;
my $type;
my $storePath;
my $narurl;
my $hash;
my @preds;
while (<MANIFEST>) {
chomp;
s/\#.*$//g;
next if (/^$/);
if (!$inside) {
if (/^\s*(\w*)\s*\{$/) {
$inside = 1;
$type = $1;
$type = "narfile" if $type eq "";
undef $storePath;
undef $narurl;
undef $hash;
@preds = ();
}
} else {
if (/^\}$/) {
$inside = 0;
if ($type eq "narfile") {
$$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;
}
}
}
close MANIFEST;
}
return 1;