aboutsummaryrefslogtreecommitdiff
path: root/scripts/readmanifest.pm.in
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-12-05 11:25:38 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-12-05 11:25:38 +0000
commit06c5a7075d85636ba1fedce1fc5b131cdcffd5f8 (patch)
tree971cea7feac8925a55b32ac13663cb70433260ad /scripts/readmanifest.pm.in
parentcff6fd22ebfbfdbbda9b30c68cb61e25db718147 (diff)
* Refactoring: put the manifest-reading code in a separate file.
Diffstat (limited to 'scripts/readmanifest.pm.in')
-rw-r--r--scripts/readmanifest.pm.in72
1 files changed, 72 insertions, 0 deletions
diff --git a/scripts/readmanifest.pm.in b/scripts/readmanifest.pm.in
new file mode 100644
index 000000000..e8819d8b8
--- /dev/null
+++ b/scripts/readmanifest.pm.in
@@ -0,0 +1,72 @@
+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 "wget --cache=off '$url'/MANIFEST -O '$manifest' 2> /dev/null"; # !!! escape
+ if ($?) { die "`wget' failed"; }
+
+ open MANIFEST, "<$manifest";
+
+ my $inside = 0;
+
+ my $storepath;
+ my $narname;
+ my $hash;
+ my @preds;
+
+ while (<MANIFEST>) {
+ chomp;
+ s/\#.*$//g;
+ next if (/^$/);
+
+ if (!$inside) {
+ if (/^\{$/) {
+ $inside = 1;
+ undef $storepath;
+ undef $narname;
+ undef $hash;
+ @preds = ();
+ }
+ else { die "bad line: $_"; }
+ } else {
+ if (/^\}$/) {
+ $inside = 0;
+ my $fullurl = "$url/$narname";
+
+ $$storepaths2urls{$storepath} = $fullurl;
+ $$urls2hashes{$fullurl} = $hash;
+
+ foreach my $p (@preds) {
+ $$successors{$p} = $storepath;
+ }
+
+ }
+ elsif (/^\s*StorePath:\s*(\/\S+)\s*$/) {
+ $storepath = $1;
+ }
+ elsif (/^\s*NarName:\s*(\S+)\s*$/) {
+ $narname = $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;