diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2011-10-10T21·11+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2011-10-10T21·11+0000 |
commit | 6fcdbcac202e40e5de7147ff64b34d6aaad16249 (patch) | |
tree | 3a18b2cde295fd1551bedb279948660dccd22d60 | |
parent | 659c427caa39e44e5861ff1345425e4c34c9ced3 (diff) |
* Install NixManifest.pm, NixConfig.pm and GeneratePatches.pm under
the Nix:: namespace.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | corepkgs/nar/nar.nix | 2 | ||||
-rw-r--r-- | perl/Makefile.am | 8 | ||||
-rw-r--r-- | perl/lib/Nix/Config.pm.in (renamed from scripts/NixConfig.pm.in) | 10 | ||||
-rw-r--r-- | perl/lib/Nix/GeneratePatches.pm (renamed from scripts/GeneratePatches.pm.in) | 19 | ||||
-rw-r--r-- | perl/lib/Nix/Manifest.pm (renamed from scripts/NixManifest.pm.in) | 13 | ||||
-rw-r--r-- | scripts/Makefile.am | 10 | ||||
-rw-r--r-- | scripts/download-using-manifests.pl.in | 30 | ||||
-rw-r--r-- | scripts/nix-generate-patches.in | 6 | ||||
-rw-r--r-- | scripts/nix-install-package.in | 9 | ||||
-rw-r--r-- | scripts/nix-prefetch-url.in | 17 | ||||
-rw-r--r-- | scripts/nix-pull.in | 18 | ||||
-rw-r--r-- | scripts/nix-push.in | 9 | ||||
-rwxr-xr-x | scripts/update-manifest.pl | 52 | ||||
-rw-r--r-- | substitute.mk | 2 | ||||
-rw-r--r-- | tests/binary-patching.sh | 12 | ||||
-rw-r--r-- | tests/common.sh.in | 13 | ||||
-rw-r--r-- | tests/init.sh | 18 | ||||
-rw-r--r-- | tests/nix-pull.sh | 2 | ||||
-rw-r--r-- | tests/nix-push.sh | 3 |
20 files changed, 108 insertions, 147 deletions
diff --git a/configure.ac b/configure.ac index b0ce642a7965..876e0a862ee8 100644 --- a/configure.ac +++ b/configure.ac @@ -283,6 +283,8 @@ fi # Check for the required Perl dependencies (DBI and DBD::SQLite). +perlFlags="-I${libdir}/perl5/site_perl" + AC_ARG_WITH(dbi, AC_HELP_STRING([--with-dbi=PATH], [prefix of the Perl DBI library]), perlFlags="$perlFlags -I$withval") diff --git a/corepkgs/nar/nar.nix b/corepkgs/nar/nar.nix index da63bde9a62e..d3d799998f10 100644 --- a/corepkgs/nar/nar.nix +++ b/corepkgs/nar/nar.nix @@ -1,4 +1,4 @@ -{system, storePath, hashAlgo}: +{ system, storePath, hashAlgo }: derivation { name = "nar"; diff --git a/perl/Makefile.am b/perl/Makefile.am index 548708a33842..a459bdc87c76 100644 --- a/perl/Makefile.am +++ b/perl/Makefile.am @@ -2,7 +2,9 @@ perlversion := $(shell perl -e 'use Config; print $$Config{version};') perlarchname := $(shell perl -e 'use Config; print $$Config{archname};') perllibdir = $(libdir)/perl5/site_perl/$(perlversion)/$(perlarchname) -install-exec-local: lib/Nix/*.pm +all: lib/Nix/Config.pm + +install-exec-local: lib/Nix/*.pm lib/Nix/Config.pm $(INSTALL) -d $(DESTDIR)$(perllibdir)/Nix $(INSTALL_DATA) lib/Nix/*.pm $(DESTDIR)$(perllibdir)/Nix $(INSTALL) -d $(DESTDIR)$(perllibdir)/auto/Nix/Store @@ -22,4 +24,6 @@ AM_CXXFLAGS = \ lib/Nix/Store.cc: lib/Nix/Store.xs xsubpp $^ -output $@ -EXTRA_DIST = lib/Nix/*.pm lib/Nix/Store.xs +EXTRA_DIST = lib/Nix/Store.pm lib/Nix/Manifest.pm lib/Nix/Config.pm.in lib/Nix/Store.xs + +include ../substitute.mk diff --git a/scripts/NixConfig.pm.in b/perl/lib/Nix/Config.pm.in index aeb443aeed3a..658305fd9783 100644 --- a/scripts/NixConfig.pm.in +++ b/perl/lib/Nix/Config.pm.in @@ -1,4 +1,12 @@ -use strict; +package Nix::Config; + +$binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; +$libexecDir = $ENV{"NIX_LIBEXEC_DIR"} || "@libexecdir@"; +$manifestDir = $ENV{"NIX_MANIFESTS_DIR"} || "@localstatedir@/nix/manifests"; +$logDir = $ENV{"NIX_LOG_DIR"} || "@localstatedir@/log/nix"; + +$bzip2 = $ENV{"NIX_BZIP2"} || "@bzip2@"; +$curl = "@curl@"; sub readConfig { my %config; diff --git a/scripts/GeneratePatches.pm.in b/perl/lib/Nix/GeneratePatches.pm index 4bb5b05a8c9e..f9d83c49c856 100644 --- a/scripts/GeneratePatches.pm.in +++ b/perl/lib/Nix/GeneratePatches.pm @@ -1,6 +1,13 @@ +package Nix::GeneratePatches; + use strict; use File::Temp qw(tempdir); use File::stat; +use Nix::Config; +use Nix::Manifest; + +our @ISA = qw(Exporter); +our @EXPORT = qw(generatePatches propagatePatches copyPatches); # Some patch generations options. @@ -201,7 +208,7 @@ sub generatePatches { next; } - system("@bunzip2@ < $srcNarBz2 > $tmpDir/A") == 0 + system("$Nix::Config::bzip2 -d < $srcNarBz2 > $tmpDir/A") == 0 or die "cannot unpack $srcNarBz2"; if (stat("$tmpDir/A")->size >= $maxNarSize) { @@ -209,7 +216,7 @@ sub generatePatches { next; } - system("@bunzip2@ < $dstNarBz2 > $tmpDir/B") == 0 + system("$Nix::Config::bzip2 -d < $dstNarBz2 > $tmpDir/B") == 0 or die "cannot unpack $dstNarBz2"; if (stat("$tmpDir/B")->size >= $maxNarSize) { @@ -218,20 +225,20 @@ sub generatePatches { } my $time1 = time(); - my $res = system("ulimit -t $timeLimit; @libexecdir@/bsdiff $tmpDir/A $tmpDir/B $tmpDir/DIFF"); + my $res = system("ulimit -t $timeLimit; $Nix::Config::libexecDir/bsdiff $tmpDir/A $tmpDir/B $tmpDir/DIFF"); my $time2 = time(); if ($res) { warn "binary diff computation aborted after ", $time2 - $time1, " seconds\n"; next; } - my $baseHash = `@bindir@/nix-hash --flat --type $hashAlgo --base32 $tmpDir/A` or die; + my $baseHash = `$Nix::Config::binDir/nix-hash --flat --type $hashAlgo --base32 $tmpDir/A` or die; chomp $baseHash; - my $narHash = `@bindir@/nix-hash --flat --type $hashAlgo --base32 $tmpDir/B` or die; + my $narHash = `$Nix::Config::binDir/nix-hash --flat --type $hashAlgo --base32 $tmpDir/B` or die; chomp $narHash; - my $narDiffHash = `@bindir@/nix-hash --flat --type $hashAlgo --base32 $tmpDir/DIFF` or die; + my $narDiffHash = `$Nix::Config::binDir/nix-hash --flat --type $hashAlgo --base32 $tmpDir/DIFF` or die; chomp $narDiffHash; my $narDiffSize = stat("$tmpDir/DIFF")->size; diff --git a/scripts/NixManifest.pm.in b/perl/lib/Nix/Manifest.pm index d080dcee7478..7790cfe3b98c 100644 --- a/scripts/NixManifest.pm.in +++ b/perl/lib/Nix/Manifest.pm @@ -1,9 +1,15 @@ +package Nix::Manifest; + use strict; use DBI; use Cwd; use File::stat; use File::Path; use Fcntl ':flock'; +use Nix::Config; + +our @ISA = qw(Exporter); +our @EXPORT = qw(readManifest writeManifest updateManifestDB addPatch); sub addNAR { @@ -200,7 +206,7 @@ sub writeManifest { # Create a bzipped manifest. unless (defined $noCompress) { - system("@bzip2@ < $manifest > $manifest.bz2.tmp") == 0 + system("$Nix::Config::bzip2 < $manifest > $manifest.bz2.tmp") == 0 or die "cannot compress manifest"; rename("$manifest.bz2.tmp", "$manifest.bz2") @@ -210,7 +216,7 @@ sub writeManifest { sub updateManifestDB { - my $manifestDir = ($ENV{"NIX_MANIFESTS_DIR"} or "@localstatedir@/nix/manifests"); + my $manifestDir = $Nix::Config::manifestDir; mkpath($manifestDir); @@ -276,7 +282,8 @@ EOF # Acquire an exclusive lock to ensure that only one process # updates the DB at the same time. This isn't really necessary, # but it prevents work duplication and lock contention in SQLite. - open MAINLOCK, ">>$manifestDir/cache.lock" or die; + my $lockFile = "$manifestDir/cache.lock"; + open MAINLOCK, ">>$lockFile" or die "unable to acquire lock ‘$lockFile’: $!\n"; flock(MAINLOCK, LOCK_EX) or die; $dbh->begin_work; diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 60bb0a9b8105..752fcd574025 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -3,20 +3,17 @@ bin_SCRIPTS = nix-collect-garbage \ nix-install-package nix-channel nix-build \ nix-copy-closure nix-generate-patches -noinst_SCRIPTS = nix-profile.sh GeneratePatches.pm \ +noinst_SCRIPTS = nix-profile.sh \ find-runtime-roots.pl build-remote.pl nix-reduce-build \ copy-from-other-stores.pl nix-http-export.cgi -nix-pull nix-push: NixManifest.pm NixConfig.pm download-using-manifests.pl +nix-pull nix-push: download-using-manifests.pl -install-exec-local: NixManifest.pm GeneratePatches.pm download-using-manifests.pl copy-from-other-stores.pl find-runtime-roots.pl +install-exec-local: download-using-manifests.pl copy-from-other-stores.pl find-runtime-roots.pl $(INSTALL) -d $(DESTDIR)$(sysconfdir)/profile.d $(INSTALL_PROGRAM) nix-profile.sh $(DESTDIR)$(sysconfdir)/profile.d/nix.sh $(INSTALL) -d $(DESTDIR)$(libexecdir)/nix - $(INSTALL_DATA) NixManifest.pm $(DESTDIR)$(libexecdir)/nix - $(INSTALL_DATA) NixConfig.pm $(DESTDIR)$(libexecdir)/nix $(INSTALL_DATA) SSH.pm $(DESTDIR)$(libexecdir)/nix - $(INSTALL_DATA) GeneratePatches.pm $(DESTDIR)$(libexecdir)/nix $(INSTALL_PROGRAM) find-runtime-roots.pl $(DESTDIR)$(libexecdir)/nix $(INSTALL_PROGRAM) build-remote.pl $(DESTDIR)$(libexecdir)/nix $(INSTALL) -d $(DESTDIR)$(libexecdir)/nix/substituters @@ -30,7 +27,6 @@ EXTRA_DIST = nix-collect-garbage.in \ nix-pull.in nix-push.in nix-profile.sh.in \ nix-prefetch-url.in nix-install-package.in \ nix-channel.in \ - NixManifest.pm.in \ NixConfig.pm.in \ SSH.pm \ GeneratePatches.pm.in \ diff --git a/scripts/download-using-manifests.pl.in b/scripts/download-using-manifests.pl.in index ca4d97b51aa6..a827a995f919 100644 --- a/scripts/download-using-manifests.pl.in +++ b/scripts/download-using-manifests.pl.in @@ -1,16 +1,14 @@ -#! @perl@ -w -I@libexecdir@/nix @perlFlags@ +#! @perl@ -w @perlFlags@ use strict; -use NixManifest; +use Nix::Config; +use Nix::Manifest; use POSIX qw(strftime); use File::Temp qw(tempdir); -my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; - STDOUT->autoflush(1); -my $manifestDir = ($ENV{"NIX_MANIFESTS_DIR"} or "@localstatedir@/nix/manifests"); -my $logFile = "@localstatedir@/log/nix/downloads"; +my $logFile = "$Nix::Config::logDir/downloads"; # For queries, skip expensive calls to nix-hash etc. We're just # estimating the expected download size. @@ -26,7 +24,7 @@ sub isValidPath { if ($fast) { return -e $p; } else { - return system("$binDir/nix-store --check-validity '$p' 2> /dev/null") == 0; + return system("$Nix::Config::binDir/nix-store --check-validity '$p' 2> /dev/null") == 0; } } @@ -108,8 +106,8 @@ sub computeSmallestDownload { my $format = "--base32"; $format = "" if $baseHashAlgo eq "md5"; my $hash = $fast && $baseHashAlgo eq "sha256" - ? `$binDir/nix-store -q --hash "$patch->{basePath}"` - : `$binDir/nix-hash --type '$baseHashAlgo' $format "$patch->{basePath}"`; + ? `$Nix::Config::binDir/nix-store -q --hash "$patch->{basePath}"` + : `$Nix::Config::binDir/nix-hash --type '$baseHashAlgo' $format "$patch->{basePath}"`; chomp $hash; $hash =~ s/.*://; next if $hash ne $baseHash; @@ -282,7 +280,7 @@ sub downloadFile { my $url = shift; $ENV{"PRINT_PATH"} = 1; $ENV{"QUIET"} = 1; - my ($hash, $path) = `$binDir/nix-prefetch-url '$url'`; + my ($hash, $path) = `$Nix::Config::binDir/nix-prefetch-url '$url'`; die "download of `$url' failed" . ($! ? ": $!" : "") unless $? == 0; chomp $path; return $path; @@ -306,7 +304,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("$Nix::Config::binDir/nix-store --dump $v > $tmpNar") == 0 or die "cannot dump `$v'"; } } @@ -324,7 +322,7 @@ while (scalar @path > 0) { # Apply the patch to the NAR archive produced in step 1 (for # the already present path) or a later step (for patch sequences). print " applying patch...\n"; - system("@libexecdir@/bspatch $tmpNar $tmpNar2 $patchPath") == 0 + system("$Nix::Config::libexecDir/bspatch $tmpNar $tmpNar2 $patchPath") == 0 or die "cannot apply patch `$patchPath' to $tmpNar"; if ($curStep < $maxStep) { @@ -334,7 +332,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("$Nix::Config::binDir/nix-store --restore $v < $tmpNar2") == 0 or die "cannot unpack $tmpNar2 into `$v'"; } @@ -354,12 +352,12 @@ while (scalar @path > 0) { if ($curStep < $maxStep) { # The archive will be used a base to a patch. - system("@bunzip2@ < '$narFilePath' > $tmpNar") == 0 + system("$Nix::Config::bzip2 -d < '$narFilePath' > $tmpNar") == 0 or die "cannot unpack `$narFilePath' into `$v'"; } else { # Unpack the archive into the target path. print " unpacking archive...\n"; - system("@bunzip2@ < '$narFilePath' | $binDir/nix-store --restore '$v'") == 0 + system("$Nix::Config::bzip2 -d < '$narFilePath' | $Nix::Config::binDir/nix-store --restore '$v'") == 0 or die "cannot unpack `$narFilePath' into `$v'"; } @@ -382,7 +380,7 @@ if (defined $finalNarHash) { ($hashAlgo eq "sha256" && length($hash) != 64) ? "--base32" : ""; - my $hash2 = `@bindir@/nix-hash --type $hashAlgo $extraFlag $targetPath` + my $hash2 = `$Nix::Config::binDir/nix-hash --type $hashAlgo $extraFlag $targetPath` or die "cannot compute hash of path `$targetPath'"; chomp $hash2; diff --git a/scripts/nix-generate-patches.in b/scripts/nix-generate-patches.in index 1f32ab410920..4cb843382b52 100644 --- a/scripts/nix-generate-patches.in +++ b/scripts/nix-generate-patches.in @@ -1,9 +1,9 @@ -#! @perl@ -w -I@libexecdir@/nix @perlFlags@ +#! @perl@ -w @perlFlags@ use strict; use File::Temp qw(tempdir); -use NixManifest; -use GeneratePatches; +use Nix::Manifest; +use Nix::GeneratePatches; if (scalar @ARGV != 5) { print STDERR <<EOF; diff --git a/scripts/nix-install-package.in b/scripts/nix-install-package.in index f40cfc7d0b23..178b14c7468f 100644 --- a/scripts/nix-install-package.in +++ b/scripts/nix-install-package.in @@ -2,8 +2,7 @@ use strict; use File::Temp qw(tempdir); - -my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; +use Nix::Config; sub usageError { @@ -61,7 +60,7 @@ if ($interactive && !defined $ENV{"NIX_HAVE_TERMINAL"}) { $ENV{"NIX_HAVE_TERMINAL"} = "1"; $ENV{"LD_LIBRARY_PATH"} = ""; foreach my $term ("xterm", "konsole", "gnome-terminal", "xterm") { - exec($term, "-e", "$binDir/nix-install-package", @ARGV); + exec($term, "-e", "$Nix::Config::binDir/nix-install-package", @ARGV); } die "cannot execute `xterm'"; } @@ -132,12 +131,12 @@ $ENV{NIX_REMOTE} = ""; print "\nPulling manifests...\n"; -system("$binDir/nix-pull", $manifestURL) == 0 +system("$Nix::Config::binDir/nix-pull", $manifestURL) == 0 or barf "nix-pull failed: $?"; print "\nInstalling package...\n"; -system("$binDir/nix-env", "--install", $outPath, "--force-name", $drvName, @extraNixEnvArgs) == 0 +system("$Nix::Config::binDir/nix-env", "--install", $outPath, "--force-name", $drvName, @extraNixEnvArgs) == 0 or barf "nix-env failed: $?"; diff --git a/scripts/nix-prefetch-url.in b/scripts/nix-prefetch-url.in index 31170fa953ea..45bad75f3e9f 100644 --- a/scripts/nix-prefetch-url.in +++ b/scripts/nix-prefetch-url.in @@ -3,6 +3,9 @@ url=$1 expHash=$2 +binDir=@bindir@ +if [ -n "$NIX_BIN_DIR" ]; then binDir="$NIX_BIN_DIR"; fi + # needed to make it work on NixOS export PATH=$PATH:@coreutils@ @@ -31,8 +34,8 @@ if test -z "$name"; then echo "invalid url"; exit 1; fi # If the hash was given, a file with that hash may already be in the # store. if test -n "$expHash"; then - finalPath=$(@bindir@/nix-store --print-fixed-path "$hashType" "$expHash" "$name") - if ! @bindir@/nix-store --check-validity "$finalPath" 2> /dev/null; then + finalPath=$($binDir/nix-store --print-fixed-path "$hashType" "$expHash" "$name") + if ! $bindir/nix-store --check-validity "$finalPath" 2> /dev/null; then finalPath= fi hash=$expHash @@ -103,7 +106,7 @@ if test -z "$finalPath"; then # garbage-collected independently. if test -n "$NIX_DOWNLOAD_CACHE"; then echo -n "$url" > $tmpPath/url - urlHash=$(@bindir@/nix-hash --type sha256 --base32 --flat $tmpPath/url) + urlHash=$($binDir/nix-hash --type sha256 --base32 --flat $tmpPath/url) echo "$url" > "$NIX_DOWNLOAD_CACHE/$urlHash.url" cachedHashFN="$NIX_DOWNLOAD_CACHE/$urlHash.$hashType" cachedTimestampFN="$NIX_DOWNLOAD_CACHE/$urlHash.stamp" @@ -121,8 +124,8 @@ if test -z "$finalPath"; then # Curl didn't create $tmpFile, so apparently there's no newer # file on the server. hash=$(cat $cachedHashFN) - finalPath=$(@bindir@/nix-store --print-fixed-path "$hashType" "$hash" "$name") - if ! @bindir@/nix-store --check-validity "$finalPath" 2> /dev/null; then + finalPath=$($binDir/nix-store --print-fixed-path "$hashType" "$hash" "$name") + if ! $binDir/nix-store --check-validity "$finalPath" 2> /dev/null; then echo "cached contents of \`$url' disappeared, redownloading..." >&2 finalPath= cacheFlags="--remote-time" @@ -133,7 +136,7 @@ if test -z "$finalPath"; then if test -z "$finalPath"; then # Compute the hash. - hash=$(@bindir@/nix-hash --type "$hashType" $hashFormat --flat $tmpFile) + hash=$($binDir/nix-hash --type "$hashType" $hashFormat --flat $tmpFile) if ! test -n "$QUIET"; then echo "hash is $hash" >&2; fi if test -n "$NIX_DOWNLOAD_CACHE"; then @@ -142,7 +145,7 @@ if test -z "$finalPath"; then fi # Add the downloaded file to the Nix store. - finalPath=$(@bindir@/nix-store --add-fixed "$hashType" $tmpFile) + finalPath=$($binDir/nix-store --add-fixed "$hashType" $tmpFile) if test -n "$expHash" -a "$expHash" != "$hash"; then echo "hash mismatch for URL \`$url'" >&2 diff --git a/scripts/nix-pull.in b/scripts/nix-pull.in index 51c7e681a5a7..8fb256179c02 100644 --- a/scripts/nix-pull.in +++ b/scripts/nix-pull.in @@ -1,17 +1,17 @@ -#! @perl@ -w -I@libexecdir@/nix @perlFlags@ +#! @perl@ -w @perlFlags@ use strict; use File::Temp qw(tempdir); -use NixManifest; +use Nix::Config; +use Nix::Manifest; my $tmpDir = tempdir("nix-pull.XXXXXX", CLEANUP => 1, TMPDIR => 1) or die "cannot create a temporary directory"; -my $binDir = $ENV{"NIX_BIN_DIR"} || "@bindir@"; my $libexecDir = ($ENV{"NIX_LIBEXEC_DIR"} or "@libexecdir@"); my $storeDir = ($ENV{"NIX_STORE_DIR"} or "@storedir@"); my $stateDir = ($ENV{"NIX_STATE_DIR"} or "@localstatedir@/nix"); -my $manifestDir = ($ENV{"NIX_MANIFESTS_DIR"} or "$stateDir/manifests"); +my $manifestDir = $Nix::Config::manifestDir; # Prevent access problems in shared-stored installations. @@ -42,7 +42,7 @@ sub downloadFile { my $url = shift; $ENV{"PRINT_PATH"} = 1; $ENV{"QUIET"} = 1; - my ($dummy, $path) = `$binDir/nix-prefetch-url '$url'`; + my ($dummy, $path) = `$Nix::Config::binDir/nix-prefetch-url '$url'`; die "cannot fetch `$url'" if $? != 0; die "nix-prefetch-url did not return a path" unless defined $path; chomp $path; @@ -57,16 +57,16 @@ sub processURL { my $manifest; # First see if a bzipped manifest is available. - if (system("@curl@ --fail --silent --head '$url'.bz2 > /dev/null") == 0) { + if (system("$Nix::Config::curl --fail --silent --head '$url'.bz2 > /dev/null") == 0) { print "fetching list of Nix archives at `$url.bz2'...\n"; my $bzipped = downloadFile "$url.bz2"; $manifest = "$tmpDir/MANIFEST"; - system("@bunzip2@ < $bzipped > $manifest") == 0 + system("$Nix::Config::bzip2 -d < $bzipped > $manifest") == 0 or die "cannot decompress manifest"; - $manifest = (`$binDir/nix-store --add $manifest` + $manifest = (`$Nix::Config::binDir/nix-store --add $manifest` or die "cannot copy $manifest to the store"); chomp $manifest; } @@ -96,7 +96,7 @@ sub processURL { $baseName = $1; } - my $hash = `$binDir/nix-hash --flat '$manifest'` + my $hash = `$Nix::Config::binDir/nix-hash --flat '$manifest'` or die "cannot hash `$manifest'"; chomp $hash; diff --git a/scripts/nix-push.in b/scripts/nix-push.in index fd1ec21485e2..dcdad5721265 100644 --- a/scripts/nix-push.in +++ b/scripts/nix-push.in @@ -1,9 +1,10 @@ -#! @perl@ -w -I@libexecdir@/nix @perlFlags@ +#! @perl@ -w @perlFlags@ use strict; use File::Temp qw(tempdir); use File::stat; -use NixManifest; +use Nix::Config; +use Nix::Manifest; my $hashAlgo = "sha256"; @@ -13,7 +14,7 @@ my $tmpDir = tempdir("nix-push.XXXXXX", CLEANUP => 1, TMPDIR => 1) my $nixExpr = "$tmpDir/create-nars.nix"; my $manifest = "$tmpDir/MANIFEST"; -my $curl = "@curl@ --fail --silent"; +my $curl = "$Nix::Config::curl --fail --silent"; my $extraCurlFlags = ${ENV{'CURL_FLAGS'}}; $curl = "$curl $extraCurlFlags" if defined $extraCurlFlags; @@ -107,7 +108,7 @@ foreach my $storePath (@storePaths) { # Construct a Nix expression that creates a Nix archive. my $nixexpr = "((import $dataDir/nix/corepkgs/nar/nar.nix) " . - "{storePath = builtins.storePath \"$storePath\"; system = \"@system@\"; hashAlgo = \"$hashAlgo\";}) "; + "{ storePath = builtins.storePath \"$storePath\"; system = \"@system@\"; hashAlgo = \"$hashAlgo\"; }) "; print NIX $nixexpr; } diff --git a/scripts/update-manifest.pl b/scripts/update-manifest.pl deleted file mode 100755 index 566f6467328d..000000000000 --- a/scripts/update-manifest.pl +++ /dev/null @@ -1,52 +0,0 @@ -#! /usr/bin/perl -w -I. - -use strict; -use readmanifest; - -die unless scalar @ARGV == 2; - -my $cache = $ARGV[0]; -my $manifest = $ARGV[1]; -my %narFiles; -my %patches; - -readManifest $manifest, \%narFiles, \%patches; - -foreach my $storePath (keys %narFiles) { - my $narFileList = $narFiles{$storePath}; - - foreach my $narFile (@{$narFileList}) { - if (!defined $narFile->{size} or - !defined $narFile->{narHash}) - { - $narFile->{url} =~ /\/([^\/]+)$/; - die unless defined $1; - my $fn = "$cache/$1"; - - my @info = stat $fn or die; - $narFile->{size} = $info[7]; - - my $narHash; - my $hashFile = "$fn.NARHASH"; - if (-e $hashFile) { - open HASH, "<$hashFile" or die; - $narHash = <HASH>; - close HASH; - } else { - print "$fn\n"; - $narHash = `bunzip2 < '$fn' | nix-hash --flat /dev/stdin` or die; - open HASH, ">$hashFile" or die; - print HASH $narHash; - close HASH; - } - chomp $narHash; - $narFile->{narHash} = $narHash; - } - } -} - -if (! -e "$manifest.backup") { - system "mv --reply=no '$manifest' '$manifest.backup'"; -} - -writeManifest $manifest, \%narFiles, \%patches; diff --git a/substitute.mk b/substitute.mk index 7da60d0677e3..ede3470073f8 100644 --- a/substitute.mk +++ b/substitute.mk @@ -6,13 +6,13 @@ -e "s^@sysconfdir\@^$(sysconfdir)^g" \ -e "s^@localstatedir\@^$(localstatedir)^g" \ -e "s^@datadir\@^$(datadir)^g" \ + -e "s^@libdir\@^$(libdir)^g" \ -e "s^@libexecdir\@^$(libexecdir)^g" \ -e "s^@storedir\@^$(storedir)^g" \ -e "s^@system\@^$(system)^g" \ -e "s^@shell\@^$(bash)^g" \ -e "s^@curl\@^$(curl)^g" \ -e "s^@bzip2\@^$(bzip2_bin)/bzip2^g" \ - -e "s^@bunzip2\@^$(bzip2_bin)/bunzip2^g" \ -e "s^@bzip2_bin_test\@^$(bzip2_bin_test)^g" \ -e "s^@perl\@^$(perl)^g" \ -e "s^@perlFlags\@^$(perlFlags)^g" \ diff --git a/tests/binary-patching.sh b/tests/binary-patching.sh index 60e57b4b00dc..9866f4f6f26b 100644 --- a/tests/binary-patching.sh +++ b/tests/binary-patching.sh @@ -7,22 +7,22 @@ mkdir -p $TEST_ROOT/cache2 $TEST_ROOT/patches RESULT=$TEST_ROOT/result # Build version 1 and 2 of the "foo" package. -$NIX_BIN_DIR/nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest1 \ +nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest1 \ $($nixbuild -o $RESULT binary-patching.nix --arg version 1) out2=$($nixbuild -o $RESULT binary-patching.nix --arg version 2) -$NIX_BIN_DIR/nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest2 $out2 +nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest2 $out2 out3=$($nixbuild -o $RESULT binary-patching.nix --arg version 3) -$NIX_BIN_DIR/nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest3 $out3 +nix-push --copy $TEST_ROOT/cache2 $TEST_ROOT/manifest3 $out3 rm $RESULT # Generate binary patches. -$NIX_BIN_DIR/nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \ +nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \ file://$TEST_ROOT/patches $TEST_ROOT/manifest1 $TEST_ROOT/manifest2 -$NIX_BIN_DIR/nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \ +nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \ file://$TEST_ROOT/patches $TEST_ROOT/manifest2 $TEST_ROOT/manifest3 grep -q "patch {" $TEST_ROOT/manifest3 @@ -45,7 +45,7 @@ rm $RESULT [ "$(grep ' patch ' $TEST_ROOT/var/log/nix/downloads | wc -l)" -eq 2 ] # Add a patch from version 1 directly to version 3. -$NIX_BIN_DIR/nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \ +nix-generate-patches $TEST_ROOT/cache2 $TEST_ROOT/patches \ file://$TEST_ROOT/patches $TEST_ROOT/manifest1 $TEST_ROOT/manifest3 # Rebuild version 3. This should use the direct patch rather than the diff --git a/tests/common.sh.in b/tests/common.sh.in index b03cd49ec70d..4a2c96daf706 100644 --- a/tests/common.sh.in +++ b/tests/common.sh.in @@ -1,5 +1,7 @@ set -e +export TOP=$(pwd)/.. + export TEST_ROOT=$(pwd)/test-tmp export NIX_STORE_DIR if ! NIX_STORE_DIR=$(readlink -f $TEST_ROOT/store 2> /dev/null); then @@ -15,9 +17,12 @@ export NIX_DB_DIR=$TEST_ROOT/db export NIX_CONF_DIR=$TEST_ROOT/etc export NIX_BIN_DIR=$TEST_ROOT/bin export NIX_LIBEXEC_DIR=$TEST_ROOT/bin +export NIX_MANIFESTS_DIR=$TEST_ROOT/var/nix/manifests export NIX_ROOT_FINDER= export SHARED=$TEST_ROOT/shared +export PATH=$NIX_BIN_DIR:$TOP/scripts:$PATH + export NIX_REMOTE= export REAL_BIN_DIR=@bindir@ @@ -27,10 +32,10 @@ export REAL_DATA_DIR=@datadir@ export REAL_STORE_DIR=@storedir@ export NIX_BUILD_HOOK= export PERL=perl -export TOP=$(pwd)/.. -export bzip2_bin_test="@bzip2_bin_test@" -if test "${bzip2_bin_test:0:1}" != "/"; then - bzip2_bin_test=`pwd`/${bzip2_bin_test} +export PERL5LIB=$TOP/perl/lib +export NIX_BZIP2="@bzip2_bin_test@/bzip2" +if test "${NIX_BZIP2:0:1}" != "/"; then + NIX_BZIP2=`pwd`/${NIX_BZIP2} fi export dot=@dot@ export xmllint="@xmllint@" diff --git a/tests/init.sh b/tests/init.sh index 104da432eaef..0e17740f36d2 100644 --- a/tests/init.sh +++ b/tests/init.sh @@ -29,16 +29,11 @@ ln -s $TOP/scripts/nix-prefetch-url $NIX_BIN_DIR/ ln -s $TOP/scripts/nix-collect-garbage $NIX_BIN_DIR/ ln -s $TOP/scripts/nix-build $NIX_BIN_DIR/ ln -s $TOP/scripts/nix-install-package $NIX_BIN_DIR/ -ln -s $TOP/scripts/nix-push $NIX_BIN_DIR/ ln -s $TOP/scripts/nix-pull $NIX_BIN_DIR/ -ln -s $TOP/scripts/nix-generate-patches $NIX_BIN_DIR/ mkdir $NIX_BIN_DIR/nix -ln -s $bzip2_bin_test/bzip2 $NIX_BIN_DIR/nix/ -ln -s $bzip2_bin_test/bunzip2 $NIX_BIN_DIR/nix/ +ln -s $NIX_BZIP2 $NIX_BIN_DIR/nix/ ln -s $TOP/scripts/copy-from-other-stores.pl $NIX_BIN_DIR/nix/ ln -s $TOP/scripts/download-using-manifests.pl $NIX_BIN_DIR/nix/ -ln -s $TOP/scripts/GeneratePatches.pm $NIX_BIN_DIR/nix/ -ln -s $TOP/scripts/NixManifest.pm $NIX_BIN_DIR/nix/ cat > "$NIX_CONF_DIR"/nix.conf <<EOF gc-keep-outputs = false @@ -53,17 +48,6 @@ cp -pr $TOP/corepkgs $NIX_DATA_DIR/nix/ # (and likely to fail). for i in \ $NIX_DATA_DIR/nix/corepkgs/nar/nar.sh \ - $NIX_BIN_DIR/nix/download-using-manifests.pl \ - $NIX_BIN_DIR/nix/copy-from-other-stores.pl \ - $NIX_BIN_DIR/nix-prefetch-url \ - $NIX_BIN_DIR/nix-collect-garbage \ - $NIX_BIN_DIR/nix-build \ - $NIX_BIN_DIR/nix-install-package \ - $NIX_BIN_DIR/nix-push \ - $NIX_BIN_DIR/nix-pull \ - $NIX_BIN_DIR/nix-generate-patches \ - $NIX_BIN_DIR/nix/NixManifest.pm \ - $NIX_BIN_DIR/nix/GeneratePatches.pm \ ; do sed < $i > $i.tmp \ -e "s^$REAL_BIN_DIR/nix-store^$NIX_BIN_DIR/nix-store^" \ diff --git a/tests/nix-pull.sh b/tests/nix-pull.sh index d2309742d217..9fc3992f6257 100644 --- a/tests/nix-pull.sh +++ b/tests/nix-pull.sh @@ -2,7 +2,7 @@ source common.sh pullCache () { echo "pulling cache..." - $NIX_BIN_DIR/nix-pull file://$TEST_ROOT/manifest + nix-pull file://$TEST_ROOT/manifest } clearStore diff --git a/tests/nix-push.sh b/tests/nix-push.sh index 0a35e3b97ab7..0cef0c22a248 100644 --- a/tests/nix-push.sh +++ b/tests/nix-push.sh @@ -7,5 +7,4 @@ echo "pushing $drvPath" mkdir -p $TEST_ROOT/cache -$NIX_BIN_DIR/nix-push \ - --copy $TEST_ROOT/cache $TEST_ROOT/manifest $drvPath +nix-push --copy $TEST_ROOT/cache $TEST_ROOT/manifest $drvPath |