about summary refs log tree commit diff
path: root/scripts/download-using-manifests.pl.in
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-11-17T17·41+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-11-17T17·41+0000
commita4f0365b2dfc95b60c42a702937fc801dcc8d81b (patch)
tree16b758cc06f5429a124ef4fd1126fbc7c49290f6 /scripts/download-using-manifests.pl.in
parent3d38a498404bf842ca479d42d18def1f472a6fb0 (diff)
* When checking whether a patch is applicable, for efficiency, use
  `nix-store -q --hash' to get the hash of the base path rather than
  `nix-hash'.  However, only do this for estimating the size of a
  download, not for the actual substitution, because sometimes the
  contents of store paths are modified (which they shouldn't, of
  course).

Diffstat (limited to 'scripts/download-using-manifests.pl.in')
-rw-r--r--scripts/download-using-manifests.pl.in10
1 files changed, 7 insertions, 3 deletions
diff --git a/scripts/download-using-manifests.pl.in b/scripts/download-using-manifests.pl.in
index 7147090c4bb3..c31a294e8800 100644
--- a/scripts/download-using-manifests.pl.in
+++ b/scripts/download-using-manifests.pl.in
@@ -51,6 +51,7 @@ sub parseHash {
 # given path.
 sub computeSmallestDownload {
     my $targetPath = shift;
+    my $fast = shift;
     
     # Build a graph of all store paths that might contribute to the
     # construction of $targetPath, and the special node "start".  The
@@ -110,8 +111,11 @@ sub computeSmallestDownload {
                     my ($baseHashAlgo, $baseHash) = parseHash $patch->{baseHash};
                     my $format = "--base32";
                     $format = "" if $baseHashAlgo eq "md5";
-                    my $hash = `$binDir/nix-hash --type '$baseHashAlgo' $format "$patch->{basePath}"`;
+                    my $hash = $fast && $baseHashAlgo eq "sha256"
+                        ? `$binDir/nix-store -q --hash "$patch->{basePath}"`
+                        : `$binDir/nix-hash --type '$baseHashAlgo' $format "$patch->{basePath}"`;
                     chomp $hash;
+                    $hash =~ s/.*://;
                     next if $hash ne $baseHash;
                 }
                 push @queue, $patch->{basePath};
@@ -203,7 +207,7 @@ if ($ARGV[0] eq "--query") {
             print scalar @references, "\n";
             print "$_\n" foreach @references;
 
-            my @path = computeSmallestDownload $storePath;
+            my @path = computeSmallestDownload $storePath, 1;
             
             my $downloadSize = 0;
             while (scalar @path > 0) {
@@ -269,7 +273,7 @@ foreach my $localPath (@{$localPathList}) {
 
 
 # Compute the shortest path.
-my @path = computeSmallestDownload $targetPath;
+my @path = computeSmallestDownload $targetPath, 0;
 die "don't know how to produce $targetPath\n" if scalar @path == 0;