* nix-pull: update the Nix manifest cache if necessary. Also, don't

read the manifest just to check the version and print the number of
  paths.  This makes nix-pull very fast for the cached cache (speeding
  up nixos-rebuild without the ‘--no-pull’ or ‘--fast’ options).
This commit is contained in:
Eelco Dolstra 2011-11-16 16:41:48 +00:00
parent d7d7910ba4
commit f8e609c341
2 changed files with 7 additions and 25 deletions

View File

@ -305,8 +305,8 @@ EOF
# unless we've already done so on a previous run. # unless we've already done so on a previous run.
my %seen; my %seen;
for my $manifest (glob "$manifestDir/*.nixmanifest") { for my $manifestLink (glob "$manifestDir/*.nixmanifest") {
$manifest = Cwd::abs_path($manifest); my $manifest = Cwd::abs_path($manifestLink);
my $timestamp = lstat($manifest)->mtime; my $timestamp = lstat($manifest)->mtime;
$seen{$manifest} = 1; $seen{$manifest} = 1;
@ -342,10 +342,10 @@ EOF
my $version = readManifest_($manifest, \&addNARToDB, \&addPatchToDB); my $version = readManifest_($manifest, \&addNARToDB, \&addPatchToDB);
if ($version < 3) { 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) { 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";
} }
} }

View File

@ -33,10 +33,6 @@ if (! -l $manifestDirLink) {
# Process the URLs specified on the command line. # Process the URLs specified on the command line.
my %narFiles;
my %patches;
my $skipWrongStore = 0;
sub downloadFile { sub downloadFile {
my $url = shift; my $url = shift;
@ -68,20 +64,6 @@ sub processURL {
$manifest = downloadFile $url; $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"; my $baseName = "unnamed";
if ($url =~ /\/([^\/]+)\/[^\/]+$/) { # get the forelast component if ($url =~ /\/([^\/]+)\/[^\/]+$/) { # get the forelast component
$baseName = $1; $baseName = $1;
@ -120,12 +102,12 @@ sub processURL {
while (@ARGV) { while (@ARGV) {
my $url = shift @ARGV; my $url = shift @ARGV;
if ($url eq "--skip-wrong-store") { if ($url eq "--skip-wrong-store") {
$skipWrongStore = 1; # No-op, no longer supported.
} else { } else {
processURL $url; processURL $url;
} }
} }
my $size = scalar (keys %narFiles); # Update the cache.
print "$size store paths in manifest\n"; updateManifestDB();