From b087618ac06256cb3c06278e7eaba45841f4ea91 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 24 Jul 2017 00:53:13 -0400 Subject: [PATCH] Revert "stdenv: Store one package per line in nix-support/propagated-*" As @oxij points out in [1], this breakage is especially serious because it changes the contents of built environments without a corresonding change in their hashes. Also, the revert is easier than I thought. This reverts commit 3cb745d5a69018829ac15f7d5a508135f6bda123. [1]: https://github.com/NixOS/nixpkgs/pull/27427#issuecomment-317293040 --- pkgs/build-support/cc-wrapper/default.nix | 4 ++-- pkgs/build-support/gcc-wrapper-old/builder.sh | 2 +- .../setup-hooks/multiple-outputs.sh | 2 +- pkgs/build-support/trivial-builders.nix | 2 +- .../desktops/kde-4.14/kde-package/default.nix | 2 +- .../compilers/openjdk-darwin/8.nix | 2 +- .../compilers/openjdk-darwin/default.nix | 2 +- pkgs/development/compilers/openjdk/7.nix | 2 +- pkgs/development/compilers/openjdk/8.nix | 2 +- .../compilers/oraclejdk/jdk-linux-base.nix | 2 +- pkgs/development/compilers/zulu/default.nix | 2 +- .../haskell-modules/generic-builder.nix | 2 +- pkgs/misc/misc.nix | 2 +- pkgs/stdenv/generic/builder.sh | 5 ++--- pkgs/stdenv/generic/setup.sh | 20 ++++++------------- 15 files changed, 22 insertions(+), 31 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 37d62891ecfc..676fbd006881 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -275,9 +275,9 @@ stdenv.mkDerivation { # Propagate the wrapped cc so that if you install the wrapper, # you get tools like gcov, the manpages, etc. as well (including # for binutils and Glibc). - printLines ${cc} ${cc.man or ""} ${binutils_bin} ${if libc == null then "" else libc_bin} > $out/nix-support/propagated-user-env-packages + echo ${cc} ${cc.man or ""} ${binutils_bin} ${if libc == null then "" else libc_bin} > $out/nix-support/propagated-user-env-packages - printLines ${toString extraPackages} > $out/nix-support/propagated-native-build-inputs + echo ${toString extraPackages} > $out/nix-support/propagated-native-build-inputs '' + optionalString (targetPlatform.isSunOS && nativePrefix != "") '' diff --git a/pkgs/build-support/gcc-wrapper-old/builder.sh b/pkgs/build-support/gcc-wrapper-old/builder.sh index 4f141f6b8f21..a8e8a370ec0d 100644 --- a/pkgs/build-support/gcc-wrapper-old/builder.sh +++ b/pkgs/build-support/gcc-wrapper-old/builder.sh @@ -211,5 +211,5 @@ cp -p $utils $out/nix-support/utils.sh # tools like gcov, the manpages, etc. as well (including for binutils # and Glibc). if test -z "$nativeTools"; then - printLines $gcc $binutils $libc $libc_bin > $out/nix-support/propagated-user-env-packages + echo $gcc $binutils $libc $libc_bin > $out/nix-support/propagated-user-env-packages fi diff --git a/pkgs/build-support/setup-hooks/multiple-outputs.sh b/pkgs/build-support/setup-hooks/multiple-outputs.sh index 9abf50f6ea47..62a6491b8dc0 100644 --- a/pkgs/build-support/setup-hooks/multiple-outputs.sh +++ b/pkgs/build-support/setup-hooks/multiple-outputs.sh @@ -202,7 +202,7 @@ _multioutPropagateDev() { mkdir -p "${!propagaterOutput}"/nix-support for output in $propagatedBuildOutputs; do - echo "${!output}" >> "${!propagaterOutput}"/nix-support/$propagatedBuildInputsFile + echo -n " ${!output}" >> "${!propagaterOutput}"/nix-support/$propagatedBuildInputsFile done } diff --git a/pkgs/build-support/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix index 1ee1fe8298fd..4debd9636396 100644 --- a/pkgs/build-support/trivial-builders.nix +++ b/pkgs/build-support/trivial-builders.nix @@ -84,7 +84,7 @@ rec { mkdir -p $out/nix-support cp ${script} $out/nix-support/setup-hook '' + lib.optionalString (deps != []) '' - printLines ${toString deps} > $out/nix-support/propagated-native-build-inputs + echo ${toString deps} > $out/nix-support/propagated-native-build-inputs '' + lib.optionalString (substitutions != {}) '' substituteAll ${script} $out/nix-support/setup-hook ''); diff --git a/pkgs/desktops/kde-4.14/kde-package/default.nix b/pkgs/desktops/kde-4.14/kde-package/default.nix index 3637d9f89cb2..d5de6f5f6bc1 100644 --- a/pkgs/desktops/kde-4.14/kde-package/default.nix +++ b/pkgs/desktops/kde-4.14/kde-package/default.nix @@ -86,7 +86,7 @@ rec { };}) '' mkdir -pv $out/nix-support - printLines ${toString list} | tee $out/nix-support/propagated-user-env-packages + echo "${toString list}" | tee $out/nix-support/propagated-user-env-packages ''; # Given manifest module data, return the module diff --git a/pkgs/development/compilers/openjdk-darwin/8.nix b/pkgs/development/compilers/openjdk-darwin/8.nix index 691829c7788a..51effd2c7841 100644 --- a/pkgs/development/compilers/openjdk-darwin/8.nix +++ b/pkgs/development/compilers/openjdk-darwin/8.nix @@ -33,7 +33,7 @@ let # any package that depends on the JRE has $CLASSPATH set up # properly. mkdir -p $out/nix-support - printLines ${setJavaClassPath} > $out/nix-support/propagated-native-build-inputs + echo -n "${setJavaClassPath}" > $out/nix-support/propagated-native-build-inputs install_name_tool -change /usr/X11/lib/libfreetype.6.dylib ${freetype}/lib/libfreetype.6.dylib $out/jre/lib/libfontmanager.dylib diff --git a/pkgs/development/compilers/openjdk-darwin/default.nix b/pkgs/development/compilers/openjdk-darwin/default.nix index 8ce0835fcb69..10a9eb2b3666 100644 --- a/pkgs/development/compilers/openjdk-darwin/default.nix +++ b/pkgs/development/compilers/openjdk-darwin/default.nix @@ -23,7 +23,7 @@ let # any package that depends on the JRE has $CLASSPATH set up # properly. mkdir -p $out/nix-support - printLines ${setJavaClassPath} > $out/nix-support/propagated-native-build-inputs + echo -n "${setJavaClassPath}" > $out/nix-support/propagated-native-build-inputs install_name_tool -change /usr/X11/lib/libfreetype.6.dylib ${freetype}/lib/libfreetype.6.dylib $out/jre/lib/libfontmanager.dylib diff --git a/pkgs/development/compilers/openjdk/7.nix b/pkgs/development/compilers/openjdk/7.nix index 9ef7d26b2efe..6dcbb0a330f1 100644 --- a/pkgs/development/compilers/openjdk/7.nix +++ b/pkgs/development/compilers/openjdk/7.nix @@ -190,7 +190,7 @@ let # any package that depends on the JRE has $CLASSPATH set up # properly. mkdir -p $jre/nix-support - printLines ${setJavaClassPath} > $jre/nix-support/propagated-native-build-inputs + echo -n "${setJavaClassPath}" > $jre/nix-support/propagated-native-build-inputs # Set JAVA_HOME automatically. mkdir -p $out/nix-support diff --git a/pkgs/development/compilers/openjdk/8.nix b/pkgs/development/compilers/openjdk/8.nix index 7c50872ebe59..7977881d5f6d 100644 --- a/pkgs/development/compilers/openjdk/8.nix +++ b/pkgs/development/compilers/openjdk/8.nix @@ -202,7 +202,7 @@ let # any package that depends on the JRE has $CLASSPATH set up # properly. mkdir -p $jre/nix-support - printLines ${setJavaClassPath} > $jre/nix-support/propagated-native-build-inputs + echo -n "${setJavaClassPath}" > $jre/nix-support/propagated-native-build-inputs # Set JAVA_HOME automatically. mkdir -p $out/nix-support diff --git a/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix b/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix index 08fd724f7733..6db0029730a0 100644 --- a/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix +++ b/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix @@ -165,7 +165,7 @@ let result = stdenv.mkDerivation rec { ln -s $jrePath/lib/${architecture}/libnpjp2.so $jrePath/lib/${architecture}/plugins mkdir -p $out/nix-support - printLines ${setJavaClassPath} > $out/nix-support/propagated-native-build-inputs + echo -n "${setJavaClassPath}" > $out/nix-support/propagated-native-build-inputs # Set JAVA_HOME automatically. cat <> $out/nix-support/setup-hook diff --git a/pkgs/development/compilers/zulu/default.nix b/pkgs/development/compilers/zulu/default.nix index 03be4ee8a0b9..c4cdf70f14ac 100644 --- a/pkgs/development/compilers/zulu/default.nix +++ b/pkgs/development/compilers/zulu/default.nix @@ -54,7 +54,7 @@ in stdenv.mkDerivation rec { find $out -name "*.so" -exec patchelf --set-rpath "$rpath" {} \; mkdir -p $out/nix-support - printLines ${setJavaClassPath} > $out/nix-support/propagated-native-build-inputs + echo -n "${setJavaClassPath}" > $out/nix-support/propagated-native-build-inputs # Set JAVA_HOME automatically. cat <> $out/nix-support/setup-hook diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index e097fd5af33e..97a3adaf220f 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -311,7 +311,7 @@ stdenv.mkDerivation ({ ${optionalString isGhcjs '' for exeDir in "$out/bin/"*.jsexe; do exe="''${exeDir%.jsexe}" - printLines '#!${nodejs}/bin/node' > "$exe" + printf '%s\n' '#!${nodejs}/bin/node' > "$exe" cat "$exeDir/all.js" >> "$exe" chmod +x "$exe" done diff --git a/pkgs/misc/misc.nix b/pkgs/misc/misc.nix index 6e8c6f4486f1..6357c4e6f905 100644 --- a/pkgs/misc/misc.nix +++ b/pkgs/misc/misc.nix @@ -23,7 +23,7 @@ in */ collection = {list, name} : runCommand "collection-${name}" {} '' mkdir -p $out/nix-support - printLines ${builtins.toString list} > $out/nix-support/propagated-user-env-packages + echo ${builtins.toString list} > $out/nix-support/propagated-user-env-packages ''; /* creates a derivation symlinking references C/C++ libs into one include and lib directory called $out/cdt-envs/${name} diff --git a/pkgs/stdenv/generic/builder.sh b/pkgs/stdenv/generic/builder.sh index f8c0fd44ac78..a46c46c2db50 100644 --- a/pkgs/stdenv/generic/builder.sh +++ b/pkgs/stdenv/generic/builder.sh @@ -1,3 +1,4 @@ +export PATH= for i in $initialPath; do if [ "$i" = / ]; then i=; fi PATH=$PATH${PATH:+:}$i/bin @@ -14,6 +15,4 @@ cat "$setup" >> $out/setup # Allow the user to install stdenv using nix-env and get the packages # in stdenv. mkdir $out/nix-support -if [ "$propagatedUserEnvPkgs" ]; then - printf '%s\n' $propagatedUserEnvPkgs > $out/nix-support/propagated-user-env-packages -fi +echo $propagatedUserEnvPkgs > $out/nix-support/propagated-user-env-packages diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index de94565ed6d7..e5d2ba8682de 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -215,11 +215,6 @@ isScript() { if [[ "$magic" =~ \#! ]]; then return 0; else return 1; fi } -# printf unfortunately will print a trailing newline regardless -printLines() { - [[ $# -gt 0 ]] || return 0 - printf '%s\n' "$@" -} ###################################################################### # Initialisation. @@ -305,12 +300,9 @@ findInputs() { fi if [ -f "$pkg/nix-support/$propagatedBuildInputsFile" ]; then - local fd pkgNext - exec {fd}<"$pkg/nix-support/$propagatedBuildInputsFile" - while IFS= read -r -u $fd pkgNext; do - findInputs "$pkgNext" $var $propagatedBuildInputsFile + for i in $(cat "$pkg/nix-support/$propagatedBuildInputsFile"); do + findInputs "$i" $var $propagatedBuildInputsFile done - exec {fd}<&- fi } @@ -802,17 +794,17 @@ fixupPhase() { fi if [ -n "$propagated" ]; then mkdir -p "${!outputDev}/nix-support" - printLines $propagated > "${!outputDev}/nix-support/propagated-native-build-inputs" + echo "$propagated" > "${!outputDev}/nix-support/propagated-native-build-inputs" fi else if [ -n "$propagatedBuildInputs" ]; then mkdir -p "${!outputDev}/nix-support" - printLines $propagatedBuildInputs > "${!outputDev}/nix-support/propagated-build-inputs" + echo "$propagatedBuildInputs" > "${!outputDev}/nix-support/propagated-build-inputs" fi if [ -n "$propagatedNativeBuildInputs" ]; then mkdir -p "${!outputDev}/nix-support" - printLines $propagatedNativeBuildInputs > "${!outputDev}/nix-support/propagated-native-build-inputs" + echo "$propagatedNativeBuildInputs" > "${!outputDev}/nix-support/propagated-native-build-inputs" fi fi @@ -825,7 +817,7 @@ fixupPhase() { if [ -n "$propagatedUserEnvPkgs" ]; then mkdir -p "${!outputBin}/nix-support" - printLines $propagatedUserEnvPkgs > "${!outputBin}/nix-support/propagated-user-env-packages" + echo "$propagatedUserEnvPkgs" > "${!outputBin}/nix-support/propagated-user-env-packages" fi runHook postFixup