stdenv: Store one package per line in nix-support/propagated-*

This makes those files a bit easier to read. Also, for what it's worth,
it brings us one baby step closer to handling spaces in store paths.

Also, I optimized handling of many transitive deps with read. Probably,
not very beneficial, but nice to enforce the pkg-per-line structure.
Doing so let me find much dubious code and fix it.

Two misc notes:

 - `propagated-user-env-packages` also needed to be adjusted as
   sometimes it is copied to/from the propagated input files.

 - `local fd` should ensure that file descriptors aren't clobbered
   during recursion.
This commit is contained in:
John Ericson
2017-07-10 13:32:13 -04:00
parent f385e224e5
commit 3cb745d5a6
15 changed files with 31 additions and 22 deletions
+14 -6
View File
@@ -215,6 +215,11 @@ 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.
@@ -300,9 +305,12 @@ findInputs() {
fi
if [ -f "$pkg/nix-support/$propagatedBuildInputsFile" ]; then
for i in $(cat "$pkg/nix-support/$propagatedBuildInputsFile"); do
findInputs "$i" $var $propagatedBuildInputsFile
local fd pkgNext
exec {fd}<"$pkg/nix-support/$propagatedBuildInputsFile"
while IFS= read -r -u $fd pkgNext; do
findInputs "$pkgNext" $var $propagatedBuildInputsFile
done
exec {fd}<&-
fi
}
@@ -794,17 +802,17 @@ fixupPhase() {
fi
if [ -n "$propagated" ]; then
mkdir -p "${!outputDev}/nix-support"
echo "$propagated" > "${!outputDev}/nix-support/propagated-native-build-inputs"
printLines $propagated > "${!outputDev}/nix-support/propagated-native-build-inputs"
fi
else
if [ -n "$propagatedBuildInputs" ]; then
mkdir -p "${!outputDev}/nix-support"
echo "$propagatedBuildInputs" > "${!outputDev}/nix-support/propagated-build-inputs"
printLines $propagatedBuildInputs > "${!outputDev}/nix-support/propagated-build-inputs"
fi
if [ -n "$propagatedNativeBuildInputs" ]; then
mkdir -p "${!outputDev}/nix-support"
echo "$propagatedNativeBuildInputs" > "${!outputDev}/nix-support/propagated-native-build-inputs"
printLines $propagatedNativeBuildInputs > "${!outputDev}/nix-support/propagated-native-build-inputs"
fi
fi
@@ -817,7 +825,7 @@ fixupPhase() {
if [ -n "$propagatedUserEnvPkgs" ]; then
mkdir -p "${!outputBin}/nix-support"
echo "$propagatedUserEnvPkgs" > "${!outputBin}/nix-support/propagated-user-env-packages"
printLines $propagatedUserEnvPkgs > "${!outputBin}/nix-support/propagated-user-env-packages"
fi
runHook postFixup