summary refs log tree commit diff
path: root/pkgs/build-support/setup-hooks
diff options
context:
space:
mode:
authorPeter Simons <simons@cryp.to>2017-08-08 17:26:38 +0200
committerGitHub <noreply@github.com>2017-08-08 17:26:38 +0200
commit67f37b70e8eaae8372c05519c43d5a0557ee037b (patch)
tree31bf1217dc9c2559e52b46b9afea22ffde5372e8 /pkgs/build-support/setup-hooks
parenta6e7dffd1f8e60e852c3de4bf9b153ba874d2823 (diff)
parente1d46c0c4d3bdb0aa42a04bc2bfcadc641b4ac05 (diff)
downloadnixlib-67f37b70e8eaae8372c05519c43d5a0557ee037b.tar
nixlib-67f37b70e8eaae8372c05519c43d5a0557ee037b.tar.gz
nixlib-67f37b70e8eaae8372c05519c43d5a0557ee037b.tar.bz2
nixlib-67f37b70e8eaae8372c05519c43d5a0557ee037b.tar.lz
nixlib-67f37b70e8eaae8372c05519c43d5a0557ee037b.tar.xz
nixlib-67f37b70e8eaae8372c05519c43d5a0557ee037b.tar.zst
nixlib-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.sh14
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 ec32cd800e0e..82176becf2a3 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}_"