3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #24944 from ahmedtd/make-makewrapper-picky

makeWrapper: Fail loudly when misused
This commit is contained in:
Peter Simons 2017-08-08 17:26:38 +02:00 committed by GitHub
commit 67f37b70e8

View file

@ -1,3 +1,12 @@
# Assert that FILE exists and is executable
#
# assertExecutable FILE
assertExecutable() {
local file="$1"
[[ -f "${file}" && -x "${file}" ]] || \
die "Cannot wrap ${file} because it is not an executable file"
}
# construct an executable file that wraps the actual executable
# makeWrapper EXECUTABLE ARGS
@ -24,6 +33,8 @@ makeWrapper() {
local params varName value command separator n fileNames
local argv0 flagsBefore flags
assertExecutable "${file}"
mkdir -p "$(dirname "$wrapper")"
echo "#! $SHELL -e" > "$wrapper"
@ -119,6 +130,9 @@ filterExisting() {
wrapProgram() {
local prog="$1"
local hidden
assertExecutable "${prog}"
hidden="$(dirname "$prog")/.$(basename "$prog")"-wrapped
while [ -e "$hidden" ]; do
hidden="${hidden}_"