about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2019-02-01 14:20:37 +0100
committerGitHub <noreply@github.com>2019-02-01 14:20:37 +0100
commitd42ef371c9b1b532400b0f2820885e575f4f1617 (patch)
tree7e171e416115f13e16bfa0aa61ef33f3864e8f28 /pkgs/build-support
parentf55f45f273ead5866d32846539546cba8d2d68bc (diff)
parentbbb2f93cee60f21224b16fce2f777f5fe9e21095 (diff)
downloadnixlib-d42ef371c9b1b532400b0f2820885e575f4f1617.tar
nixlib-d42ef371c9b1b532400b0f2820885e575f4f1617.tar.gz
nixlib-d42ef371c9b1b532400b0f2820885e575f4f1617.tar.bz2
nixlib-d42ef371c9b1b532400b0f2820885e575f4f1617.tar.lz
nixlib-d42ef371c9b1b532400b0f2820885e575f4f1617.tar.xz
nixlib-d42ef371c9b1b532400b0f2820885e575f4f1617.tar.zst
nixlib-d42ef371c9b1b532400b0f2820885e575f4f1617.zip
Merge pull request #54909 from tollb/fix/wrap-gapps-hook_unnecessary_symlink_wrap
wrap-gapps-hook.sh: only wrap links when required
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/setup-hooks/wrap-gapps-hook.sh28
1 files changed, 26 insertions, 2 deletions
diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh b/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh
index 25ac12996cc1..b5ceb4a13d85 100644
--- a/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh
+++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh
@@ -36,16 +36,40 @@ wrapGAppsHook() {
   done
 
   if [[ -z "$dontWrapGApps" ]]; then
+    targetDirsThatExist=()
+    targetDirsRealPath=()
+
+    # wrap binaries
     targetDirs=( "${prefix}/bin" "${prefix}/libexec" )
     for targetDir in "${targetDirs[@]}"; do
       if [[ -d "${targetDir}" ]]; then
-        find -L "${targetDir}" -type f -executable -print0 \
+        targetDirsThatExist+=("${targetDir}")
+        targetDirsRealPath+=("$(realpath "${targetDir}")/")
+        find "${targetDir}" -type f -executable -print0 \
           | while IFS= read -r -d '' file; do
-          echo "Wrapping program ${file}"
+          echo "Wrapping program '${file}'"
           wrapProgram "${file}" "${gappsWrapperArgs[@]}"
         done
       fi
     done
+
+    # wrap links to binaries that point outside targetDirs
+    # Note: links to binaries within targetDirs do not need
+    #       to be wrapped as the binaries have already been wrapped
+    if [[ ${#targetDirsThatExist[@]} -ne 0 ]]; then
+      find "${targetDirsThatExist[@]}" -type l -xtype f -executable -print0 \
+        | while IFS= read -r -d '' linkPath; do
+        linkPathReal=$(realpath "${linkPath}")
+        for targetPath in "${targetDirsRealPath[@]}"; do
+          if [[ "$linkPathReal" == "$targetPath"* ]]; then
+            echo "Not wrapping link: '$linkPath' (already wrapped)"
+            continue 2
+          fi
+        done
+        echo "Wrapping link: '$linkPath'"
+        wrapProgram "${linkPath}" "${gappsWrapperArgs[@]}"
+      done
+    fi
   fi
 }