From f8e609c3413e38d403d986020079f24a2b82c063 Mon Sep 17 00:00:00 2001
From: Eelco Dolstra <e.dolstra@tudelft.nl>
Date: Wed, 16 Nov 2011 16:41:48 +0000
Subject: [PATCH] =?UTF-8?q?*=20nix-pull:=20update=20the=20Nix=20manifest?=
 =?UTF-8?q?=20cache=20if=20necessary.=20=20Also,=20don't=20=20=20read=20th?=
 =?UTF-8?q?e=20manifest=20just=20to=20check=20the=20version=20and=20print?=
 =?UTF-8?q?=20the=20number=20of=20=20=20paths.=20=20This=20makes=20nix-pul?=
 =?UTF-8?q?l=20very=20fast=20for=20the=20cached=20cache=20(speeding=20=20?=
 =?UTF-8?q?=20up=20nixos-rebuild=20without=20the=20=E2=80=98--no-pull?=
 =?UTF-8?q?=E2=80=99=20or=20=E2=80=98--fast=E2=80=99=20options).?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 perl/lib/Nix/Manifest.pm |  8 ++++----
 scripts/nix-pull.in      | 24 +++---------------------
 2 files changed, 7 insertions(+), 25 deletions(-)

diff --git a/perl/lib/Nix/Manifest.pm b/perl/lib/Nix/Manifest.pm
index 9c891abb8..d1717a0a8 100644
--- a/perl/lib/Nix/Manifest.pm
+++ b/perl/lib/Nix/Manifest.pm
@@ -305,8 +305,8 @@ EOF
     # unless we've already done so on a previous run.
     my %seen;
     
-    for my $manifest (glob "$manifestDir/*.nixmanifest") {
-        $manifest = Cwd::abs_path($manifest);
+    for my $manifestLink (glob "$manifestDir/*.nixmanifest") {
+        my $manifest = Cwd::abs_path($manifestLink);
         my $timestamp = lstat($manifest)->mtime;
         $seen{$manifest} = 1;
 
@@ -342,10 +342,10 @@ EOF
         my $version = readManifest_($manifest, \&addNARToDB, \&addPatchToDB);
         
         if ($version < 3) {
-            die "you have an old-style manifest `$manifest'; please delete it";
+            die "you have an old-style or corrupt manifest `$manifestLink'; please delete it";
         }
         if ($version >= 10) {
-            die "manifest `$manifest' is too new; please delete it or upgrade Nix";
+            die "manifest `$manifestLink' is too new; please delete it or upgrade Nix";
         }
     }
 
diff --git a/scripts/nix-pull.in b/scripts/nix-pull.in
index d8352b277..74545a350 100755
--- a/scripts/nix-pull.in
+++ b/scripts/nix-pull.in
@@ -33,10 +33,6 @@ if (! -l $manifestDirLink) {
 
 
 # Process the URLs specified on the command line.
-my %narFiles;
-my %patches;
-
-my $skipWrongStore = 0;
 
 sub downloadFile {
     my $url = shift;
@@ -68,20 +64,6 @@ sub processURL {
         $manifest = downloadFile $url;
     }
 
-    my $version = readManifest($manifest, \%narFiles, \%patches);
-    
-    die "`$url' is not a manifest or it is too old (i.e., for Nix <= 0.7)\n" if $version < 3;
-    die "manifest `$url' is too new\n" if $version >= 5;
-
-    if ($skipWrongStore) {
-        foreach my $path (keys %narFiles) {
-            if (substr($path, 0, length($storeDir) + 1) ne "$storeDir/") {
-                print STDERR "warning: manifest `$url' assumes a Nix store at a different location than $storeDir, skipping...\n";
-                exit 0;
-            }
-        }
-    }
-
     my $baseName = "unnamed";
     if ($url =~ /\/([^\/]+)\/[^\/]+$/) { # get the forelast component
         $baseName = $1;
@@ -120,12 +102,12 @@ sub processURL {
 while (@ARGV) {
     my $url = shift @ARGV;
     if ($url eq "--skip-wrong-store") {
-        $skipWrongStore = 1;
+        # No-op, no longer supported.
     } else {
         processURL $url;
     }
 }
 
 
-my $size = scalar (keys %narFiles);
-print "$size store paths in manifest\n";
+# Update the cache.
+updateManifestDB();
-- 
GitLab