forked from lix-project/lix
* New kind of manifest object: "localPath", which denotes that a store
path can be created by copying it from another location in the file system. This is useful in the NixOS installation.
This commit is contained in:
parent
36d9258c0d
commit
bae75ca5a1
|
@ -34,17 +34,31 @@ print "\n*** Trying to download/patch `$targetPath'\n";
|
||||||
|
|
||||||
# Load all manifests.
|
# Load all manifests.
|
||||||
my %narFiles;
|
my %narFiles;
|
||||||
|
my %localPaths;
|
||||||
my %patches;
|
my %patches;
|
||||||
|
|
||||||
for my $manifest (glob "$manifestDir/*.nixmanifest") {
|
for my $manifest (glob "$manifestDir/*.nixmanifest") {
|
||||||
# print STDERR "reading $manifest\n";
|
# print STDERR "reading $manifest\n";
|
||||||
if (readManifest($manifest, \%narFiles, \%patches) < 3) {
|
if (readManifest($manifest, \%narFiles, \%localPaths, \%patches) < 3) {
|
||||||
print STDERR "you have an old-style manifest `$manifest'; please delete it\n";
|
print STDERR "you have an old-style manifest `$manifest'; please delete it\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# If we can copy from a local path, do that.
|
||||||
|
my $localPathList = $localPaths{$targetPath};
|
||||||
|
foreach my $localPath (@{$localPathList}) {
|
||||||
|
my $sourcePath = $localPath->{copyFrom};
|
||||||
|
if (-e $sourcePath) {
|
||||||
|
print "\n*** Step 1/1: copying from $sourcePath\n";
|
||||||
|
system("@bindir@/nix-store --dump $sourcePath | @bindir@/nix-store --restore $targetPath") == 0
|
||||||
|
or die "cannot copy `$sourcePath' to `$targetPath'";
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# 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
|
||||||
# edges are either patch operations, or downloads of full NAR files.
|
# edges are either patch operations, or downloads of full NAR files.
|
||||||
|
|
|
@ -28,16 +28,18 @@ print "TEMP = $tmpDir\n";
|
||||||
#END { rmdir $tmpDir; }
|
#END { rmdir $tmpDir; }
|
||||||
|
|
||||||
my %srcNarFiles;
|
my %srcNarFiles;
|
||||||
|
my %srcLocalPaths;
|
||||||
my %srcPatches;
|
my %srcPatches;
|
||||||
|
|
||||||
my %dstNarFiles;
|
my %dstNarFiles;
|
||||||
|
my %dstLocalPaths;
|
||||||
my %dstPatches;
|
my %dstPatches;
|
||||||
|
|
||||||
readManifest "$srcDir/MANIFEST",
|
readManifest "$srcDir/MANIFEST",
|
||||||
\%srcNarFiles, \%srcPatches;
|
\%srcNarFiles, \%srcLocalPaths, \%srcPatches;
|
||||||
|
|
||||||
readManifest "$dstDir/MANIFEST",
|
readManifest "$dstDir/MANIFEST",
|
||||||
\%dstNarFiles, \%dstPatches;
|
\%dstNarFiles, \%dstLocalPaths, \%dstPatches;
|
||||||
|
|
||||||
|
|
||||||
sub findOutputPaths {
|
sub findOutputPaths {
|
||||||
|
|
|
@ -7,11 +7,12 @@ use readcache;
|
||||||
|
|
||||||
# Read the manifests.
|
# Read the manifests.
|
||||||
my %narFiles;
|
my %narFiles;
|
||||||
|
my %localPaths;
|
||||||
my %patches;
|
my %patches;
|
||||||
|
|
||||||
foreach my $manifest (@ARGV) {
|
foreach my $manifest (@ARGV) {
|
||||||
print STDERR "loading $manifest\n";
|
print STDERR "loading $manifest\n";
|
||||||
if (readManifest($manifest, \%narFiles, \%patches, 1) < 3) {
|
if (readManifest($manifest, \%narFiles, \%localPaths, \%patches, 1) < 3) {
|
||||||
# die "manifest `$manifest' is too old (i.e., for Nix <= 0.7)\n";
|
# die "manifest `$manifest' is too old (i.e., for Nix <= 0.7)\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,12 @@ use readcache;
|
||||||
|
|
||||||
|
|
||||||
my %allNarFiles;
|
my %allNarFiles;
|
||||||
|
my %allLocalPaths;
|
||||||
my %allPatches;
|
my %allPatches;
|
||||||
|
|
||||||
foreach my $manifest (glob "/data/webserver/dist/*/*/MANIFEST") {
|
foreach my $manifest (glob "/data/webserver/dist/*/*/MANIFEST") {
|
||||||
print STDERR "loading $manifest\n";
|
print STDERR "loading $manifest\n";
|
||||||
readManifest($manifest, \%allNarFiles, \%allPatches, 1);
|
readManifest($manifest, \%allNarFiles, \%allLocalPaths, \%allPatches, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ umask 0022;
|
||||||
|
|
||||||
# Process the URLs specified on the command line.
|
# Process the URLs specified on the command line.
|
||||||
my %narFiles;
|
my %narFiles;
|
||||||
|
my %localPaths;
|
||||||
my %patches;
|
my %patches;
|
||||||
|
|
||||||
my $skipWrongStore = 0;
|
my $skipWrongStore = 0;
|
||||||
|
@ -42,7 +43,7 @@ sub processURL {
|
||||||
"'$url' > '$manifest'") == 0
|
"'$url' > '$manifest'") == 0
|
||||||
or die "curl failed: $?";
|
or die "curl failed: $?";
|
||||||
|
|
||||||
if (readManifest($manifest, \%narFiles, \%patches) < 3) {
|
if (readManifest($manifest, \%narFiles, \%localPaths, \%patches) < 3) {
|
||||||
die "manifest `$url' is too old (i.e., for Nix <= 0.7)\n";
|
die "manifest `$url' is too old (i.e., for Nix <= 0.7)\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +81,7 @@ while (@ARGV) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
my $size = scalar (keys %narFiles);
|
my $size = scalar (keys %narFiles) + scalar (keys %localPaths);
|
||||||
print "$size store paths in manifest\n";
|
print "$size store paths in manifest\n";
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,19 +91,32 @@ print STDERR "registering substitutes...\n";
|
||||||
my $pid = open(WRITE, "|$binDir/nix-store --register-substitutes")
|
my $pid = open(WRITE, "|$binDir/nix-store --register-substitutes")
|
||||||
or die "cannot run nix-store";
|
or die "cannot run nix-store";
|
||||||
|
|
||||||
|
sub writeRegistration {
|
||||||
|
my $storePath = shift;
|
||||||
|
my $object = shift;
|
||||||
|
print WRITE "$storePath\n";
|
||||||
|
print WRITE "$object->{deriver}\n";
|
||||||
|
print WRITE "$libexecDir/nix/download-using-manifests.pl\n";
|
||||||
|
print WRITE "0\n";
|
||||||
|
my @references = split " ", $object->{references};
|
||||||
|
my $count = scalar @references;
|
||||||
|
print WRITE "$count\n";
|
||||||
|
foreach my $reference (@references) {
|
||||||
|
print WRITE "$reference\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
foreach my $storePath (keys %narFiles) {
|
foreach my $storePath (keys %narFiles) {
|
||||||
my $narFileList = $narFiles{$storePath};
|
my $narFileList = $narFiles{$storePath};
|
||||||
foreach my $narFile (@{$narFileList}) {
|
foreach my $narFile (@{$narFileList}) {
|
||||||
print WRITE "$storePath\n";
|
writeRegistration $storePath, $narFile;
|
||||||
print WRITE "$narFile->{deriver}\n";
|
}
|
||||||
print WRITE "$libexecDir/nix/download-using-manifests.pl\n";
|
}
|
||||||
print WRITE "0\n";
|
|
||||||
my @references = split " ", $narFile->{references};
|
foreach my $storePath (keys %localPaths) {
|
||||||
my $count = scalar @references;
|
my $localPathList = $localPaths{$storePath};
|
||||||
print WRITE "$count\n";
|
foreach my $localPath (@{$localPathList}) {
|
||||||
foreach my $reference (@references) {
|
writeRegistration $storePath, $localPath;
|
||||||
print WRITE "$reference\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ sub addPatch {
|
||||||
sub readManifest {
|
sub readManifest {
|
||||||
my $manifest = shift;
|
my $manifest = shift;
|
||||||
my $narFiles = shift;
|
my $narFiles = shift;
|
||||||
|
my $localPaths = shift;
|
||||||
my $patches = shift;
|
my $patches = shift;
|
||||||
my $allowConflicts = shift;
|
my $allowConflicts = shift;
|
||||||
$allowConflicts = 0 unless defined $allowConflicts;
|
$allowConflicts = 0 unless defined $allowConflicts;
|
||||||
|
@ -57,6 +58,7 @@ sub readManifest {
|
||||||
my $references;
|
my $references;
|
||||||
my $deriver;
|
my $deriver;
|
||||||
my $hashAlgo;
|
my $hashAlgo;
|
||||||
|
my $copyFrom;
|
||||||
|
|
||||||
while (<MANIFEST>) {
|
while (<MANIFEST>) {
|
||||||
chomp;
|
chomp;
|
||||||
|
@ -125,9 +127,25 @@ sub readManifest {
|
||||||
}, $allowConflicts;
|
}, $allowConflicts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
elsif ($type eq "localPath") {
|
||||||
|
|
||||||
|
$$localPaths{$storePath} = []
|
||||||
|
unless defined $$localPaths{$storePath};
|
||||||
|
|
||||||
|
my $localPathsList = $$localPaths{$storePath};
|
||||||
|
|
||||||
|
# !!! remove duplicates
|
||||||
|
|
||||||
|
push @{$localPathsList},
|
||||||
|
{ copyFrom => $copyFrom, references => $references
|
||||||
|
, deriver => ""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif (/^\s*StorePath:\s*(\/\S+)\s*$/) { $storePath = $1; }
|
elsif (/^\s*StorePath:\s*(\/\S+)\s*$/) { $storePath = $1; }
|
||||||
|
elsif (/^\s*CopyFrom:\s*(\/\S+)\s*$/) { $copyFrom = $1; }
|
||||||
elsif (/^\s*Hash:\s*(\S+)\s*$/) { $hash = $1; }
|
elsif (/^\s*Hash:\s*(\S+)\s*$/) { $hash = $1; }
|
||||||
elsif (/^\s*URL:\s*(\S+)\s*$/) { $url = $1; }
|
elsif (/^\s*URL:\s*(\S+)\s*$/) { $url = $1; }
|
||||||
elsif (/^\s*Size:\s*(\d+)\s*$/) { $size = $1; }
|
elsif (/^\s*Size:\s*(\d+)\s*$/) { $size = $1; }
|
||||||
|
@ -158,6 +176,7 @@ sub writeManifest
|
||||||
my $manifest = shift;
|
my $manifest = shift;
|
||||||
my $narFiles = shift;
|
my $narFiles = shift;
|
||||||
my $patches = shift;
|
my $patches = shift;
|
||||||
|
my $copySources = shift;
|
||||||
|
|
||||||
open MANIFEST, ">$manifest.tmp"; # !!! check exclusive
|
open MANIFEST, ">$manifest.tmp"; # !!! check exclusive
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,12 @@ use readmanifest;
|
||||||
for my $p (@ARGV) {
|
for my $p (@ARGV) {
|
||||||
|
|
||||||
my %narFiles;
|
my %narFiles;
|
||||||
|
my %localPaths;
|
||||||
my %patches;
|
my %patches;
|
||||||
|
|
||||||
readManifest $p,
|
readManifest $p, \%narFiles, \%localPaths, \%patches;
|
||||||
\%narFiles, \%patches;
|
|
||||||
|
|
||||||
%patches = ();
|
%patches = ();
|
||||||
|
|
||||||
writeManifest $p,
|
writeManifest $p, \%narFiles, \%patches;
|
||||||
\%narFiles, \%patches;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,9 +8,10 @@ die unless scalar @ARGV == 2;
|
||||||
my $cache = $ARGV[0];
|
my $cache = $ARGV[0];
|
||||||
my $manifest = $ARGV[1];
|
my $manifest = $ARGV[1];
|
||||||
my %narFiles;
|
my %narFiles;
|
||||||
|
my %localPaths;
|
||||||
my %patches;
|
my %patches;
|
||||||
|
|
||||||
readManifest $manifest, \%narFiles, \%patches;
|
readManifest $manifest, \%narFiles, \%localPaths, \%patches;
|
||||||
|
|
||||||
foreach my $storePath (keys %narFiles) {
|
foreach my $storePath (keys %narFiles) {
|
||||||
my $narFileList = $narFiles{$storePath};
|
my $narFileList = $narFiles{$storePath};
|
||||||
|
|
Loading…
Reference in a new issue