From 8bc591a6f07ee577b5aa594dfa705f3ddabd269d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 18 Jul 2008 13:05:10 +0000 Subject: * Use the copy-from-other-stores substituter by default. Of course, it only does something if $NIX_OTHER_STORES (not really a good name...) is set. * Do globbing on the elements of $NIX_OTHER_STORES. E.g. you could set it to /mnts/*/nix or something. * Install substituters in libexec/nix/substituters. --- scripts/copy-from-other-stores.pl.in | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'scripts/copy-from-other-stores.pl.in') diff --git a/scripts/copy-from-other-stores.pl.in b/scripts/copy-from-other-stores.pl.in index 4f829108b0b8..74efbd7459e6 100644 --- a/scripts/copy-from-other-stores.pl.in +++ b/scripts/copy-from-other-stores.pl.in @@ -3,17 +3,18 @@ use strict; use File::Basename; -#print STDERR "FOO: @ARGV\n"; +my @remoteStoresAll = split ':', ($ENV{"NIX_OTHER_STORES"} or ""); -die unless defined $ENV{"NIX_OTHER_STORES"}; -my @remoteStores = split ':', $ENV{"NIX_OTHER_STORES"}; +my @remoteStores; +foreach my $dir (@remoteStoresAll) { + push @remoteStores, glob($dir); +} sub findStorePath { my $storePath = shift; my $storePathName = basename $storePath; - #print STDERR "GET $storePath\n"; foreach my $store (@remoteStores) { # Determine whether $storePath exists by looking for the @@ -26,7 +27,6 @@ sub findStorePath { my $infoFile = "$store/var/nix/db/info/$storePathName"; my $storePath2 = "$store/store/$storePathName"; if (-f $infoFile && -e $storePath2) { - #print STDERR "FOUND IN $infoFile\n"; return ($infoFile, $storePath2); } } @@ -34,7 +34,11 @@ sub findStorePath { if ($ARGV[0] eq "--query-paths") { - # !!! not implemented yet; needed for `nix-env -qas' + foreach my $store (@remoteStores) { + opendir DIR, "$store/var/nix/db/info" or next; + print "@storedir@/$_\n" foreach readdir DIR; + closedir DIR; + } } @@ -44,7 +48,7 @@ elsif ($ARGV[0] eq "--query-info") { foreach my $storePath (@ARGV) { (my $infoFile) = findStorePath $storePath; - #print STDERR "XXX $infoFile\n"; + next unless $infoFile; my $deriver = ""; my @references = (); @@ -73,8 +77,9 @@ elsif ($ARGV[0] eq "--substitute") { die unless scalar @ARGV == 2; my $storePath = $ARGV[1]; (my $infoFile, my $sourcePath) = findStorePath $storePath; + die unless $infoFile; print "\n*** Copying `$storePath' from `$sourcePath'\n\n"; - system("nix-store --dump $sourcePath | nix-store --restore $storePath") == 0 + system("@bindir@/nix-store --dump $sourcePath | @bindir@/nix-store --restore $storePath") == 0 or die "cannot copy `$sourcePath' to `$storePath'"; } -- cgit 1.4.1