1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-07 06:01:48 +02:00

* Properly specify the hash algorithm in the manifests, and read it

too.
* Change the default hash for nix-prefetch-url back to md5, since
  that's what we use in Nixpkgs (for now; a birthday attack is rather
  unlikely there).
This commit is contained in:
Eelco Dolstra 2005-02-24 17:36:42 +00:00
parent 95e870a113
commit 3259ae5811
4 changed files with 31 additions and 13 deletions

View file

@ -52,6 +52,7 @@ sub readManifest {
my $narHash;
my $references;
my $deriver;
my $hashAlgo;
while (<MANIFEST>) {
chomp;
@ -75,6 +76,7 @@ sub readManifest {
undef $patchType;
$references = "";
$deriver = "";
$hashAlgo = "md5";
}
} else {
@ -104,7 +106,7 @@ sub readManifest {
push @{$narFileList},
{ url => $url, hash => $hash, size => $size
, narHash => $narHash, references => $references
, deriver => $deriver
, deriver => $deriver, hashAlgo => $hashAlgo
};
}
@ -119,12 +121,14 @@ sub readManifest {
{ url => $url, hash => $hash, size => $size
, basePath => $basePath, baseHash => $baseHash
, narHash => $narHash, patchType => $patchType
, hashAlgo => $hashAlgo
};
}
}
elsif (/^\s*StorePath:\s*(\/\S+)\s*$/) { $storePath = $1; }
elsif (/^\s*HashAlgo:\s*(\S+)\s*$/) { $hashAlgo = $1; }
elsif (/^\s*Hash:\s*(\S+)\s*$/) { $hash = $1; }
elsif (/^\s*URL:\s*(\S+)\s*$/) { $url = $1; }
elsif (/^\s*Size:\s*(\d+)\s*$/) { $size = $1; }
@ -162,7 +166,11 @@ sub writeManifest
print MANIFEST " StorePath: $storePath\n";
print MANIFEST " HashAlgo: $narFile->{hashAlgo}\n";
print MANIFEST " NarURL: $narFile->{url}\n";
print MANIFEST " MD5: $narFile->{hash}\n";
if ($narFile->{hashAlgo} eq "md5") {
print MANIFEST " MD5: $narFile->{hash}\n";
} else {
print MANIFEST " Hash: $narFile->{hash}\n";
}
print MANIFEST " NarHash: $narFile->{narHash}\n";
print MANIFEST " Size: $narFile->{size}\n";
print MANIFEST " References: $narFile->{references}\n"
@ -180,7 +188,11 @@ sub writeManifest
print MANIFEST " StorePath: $storePath\n";
print MANIFEST " HashAlgo: $patch->{hashAlgo}\n";
print MANIFEST " NarURL: $patch->{url}\n";
print MANIFEST " MD5: $patch->{hash}\n";
if ($patch->{hashAlgo} eq "md5") {
print MANIFEST " MD5: $patch->{hash}\n";
} else {
print MANIFEST " Hash: $patch->{hash}\n";
}
print MANIFEST " NarHash: $patch->{narHash}\n";
print MANIFEST " Size: $patch->{size}\n";
print MANIFEST " BasePath: $patch->{basePath}\n";