mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-30 01:26:15 +02:00
* 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).
This commit is contained in:
parent
3d38a49840
commit
a4f0365b2d
1 changed files with 7 additions and 3 deletions
|
@ -51,6 +51,7 @@ sub parseHash {
|
||||||
# given path.
|
# given path.
|
||||||
sub computeSmallestDownload {
|
sub computeSmallestDownload {
|
||||||
my $targetPath = shift;
|
my $targetPath = shift;
|
||||||
|
my $fast = shift;
|
||||||
|
|
||||||
# Build a graph of all store paths that might contribute to the
|
# Build a graph of all store paths that might contribute to the
|
||||||
# construction of $targetPath, and the special node "start". The
|
# construction of $targetPath, and the special node "start". The
|
||||||
|
@ -110,8 +111,11 @@ sub computeSmallestDownload {
|
||||||
my ($baseHashAlgo, $baseHash) = parseHash $patch->{baseHash};
|
my ($baseHashAlgo, $baseHash) = parseHash $patch->{baseHash};
|
||||||
my $format = "--base32";
|
my $format = "--base32";
|
||||||
$format = "" if $baseHashAlgo eq "md5";
|
$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;
|
chomp $hash;
|
||||||
|
$hash =~ s/.*://;
|
||||||
next if $hash ne $baseHash;
|
next if $hash ne $baseHash;
|
||||||
}
|
}
|
||||||
push @queue, $patch->{basePath};
|
push @queue, $patch->{basePath};
|
||||||
|
@ -203,7 +207,7 @@ if ($ARGV[0] eq "--query") {
|
||||||
print scalar @references, "\n";
|
print scalar @references, "\n";
|
||||||
print "$_\n" foreach @references;
|
print "$_\n" foreach @references;
|
||||||
|
|
||||||
my @path = computeSmallestDownload $storePath;
|
my @path = computeSmallestDownload $storePath, 1;
|
||||||
|
|
||||||
my $downloadSize = 0;
|
my $downloadSize = 0;
|
||||||
while (scalar @path > 0) {
|
while (scalar @path > 0) {
|
||||||
|
@ -269,7 +273,7 @@ foreach my $localPath (@{$localPathList}) {
|
||||||
|
|
||||||
|
|
||||||
# Compute the shortest path.
|
# 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;
|
die "don't know how to produce $targetPath\n" if scalar @path == 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue