about summary refs log tree commit diff
path: root/scripts/nix-pull.in
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-12-13T13·47+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-12-13T13·47+0000
commit862f4c154e883611ba9dfefe921c87e6423075ea (patch)
tree63d8c96c29c18f322f0d70cf5c1a5224e306d835 /scripts/nix-pull.in
parentdca48aed349375b8515a32ac58dce48f48f7264e (diff)
* Patch deployment. `download.pl' (intended to be used in the
  substitute mechanism) creates a store path by downloading full NAR
  archives and/or patches specified in the available manifests.

  Any combination of present paths, full downloads, and patches can be
  used to construct the target path.  In particular, patches can be
  chained in sequence; and full NAR archives of the target path can be
  omitted (i.e., patch-only deployment is possible).  A shortest path
  algorithm is used to find the smallest set of files to be downloaded
  (the edge weights are currently file sizes, but one can imagine
  taking the network speed to the various source into account).

  Patches are binary deltas between two store paths.  To be precise,
  they are the output of the `bsdiff' program applied to the NAR
  archives obtained by dumping (`nix-store --dump') the two store
  paths.  The advantage of diff'ing NAR archives (and not, say, doing
  file-by-file diffs) is that file renames/moves are handled
  automatically.  The disadvantage is that we cannot optimise creation
  of unchanged files (by hard-linking).

Diffstat (limited to 'scripts/nix-pull.in')
-rw-r--r--scripts/nix-pull.in18
1 files changed, 14 insertions, 4 deletions
diff --git a/scripts/nix-pull.in b/scripts/nix-pull.in
index a802760a5293..66d99ff7c9b5 100644
--- a/scripts/nix-pull.in
+++ b/scripts/nix-pull.in
@@ -19,14 +19,24 @@ my $confFile = "@sysconfdir@/nix/prebuilts.conf";
 my %storePaths2urls;
 my %urls2hashes;
 my %successors;
-sub doURL {
+
+sub processURL {
     my $url = shift;
-    processURL $manifest, $url, \%storePaths2urls, \%urls2hashes, \%successors;
+
+    $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: $?";
+    
+    readManifest $manifest, \%storePaths2urls, \%urls2hashes, \%successors;
 }
+
 if (scalar @ARGV > 0) {
     while (@ARGV) {
         my $url = shift @ARGV;
-	doURL $url;
+	processURL $url;
     }
 } else {
     open CONFFILE, "<$confFile";
@@ -34,7 +44,7 @@ if (scalar @ARGV > 0) {
         chomp;
         if (/^\s*(\S+)\s*(\#.*)?$/) {
             my $url = $1;
-	    doURL $url;
+	    processURL $url;
         }
     }
     close CONFFILE;