diff options
author | Peter Simons <simons@cryp.to> | 2017-08-08 17:26:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-08 17:26:38 +0200 |
commit | 67f37b70e8eaae8372c05519c43d5a0557ee037b (patch) | |
tree | 31bf1217dc9c2559e52b46b9afea22ffde5372e8 /pkgs/build-support/setup-hooks | |
parent | a6e7dffd1f8e60e852c3de4bf9b153ba874d2823 (diff) | |
parent | e1d46c0c4d3bdb0aa42a04bc2bfcadc641b4ac05 (diff) | |
download | nixpkgs-67f37b70e8eaae8372c05519c43d5a0557ee037b.tar nixpkgs-67f37b70e8eaae8372c05519c43d5a0557ee037b.tar.gz nixpkgs-67f37b70e8eaae8372c05519c43d5a0557ee037b.tar.bz2 nixpkgs-67f37b70e8eaae8372c05519c43d5a0557ee037b.tar.lz nixpkgs-67f37b70e8eaae8372c05519c43d5a0557ee037b.tar.xz nixpkgs-67f37b70e8eaae8372c05519c43d5a0557ee037b.tar.zst nixpkgs-67f37b70e8eaae8372c05519c43d5a0557ee037b.zip |
Merge pull request #24944 from ahmedtd/make-makewrapper-picky
makeWrapper: Fail loudly when misused
Diffstat (limited to 'pkgs/build-support/setup-hooks')
-rw-r--r-- | pkgs/build-support/setup-hooks/make-wrapper.sh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pkgs/build-support/setup-hooks/make-wrapper.sh b/pkgs/build-support/setup-hooks/make-wrapper.sh index ec32cd800e0..82176becf2a 100644 --- a/pkgs/build-support/setup-hooks/make-wrapper.sh +++ b/pkgs/build-support/setup-hooks/make-wrapper.sh @@ -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}_" |