forked from lix-project/lix
* Set NAR name to content hash; previous nix-push names were not
unique. * Drop `hashAlgo' attribute in manifests; prefix hashes with the hash algorithm instead.
This commit is contained in:
parent
1562dfe9ba
commit
8eff18cd43
|
@ -5,7 +5,7 @@ export PATH=/bin:/usr/bin
|
|||
|
||||
echo "packing $path into $out..."
|
||||
mkdir $out
|
||||
dst=$out/$(basename $path).nar.bz2
|
||||
dst=$out/tmp.nar.bz2
|
||||
@bindir@/nix-store --dump "$path" > tmp
|
||||
|
||||
@bzip2@ < tmp > $dst
|
||||
|
@ -13,3 +13,5 @@ dst=$out/$(basename $path).nar.bz2
|
|||
@bindir@/nix-hash -vvvvv --flat --type sha1 --base32 tmp > $out/nar-hash
|
||||
|
||||
@bindir@/nix-hash --flat --type sha1 --base32 $dst > $out/narbz2-hash
|
||||
|
||||
mv $out/tmp.nar.bz2 $out/$(cat $out/narbz2-hash).nar.bz2
|
||||
|
|
|
@ -148,12 +148,6 @@ for (my $n = 0; $n < scalar @storePaths; $n++) {
|
|||
my $basename = $1;
|
||||
defined $basename or die;
|
||||
|
||||
my $narname = "$basename.nar.bz2";
|
||||
|
||||
my $narFile = "$narDir/$narname";
|
||||
(-f $narFile) or die "narfile for $storePath not found";
|
||||
push @narArchives, $narFile;
|
||||
|
||||
open SHA1, "$narDir/narbz2-hash" or die "cannot open narbz2-hash";
|
||||
my $narbz2Hash = <SHA1>;
|
||||
chomp $narbz2Hash;
|
||||
|
@ -166,6 +160,12 @@ for (my $n = 0; $n < scalar @storePaths; $n++) {
|
|||
$narHash =~ /^[0-9a-z]{32}$/ or die "invalid hash";
|
||||
close SHA1;
|
||||
|
||||
my $narName = "$narbz2Hash.nar.bz2";
|
||||
|
||||
my $narFile = "$narDir/$narName";
|
||||
(-f $narFile) or die "narfile for $storePath not found";
|
||||
push @narArchives, $narFile;
|
||||
|
||||
my $narbz2Size = (stat $narFile)[7];
|
||||
|
||||
my $references = `$binDir/nix-store --query --references '$storePath'`;
|
||||
|
@ -179,16 +179,15 @@ for (my $n = 0; $n < scalar @storePaths; $n++) {
|
|||
|
||||
my $url;
|
||||
if ($localCopy) {
|
||||
$url = "file://$localArchivesDir/$narname";
|
||||
$url = "file://$localArchivesDir/$narName";
|
||||
} else {
|
||||
$url = "$archivesGetURL/$narname";
|
||||
$url = "$archivesGetURL/$narName";
|
||||
}
|
||||
$narFiles{$storePath} = [
|
||||
{ url => $url
|
||||
, hash => $narbz2Hash
|
||||
, hash => "sha1:$narbz2Hash"
|
||||
, size => $narbz2Size
|
||||
, narHash => $narHash
|
||||
, hashAlgo => "sha1"
|
||||
, narHash => "sha1:$narHash"
|
||||
, references => $references
|
||||
, deriver => $deriver
|
||||
}
|
||||
|
|
|
@ -130,7 +130,6 @@ sub readManifest {
|
|||
}
|
||||
|
||||
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; }
|
||||
|
@ -145,7 +144,7 @@ sub readManifest {
|
|||
|
||||
# Compatibility;
|
||||
elsif (/^\s*NarURL:\s*(\S+)\s*$/) { $url = $1; }
|
||||
elsif (/^\s*MD5:\s*(\S+)\s*$/) { $hash = $1; }
|
||||
elsif (/^\s*MD5:\s*(\S+)\s*$/) { $hash = "md5:$1"; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -173,13 +172,8 @@ sub writeManifest
|
|||
foreach my $narFile (@{$narFileList}) {
|
||||
print MANIFEST "{\n";
|
||||
print MANIFEST " StorePath: $storePath\n";
|
||||
print MANIFEST " HashAlgo: $narFile->{hashAlgo}\n";
|
||||
print MANIFEST " NarURL: $narFile->{url}\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"
|
||||
|
@ -195,13 +189,8 @@ sub writeManifest
|
|||
foreach my $patch (@{$patchList}) {
|
||||
print MANIFEST "patch {\n";
|
||||
print MANIFEST " StorePath: $storePath\n";
|
||||
print MANIFEST " HashAlgo: $patch->{hashAlgo}\n";
|
||||
print MANIFEST " NarURL: $patch->{url}\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";
|
||||
|
|
Loading…
Reference in a new issue