Merge pull request #25185 from ahmedtd/fix-makewrapper-unsupported-args

Fix makewrapper unsupported args
This commit is contained in:
Peter Simons 2017-08-08 08:33:56 +02:00 committed by GitHub
commit b196230e71
3 changed files with 36 additions and 24 deletions

View file

@ -0,0 +1,21 @@
# Exit with backtrace and error message
#
# Usage: die "Error message"
die() {
# Let us be a little sloppy with errors, because otherwise the final
# invocation of `caller` below will cause the script to exit.
set +e
# Print our error message
printf "\nBuilder called die: %b\n" "$*"
printf "Backtrace:\n"
# Print a backtrace.
local frame=0
while caller $frame; do
((frame++));
done
printf "\n"
exit 1
}

View file

@ -32,26 +32,20 @@ makeWrapper() {
for ((n = 2; n < ${#params[*]}; n += 1)); do
p="${params[$n]}"
if test "$p" = "--set"; then
if [[ "$p" == "--set" ]]; then
varName="${params[$((n + 1))]}"
value="${params[$((n + 2))]}"
n=$((n + 2))
echo "export $varName=\"$value\"" >> "$wrapper"
fi
if test "$p" = "--unset"; then
elif [[ "$p" == "--unset" ]]; then
varName="${params[$((n + 1))]}"
n=$((n + 1))
echo "unset $varName" >> "$wrapper"
fi
if test "$p" = "--run"; then
elif [[ "$p" == "--run" ]]; then
command="${params[$((n + 1))]}"
n=$((n + 1))
echo "$command" >> "$wrapper"
fi
if test "$p" = "--suffix" -o "$p" = "--prefix"; then
elif [[ ("$p" == "--suffix") || ("$p" == "--prefix") ]]; then
varName="${params[$((n + 1))]}"
separator="${params[$((n + 2))]}"
value="${params[$((n + 3))]}"
@ -63,9 +57,7 @@ makeWrapper() {
echo "export $varName=$value\${$varName:+$separator}\$$varName" >> "$wrapper"
fi
fi
fi
if test "$p" = "--suffix-each"; then
elif [[ "$p" == "--suffix-each" ]]; then
varName="${params[$((n + 1))]}"
separator="${params[$((n + 2))]}"
values="${params[$((n + 3))]}"
@ -73,9 +65,7 @@ makeWrapper() {
for value in $values; do
echo "export $varName=\$$varName\${$varName:+$separator}$value" >> "$wrapper"
done
fi
if test "$p" = "--suffix-contents" -o "$p" = "--prefix-contents"; then
elif [[ ("$p" == "--suffix-contents") || ("$p" == "--prefix-contents") ]]; then
varName="${params[$((n + 1))]}"
separator="${params[$((n + 2))]}"
fileNames="${params[$((n + 3))]}"
@ -87,17 +77,15 @@ makeWrapper() {
echo "export $varName=$(cat "$fileName")\${$varName:+$separator}\$$varName" >> "$wrapper"
fi
done
fi
if test "$p" = "--add-flags"; then
elif [[ "$p" == "--add-flags" ]]; then
flags="${params[$((n + 1))]}"
n=$((n + 1))
flagsBefore="$flagsBefore $flags"
fi
if test "$p" = "--argv0"; then
elif [[ "$p" == "--argv0" ]]; then
argv0="${params[$((n + 1))]}"
n=$((n + 1))
else
die "makeWrapper doesn't understand the arg $p"
fi
done
@ -138,5 +126,5 @@ wrapProgram() {
mv "$prog" "$hidden"
# Silence warning about unexpanded $0:
# shellcheck disable=SC2016
makeWrapper "$hidden" "$prog" --argv0 '$0' "$@"
makeWrapper "$hidden" "$prog" --argv0 '$0' "${@:2}"
}

View file

@ -100,6 +100,8 @@ with pkgs;
diffPlugins = (callPackage ../build-support/plugins.nix {}).diffPlugins;
dieHook = makeSetupHook {} ../build-support/setup-hooks/die.sh;
dockerTools = callPackage ../build-support/docker { };
docker_compose = pythonPackages.docker_compose;
@ -287,7 +289,8 @@ with pkgs;
inherit contents compressor prepend;
};
makeWrapper = makeSetupHook { } ../build-support/setup-hooks/make-wrapper.sh;
makeWrapper = makeSetupHook { deps = [ dieHook ]; }
../build-support/setup-hooks/make-wrapper.sh;
makeModulesClosure = { kernel, rootModules, allowMissing ? false }:
callPackage ../build-support/kernel/modules-closure.nix {