about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-12-20T16·38+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-12-20T16·38+0000
commit3d1b2101ccfd34f15b108f54a563a616cb679109 (patch)
treeadfdf74a5efc7d8b1eb4d4e939768d6c4895c286
parent7eed57e784068ae6e2e9bf4409639067df467cd3 (diff)
* Place manifests in /nix/var/nix/manifests.
* Use the new patch downloader.

-rw-r--r--configure.ac1
-rw-r--r--corepkgs/Makefile.am2
-rw-r--r--corepkgs/nix-pull/Makefile.am11
-rw-r--r--corepkgs/nix-pull/builder.sh.in34
-rw-r--r--corepkgs/nix-pull/default.nix7
-rw-r--r--scripts/Makefile.am8
-rw-r--r--[-rwxr-xr-x]scripts/download-using-manifests.pl.in (renamed from corepkgs/nix-pull/download.pl)4
-rw-r--r--[-rwxr-xr-x]scripts/nix-build.in0
-rw-r--r--[-rwxr-xr-x]scripts/nix-channel.in0
-rw-r--r--[-rwxr-xr-x]scripts/nix-collect-garbage.in0
-rw-r--r--scripts/nix-pull.in36
-rw-r--r--scripts/readmanifest.pm.in11
12 files changed, 35 insertions, 79 deletions
diff --git a/configure.ac b/configure.ac
index 2e247053ed19..d7574bbad1e0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -195,7 +195,6 @@ AC_CONFIG_FILES([Makefile
    corepkgs/nar/Makefile
    corepkgs/buildenv/Makefile
    corepkgs/channels/Makefile
-   corepkgs/nix-pull/Makefile
    doc/Makefile
    doc/manual/Makefile
    misc/Makefile
diff --git a/corepkgs/Makefile.am b/corepkgs/Makefile.am
index ca4cea2fc6d6..c9ea11cefca7 100644
--- a/corepkgs/Makefile.am
+++ b/corepkgs/Makefile.am
@@ -1 +1 @@
-SUBDIRS = fetchurl nar buildenv channels nix-pull
+SUBDIRS = fetchurl nar buildenv channels
diff --git a/corepkgs/nix-pull/Makefile.am b/corepkgs/nix-pull/Makefile.am
deleted file mode 100644
index 91adb4853f3b..000000000000
--- a/corepkgs/nix-pull/Makefile.am
+++ /dev/null
@@ -1,11 +0,0 @@
-all-local: builder.sh
-
-install-exec-local:
-	$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs
-	$(INSTALL) -d $(DESTDIR)$(datadir)/nix/corepkgs/nix-pull
-	$(INSTALL_DATA) default.nix $(DESTDIR)$(datadir)/nix/corepkgs/nix-pull
-	$(INSTALL_PROGRAM) builder.sh $(DESTDIR)$(datadir)/nix/corepkgs/nix-pull
-
-include ../../substitute.mk
-
-EXTRA_DIST = default.nix builder.sh.in
diff --git a/corepkgs/nix-pull/builder.sh.in b/corepkgs/nix-pull/builder.sh.in
deleted file mode 100644
index cc1a125d8f8f..000000000000
--- a/corepkgs/nix-pull/builder.sh.in
+++ /dev/null
@@ -1,34 +0,0 @@
-#! @shell@ -e
-
-export PATH=/bin:/usr/bin
-
-mkdir $out
-
-cat > $out/fetch <<EOF
-#! @shell@ -e
-
-export PATH=/bin:/usr/bin
-
-echo "downloading \$2..."
-
-export PRINT_PATH=1
-result=(\$(@bindir@/nix-prefetch-url \$2))
-
-hash=\${result[0]}
-path=\${result[1]}
-
-if test "\$hash" != "\$3"; then
-    echo "hash is \$hash, expected \$3"
-    exit 1
-fi
-
-echo "unpacking into \$1..."
-
-if ! @bunzip2@ < "\$path" | @bindir@/nix-store --restore "\$1"; then
-    exit 1
-fi
-
-exit 0
-EOF
-
-chmod +x $out/fetch
diff --git a/corepkgs/nix-pull/default.nix b/corepkgs/nix-pull/default.nix
deleted file mode 100644
index 700d7213141c..000000000000
--- a/corepkgs/nix-pull/default.nix
+++ /dev/null
@@ -1,7 +0,0 @@
-{system}:
-
-derivation {
-  name = "nix-pull";
-  builder = ./builder.sh;
-  inherit system;
-}
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 8a933fe95bbe..20e42e74c5d0 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -4,13 +4,14 @@ bin_SCRIPTS = nix-collect-garbage \
 
 noinst_SCRIPTS = nix-profile.sh
 
-nix-pull nix-push: readmanifest.pm
+nix-pull nix-push: readmanifest.pm download-using-manifests.pl
 
-install-exec-local: readmanifest.pm
+install-exec-local: readmanifest.pm download-using-manifests.pl
 	$(INSTALL) -d $(DESTDIR)$(sysconfdir)/profile.d
 	$(INSTALL_PROGRAM) nix-profile.sh $(DESTDIR)$(sysconfdir)/profile.d/nix.sh
 	$(INSTALL) -d $(DESTDIR)$(libexecdir)/nix
 	$(INSTALL_DATA) readmanifest.pm $(DESTDIR)$(libexecdir)/nix 
+	$(INSTALL_PROGRAM) download-using-manifests.pl $(DESTDIR)$(libexecdir)/nix 
 	$(INSTALL) -d $(DESTDIR)$(sysconfdir)/nix
 
 include ../substitute.mk
@@ -20,4 +21,5 @@ EXTRA_DIST = nix-collect-garbage.in \
   nix-prefetch-url.in nix-install-package.in \
   nix-channel.in \
   readmanifest.pm.in \
-  nix-build.in
+  nix-build.in \
+  download-using-manifests.pl.in
diff --git a/corepkgs/nix-pull/download.pl b/scripts/download-using-manifests.pl.in
index 5c7b33a996f5..058fa9965a33 100755..100644
--- a/corepkgs/nix-pull/download.pl
+++ b/scripts/download-using-manifests.pl.in
@@ -1,9 +1,9 @@
-#! /usr/bin/perl -w -I/home/eelco/Dev/nix/scripts
+#! @perl@ -w -I@libexecdir@/nix
 
 use strict;
 use readmanifest;
 
-my $manifestDir = "/home/eelco/Dev/nix/patch/test";
+my $manifestDir = "@localstatedir@/nix/manifests";
 
 
 # Check the arguments.
diff --git a/scripts/nix-build.in b/scripts/nix-build.in
index 43d818274b33..43d818274b33 100755..100644
--- a/scripts/nix-build.in
+++ b/scripts/nix-build.in
diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in
index 3c99f454c6f8..3c99f454c6f8 100755..100644
--- a/scripts/nix-channel.in
+++ b/scripts/nix-channel.in
diff --git a/scripts/nix-collect-garbage.in b/scripts/nix-collect-garbage.in
index 44bcc16bbca0..44bcc16bbca0 100755..100644
--- a/scripts/nix-collect-garbage.in
+++ b/scripts/nix-collect-garbage.in
diff --git a/scripts/nix-pull.in b/scripts/nix-pull.in
index d2c38d0ca12e..1a8e2a91127c 100644
--- a/scripts/nix-pull.in
+++ b/scripts/nix-pull.in
@@ -11,7 +11,7 @@ until mkdir $tmpdir, 0777;
 
 my $manifest = "$tmpdir/manifest";
 
-#END { unlink $manifest; rmdir $tmpdir; }
+END { unlink $manifest; rmdir $tmpdir; }
 
 
 # Obtain URLs either from the command line or from a configuration file.
@@ -28,8 +28,22 @@ sub processURL {
     system("@curl@ --fail --silent --show-error --location --max-redirs 20 " .
            "'$url' > '$manifest'") == 0
            or die "curl failed: $?";
-    
+
     readManifest $manifest, \%narFiles, \%patches, \%successors;
+
+    my $baseName = "unnamed";
+    if ($url =~ /\/([^\/]+)\/[^\/]+$/) { # get the forelast component
+        $baseName = $1;
+    }
+
+    my $hash = `@bindir@/nix-hash --flat '$manifest'`
+        or die "cannot hash `$manifest'";
+    chomp $hash;
+    
+    my $finalPath = "@localstatedir@/nix/manifests/$baseName-$hash.nixmanifest";
+    
+    system("mv '$manifest' '$finalPath'") == 0
+        or die "cannot move `$manifest' to `$finalPath";
 }
 
 while (@ARGV) {
@@ -42,18 +56,6 @@ my $size = scalar (keys %narFiles);
 print "$size store paths in manifest\n";
 
 
-# Instantiate a store expression that builds the substitute program
-# (the program that fetches URLs and unpacks them into the store).
-my $nixExpr =
-    "(import @datadir@/nix/corepkgs/nix-pull) " .
-    "{system = \"@system@\";}";
-
-print STDERR "building downloader...\n";
-my $substProgram = `echo '$nixExpr' | @bindir@/nix-store -qnf \$(@bindir@/nix-instantiate -)`
-    or die "cannot instantiate Nix expression";
-chomp $substProgram;
-
-
 # Register all substitutes.
 print STDERR "registering substitutes...\n";
 
@@ -66,10 +68,8 @@ foreach my $storePath (keys %narFiles) {
     my $narFileList = $narFiles{$storePath};
     foreach my $narFile (@{$narFileList}) {
         print WRITE "$storePath\n";
-        print WRITE "$substProgram/fetch\n";
-        print WRITE "2\n";
-        print WRITE "$narFile->{url}\n";
-        print WRITE "$narFile->{hash}\n";
+        print WRITE "@libexecdir@/nix/download-using-manifests.pl\n";
+        print WRITE "0\n";
     }
 }
 
diff --git a/scripts/readmanifest.pm.in b/scripts/readmanifest.pm.in
index 8d6694ff2e54..7f41bd55f267 100644
--- a/scripts/readmanifest.pm.in
+++ b/scripts/readmanifest.pm.in
@@ -19,6 +19,7 @@ sub readManifest {
     my $basePath;
     my $baseHash;
     my $patchType;
+    my $narHash;
 
     while (<MANIFEST>) {
         chomp;
@@ -34,6 +35,7 @@ sub readManifest {
                 undef $hash;
                 $size = 999999999;
                 @preds = ();
+                undef $narHash;
 	    }
             elsif (/^patch \{$/) {
                 $type = "patch";
@@ -44,6 +46,7 @@ sub readManifest {
                 undef $basePath;
                 undef $baseHash;
                 undef $patchType;
+                undef $narHash;
             }
             else { die "bad line: $_"; }
         } else {
@@ -71,7 +74,9 @@ sub readManifest {
                     }
                     if (!$found) {
                         push @{$narFileList},
-                            {url => $url, hash => $hash, size => $size};
+                            { url => $url, hash => $hash, size => $size
+                            , narHash => $narHash
+                            };
                     }
                 
                     foreach my $p (@preds) {
@@ -102,6 +107,7 @@ sub readManifest {
                         push @{$patchList},
                             { url => $url, hash => $hash, size => $size
                             , basePath => $basePath, baseHash => $baseHash
+                            , narHash => $narHash
                             };
                     }
                     
@@ -117,11 +123,12 @@ sub readManifest {
             elsif (/^\s*BasePath:\s*(\/\S+)\s*$/) { $basePath = $1; }
             elsif (/^\s*BaseHash:\s*(\S+)\s*$/) { $baseHash = $1; }
             elsif (/^\s*Type:\s*(\S+)\s*$/) { $patchType = $1; }
+            elsif (/^\s*NarHash:\s*(\S+)\s*$/) { $narHash = $1; }
 
             # Compatibility;
             elsif (/^\s*NarURL:\s*(\S+)\s*$/) { $url = $1; }
             elsif (/^\s*MD5:\s*(\S+)\s*$/) { $hash = $1; }
-            
+
             else { die "bad line: $_"; }
         }
     }