From 4213b8d8ec8cf478e43b0ec3dc4068e5e55f097a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 20 Nov 2008 15:44:59 +0000 Subject: [PATCH] * Urgh. --- scripts/copy-from-other-stores.pl.in | 5 ++++- scripts/download-using-manifests.pl.in | 16 +++++++++------- scripts/nix-build.in | 6 ++++-- scripts/nix-collect-garbage.in | 6 ++++-- scripts/nix-copy-closure.in | 3 +-- scripts/nix-install-package.in | 8 +++++--- scripts/nix-pull.in | 3 +-- scripts/nix-push.in | 3 +-- tests/init.sh | 2 ++ 9 files changed, 31 insertions(+), 21 deletions(-) diff --git a/scripts/copy-from-other-stores.pl.in b/scripts/copy-from-other-stores.pl.in index 5b695ea1a..8f0ff4ca8 100644 --- a/scripts/copy-from-other-stores.pl.in +++ b/scripts/copy-from-other-stores.pl.in @@ -4,6 +4,9 @@ use strict; use File::Basename; use IO::Handle; +my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; + + STDOUT->autoflush(1); my @remoteStoresAll = split ':', ($ENV{"NIX_OTHER_STORES"} or ""); @@ -87,7 +90,7 @@ elsif ($ARGV[0] eq "--substitute") { (my $infoFile, my $sourcePath) = findStorePath $storePath; die unless $infoFile; print "\n*** Copying `$storePath' from `$sourcePath'\n\n"; - system("@bindir@/nix-store --dump $sourcePath | @bindir@/nix-store --restore $storePath") == 0 + system("$binDir/nix-store --dump $sourcePath | $binDir/nix-store --restore $storePath") == 0 or die "cannot copy `$sourcePath' to `$storePath'"; } diff --git a/scripts/download-using-manifests.pl.in b/scripts/download-using-manifests.pl.in index 1b331ffe2..e3aa0f138 100644 --- a/scripts/download-using-manifests.pl.in +++ b/scripts/download-using-manifests.pl.in @@ -5,6 +5,8 @@ use readmanifest; use POSIX qw(strftime); use File::Temp qw(tempdir); +my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; + STDOUT->autoflush(1); my $manifestDir = "@localstatedir@/nix/manifests"; @@ -98,7 +100,7 @@ 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 + system("$binDir/nix-store --dump $sourcePath | $binDir/nix-store --restore $targetPath") == 0 or die "cannot copy `$sourcePath' to `$targetPath'"; exit 0; } @@ -147,7 +149,7 @@ addToQueue $targetPath; sub isValidPath { my $p = shift; - return system("@bindir@/nix-store --check-validity '$p' 2> /dev/null") == 0; + return system("$binDir/nix-store --check-validity '$p' 2> /dev/null") == 0; } sub parseHash { @@ -181,7 +183,7 @@ while ($queueFront < scalar @queue) { my ($baseHashAlgo, $baseHash) = parseHash $patch->{baseHash}; my $format = "--base32"; $format = "" if $baseHashAlgo eq "md5"; - my $hash = `@bindir@/nix-hash --type '$baseHashAlgo' $format "$patch->{basePath}"`; + my $hash = `$binDir/nix-hash --type '$baseHashAlgo' $format "$patch->{basePath}"`; chomp $hash; # print " MY HASH is $hash\n"; if ($hash ne $baseHash) { @@ -263,7 +265,7 @@ sub downloadFile { $ENV{"PRINT_PATH"} = 1; $ENV{"QUIET"} = 1; $ENV{"NIX_HASH_ALGO"} = $hashAlgo; - my ($hash2, $path) = `@bindir@/nix-prefetch-url '$url' '$hash'`; + my ($hash2, $path) = `$binDir/nix-prefetch-url '$url' '$hash'`; die "download of `$url' failed" unless $? == 0; chomp $hash2; chomp $path; @@ -287,7 +289,7 @@ while (scalar @path > 0) { # as a base to one or more patches. So turn the base path # into a NAR archive, to which we can apply the patch. print " packing base path...\n"; - system("@bindir@/nix-store --dump $v > $tmpNar") == 0 + system("$binDir/nix-store --dump $v > $tmpNar") == 0 or die "cannot dump `$v'"; } } @@ -315,7 +317,7 @@ while (scalar @path > 0) { # This was the last patch. Unpack the final NAR archive # into the target path. print " unpacking patched archive...\n"; - system("@bindir@/nix-store --restore $v < $tmpNar2") == 0 + system("$binDir/nix-store --restore $v < $tmpNar2") == 0 or die "cannot unpack $tmpNar2 into `$v'"; } } @@ -337,7 +339,7 @@ while (scalar @path > 0) { } else { # Unpack the archive into the target path. print " unpacking archive...\n"; - system("@bunzip2@ < '$narFilePath' | @bindir@/nix-store --restore '$v'") == 0 + system("@bunzip2@ < '$narFilePath' | $binDir/nix-store --restore '$v'") == 0 or die "cannot unpack `$narFilePath' into `$v'"; } } diff --git a/scripts/nix-build.in b/scripts/nix-build.in index a674a0041..30ada24e0 100644 --- a/scripts/nix-build.in +++ b/scripts/nix-build.in @@ -2,6 +2,8 @@ use strict; +my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; + my $addDrvLink = 0; my $addOutLink = 1; @@ -124,7 +126,7 @@ foreach my $expr (@exprs) { # Instantiate. my @drvPaths; # !!! would prefer the perl 5.8.0 pipe open feature here. - my $pid = open(DRVPATHS, "-|") || exec "@bindir@/nix-instantiate", "--add-root", $drvLink, "--indirect", @instArgs, $expr; + my $pid = open(DRVPATHS, "-|") || exec "$binDir/nix-instantiate", "--add-root", $drvLink, "--indirect", @instArgs, $expr; while () {chomp; push @drvPaths, $_;} close DRVPATHS or exit 1; @@ -135,7 +137,7 @@ foreach my $expr (@exprs) { # Build. my @outPaths; - $pid = open(OUTPATHS, "-|") || exec "@bindir@/nix-store", "--add-root", $outLink, "--indirect", "-rv", + $pid = open(OUTPATHS, "-|") || exec "$binDir/nix-store", "--add-root", $outLink, "--indirect", "-rv", @buildArgs, @drvPaths; while () {chomp; push @outPaths, $_;} close OUTPATHS or exit 1; diff --git a/scripts/nix-collect-garbage.in b/scripts/nix-collect-garbage.in index b92deefc2..f445c1c71 100644 --- a/scripts/nix-collect-garbage.in +++ b/scripts/nix-collect-garbage.in @@ -4,6 +4,8 @@ use strict; my $profilesDir = "@localstatedir@/nix/profiles"; +my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; + # Process the command line arguments. my @args = (); @@ -34,7 +36,7 @@ sub removeOldGenerations { $name = $dir . "/" . $name; if (-l $name && (readlink($name) =~ /link/)) { print STDERR "removing old generations of profile $name\n"; - system("@bindir@/nix-env", "-p", $name, "--delete-generations", "old"); + system("$binDir/nix-env", "-p", $name, "--delete-generations", "old"); } elsif (! -l $name && -d $name) { removeOldGenerations $name; @@ -48,4 +50,4 @@ removeOldGenerations $profilesDir if $removeOld; # Run the actual garbage collector. -exec "@bindir@/nix-store", "--gc", @args; +exec "$binDir/nix-store", "--gc", @args; diff --git a/scripts/nix-copy-closure.in b/scripts/nix-copy-closure.in index 0fa4e870f..688bec728 100644 --- a/scripts/nix-copy-closure.in +++ b/scripts/nix-copy-closure.in @@ -1,7 +1,6 @@ #! @perl@ -w -my $binDir = $ENV{"NIX_BIN_DIR"}; -$binDir = "@bindir@" unless defined $binDir; +my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; if (scalar @ARGV < 1) { diff --git a/scripts/nix-install-package.in b/scripts/nix-install-package.in index 3aaed7e59..e37911e33 100644 --- a/scripts/nix-install-package.in +++ b/scripts/nix-install-package.in @@ -3,6 +3,8 @@ use strict; use File::Temp qw(tempdir); +my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; + sub usageError { print STDERR < 1, TMPDIR => 1) or die "cannot create a temporary directory"; -my $binDir = $ENV{"NIX_BIN_DIR"}; -$binDir = "@bindir@" unless defined $binDir; +my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; my $libexecDir = $ENV{"NIX_LIBEXEC_DIR"}; $libexecDir = "@libexecdir@" unless defined $libexecDir; diff --git a/scripts/nix-push.in b/scripts/nix-push.in index 8ac31d501..c7a0dc668 100644 --- a/scripts/nix-push.in +++ b/scripts/nix-push.in @@ -16,8 +16,7 @@ my $curl = "@curl@ --fail --silent"; my $extraCurlFlags = ${ENV{'CURL_FLAGS'}}; $curl = "$curl $extraCurlFlags" if defined $extraCurlFlags; -my $binDir = $ENV{"NIX_BIN_DIR"}; -$binDir = "@bindir@" unless defined $binDir; +my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; my $dataDir = $ENV{"NIX_DATA_DIR"}; $dataDir = "@datadir@" unless defined $dataDir; diff --git a/tests/init.sh b/tests/init.sh index 58463684e..c7d21ba07 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -65,6 +65,8 @@ for i in \ $NIX_BIN_DIR/nix/readmanifest.pm \ ; do sed < $i > $i.tmp \ + -e "s^$REAL_BIN_DIR/nix-store^$NIX_BIN_DIR/nix-store^" \ + -e "s^$REAL_BIN_DIR/nix-hash^$NIX_BIN_DIR/nix-hash^" \ -e "s^$REAL_LIBEXEC_DIR^$NIX_LIBEXEC_DIR^" \ -e "s^$REAL_LOCALSTATE_DIR^$NIX_LOCALSTATE_DIR^" \ -e "s^$REAL_DATA_DIR^$NIX_DATA_DIR^" \