From 0b7e25616262410d35a96d3bdf39a6c204467470 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 26 Oct 2006 22:20:25 +0000 Subject: [PATCH] * Hook variables in the generic builder are now executed using eval. This has a major advantage: you can write hooks directly in Nix expressions. For instance, rather than write a builder like this: source $stdenv/setup postInstall=postInstall postInstall() { ln -sf gzip $out/bin/gunzip ln -sf gzip $out/bin/zcat } genericBuild (the gzip builder), you can just add this attribute to the derivation: postInstall = "ln -sf gzip $out/bin/gunzip; ln -sf gzip $out/bin/zcat"; and so a separate build script becomes unnecessary. This should allow us to get rid of most builders in Nixpkgs. * Allow configure and make arguments to contain whitespace. Previously, you could say, for instance configureFlags="CFLAGS=-O0" but not configureFlags="CFLAGS=-O0 -g" since the `-g' would be interpreted as a separate argument to configure. Now you can say configureFlagsArray=("CFLAGS=-O0 -g") or similarly configureFlagsArray=("CFLAGS=-O0 -g" "LDFLAGS=-L/foo -L/bar") which does the right thing. Idem for makeFlags, installFlags, checkFlags and distFlags. Unfortunately you can't pass arrays to Bash through the environment, so you can't put the array above in a Nix expression, e.g., configureFlagsArray = ["CFLAGS=-O0 -g"]; since it would just be flattened to a since string. However, you can use the inline hooks described above: preConfigure = "configureFlagsArray=(\"CFLAGS=-O0 -g\")"; svn path=/nixpkgs/trunk/; revision=6863 --- pkgs/stdenv/generic/setup.sh | 82 ++++++++++--------------- pkgs/tools/compression/gzip/builder.sh | 9 --- pkgs/tools/compression/gzip/default.nix | 2 +- 3 files changed, 32 insertions(+), 61 deletions(-) delete mode 100644 pkgs/tools/compression/gzip/builder.sh diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 31a173ccafcc..b0301265cfdc 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -62,9 +62,7 @@ fail() { # Allow the caller to augment buildInputs (it's not always possible to # do this before the call to setup.sh, since the PATH is empty at that # point; here we have a basic Unix environment). -if test -n "$addInputsHook"; then - $addInputsHook -fi +eval "$addInputsHook" # Recursively find all build inputs. @@ -319,7 +317,7 @@ unpackFile() { unpackW() { if test -n "$unpackPhase"; then - $unpackPhase + eval "$unpackPhase" return fi @@ -349,7 +347,7 @@ unpackW() { # Find the source directory. if test -n "$setSourceRoot"; then - $setSourceRoot + eval "$setSourceRoot" else sourceRoot= for i in *; do @@ -382,10 +380,8 @@ unpackW() { if test "dontMakeSourcesWritable" != 1; then chmod -R +w $sourceRoot fi - - if test -n "$postUnpack"; then - $postUnpack - fi + + eval "$postUnpack" } @@ -400,7 +396,7 @@ unpackPhase() { patchW() { if test -n "$patchPhase"; then - $patchPhase + eval "$patchPhase" return fi @@ -430,13 +426,11 @@ fixLibtool() { configureW() { if test -n "$configurePhase"; then - $configurePhase + eval "$configurePhase" return fi - if test -n "$preConfigure"; then - $preConfigure - fi + eval "$preConfigure" if test -z "$prefix"; then prefix="$out"; @@ -465,12 +459,10 @@ configureW() { configureFlags="--prefix=$prefix $configureFlags" fi - echo "configure flags: $configureFlags" - $configureScript $configureFlags || fail + echo "configure flags: $configureFlags ${configureFlagsArray[@]}" + $configureScript $configureFlags"${configureFlagsArray[@]}" || fail - if test -n "$postConfigure"; then - $postConfigure - fi + eval "$postConfigure" } @@ -485,20 +477,16 @@ configurePhase() { buildW() { if test -n "$buildPhase"; then - $buildPhase + eval "$buildPhase" return fi - if test -n "$preBuild"; then - $preBuild - fi + eval "$preBuild" - echo "make flags: $makeFlags" - make $makeFlags || fail + echo "make flags: $makeFlags ${makeFlagsArray[@]}" + make $makeFlags "${makeFlagsArray[@]}" || fail - if test -n "$postBuild"; then - $postBuild - fi + eval "$postBuild" } @@ -516,7 +504,7 @@ buildPhase() { checkW() { if test -n "$checkPhase"; then - $checkPhase + eval "$checkPhase" return fi @@ -524,8 +512,8 @@ checkW() { checkTarget="check" fi - echo "check flags: $checkFlags" - make $checkFlags $checkTarget || fail + echo "check flags: $checkFlags ${checkFlagsArray[@]}" + make $checkFlags "${checkFlagsArray[@]}" $checkTarget || fail } @@ -554,19 +542,17 @@ patchELF() { installW() { if test -n "$installPhase"; then - $installPhase + eval "$installPhase" return fi - - if test -n "$preInstall"; then - $preInstall - fi + + eval "$preInstall" ensureDir "$prefix" if test -z "$dontMakeInstall"; then - echo "install flags: $installFlags" - make install $installFlags || fail + echo "install flags: $installFlags ${installFlagsArray[@]}" + make install $installFlags "${installFlagsArray[@]}" || fail fi if test -z "$dontStrip" -a "$NIX_STRIP_DEBUG" = 1; then @@ -583,9 +569,7 @@ installW() { echo "$propagatedBuildInputs" > "$out/nix-support/propagated-build-inputs" fi - if test -n "$postInstall"; then - $postInstall - fi + eval "$postInstall" } @@ -603,20 +587,18 @@ installPhase() { distW() { if test -n "$distPhase"; then - $distPhase + eval "$distPhase" return fi - if test -n "$preDist"; then - $preDist - fi + eval "$preDist" if test -z "$distTarget"; then distTarget="dist" fi - echo "dist flags: $distFlags" - make $distFlags $distTarget || fail + echo "dist flags: $distFlags ${distFlagsArray[@]}" + make $distFlags "${distFlagsArray[@]}" $distTarget || fail if test "$dontCopyDist" != 1; then ensureDir "$out/tarballs" @@ -630,9 +612,7 @@ distW() { cp -pvd $tarballs $out/tarballs fi - if test -n "$postDist"; then - $postDist - fi + eval "$postDist" } @@ -661,7 +641,7 @@ genericBuild() { for i in $phases; do dumpVars - $i + eval "$i" done stopNest diff --git a/pkgs/tools/compression/gzip/builder.sh b/pkgs/tools/compression/gzip/builder.sh deleted file mode 100644 index 9cf502b4330d..000000000000 --- a/pkgs/tools/compression/gzip/builder.sh +++ /dev/null @@ -1,9 +0,0 @@ -source $stdenv/setup - -postInstall=postInstall -postInstall() { - ln -sf gzip $out/bin/gunzip - ln -sf gzip $out/bin/zcat -} - -genericBuild diff --git a/pkgs/tools/compression/gzip/default.nix b/pkgs/tools/compression/gzip/default.nix index 735fd10fd7bb..92cf55f1275b 100644 --- a/pkgs/tools/compression/gzip/default.nix +++ b/pkgs/tools/compression/gzip/default.nix @@ -6,5 +6,5 @@ stdenv.mkDerivation { url = http://nix.cs.uu.nl/dist/tarballs/gzip-1.3.3.tar.gz; md5 = "52eaf713673507d21f7abefee98ba662"; }; - builder = ./builder.sh; + postInstall = "ln -sf gzip $out/bin/gunzip; ln -sf gzip $out/bin/zcat"; }