diff options
Diffstat (limited to 'nixpkgs/pkgs/build-support/setup-hooks')
3 files changed, 35 insertions, 4 deletions
diff --git a/nixpkgs/pkgs/build-support/setup-hooks/fix-darwin-dylib-names.sh b/nixpkgs/pkgs/build-support/setup-hooks/fix-darwin-dylib-names.sh index 1b36f5f555da..af2ff0cc9662 100644 --- a/nixpkgs/pkgs/build-support/setup-hooks/fix-darwin-dylib-names.sh +++ b/nixpkgs/pkgs/build-support/setup-hooks/fix-darwin-dylib-names.sh @@ -23,7 +23,14 @@ fixDarwinDylibNames() { for fn in "$@"; do if [ -L "$fn" ]; then continue; fi echo "$fn: fixing dylib" - install_name_tool -id "$fn" "${flags[@]}" "$fn" + int_out=$(install_name_tool -id "$fn" "${flags[@]}" "$fn" 2>&1) + result=$? + if [ "$result" -ne 0 ] && + ! grep "shared library stub file and can't be changed" <<< "$out" + then + echo "$int_out" >&2 + exit "$result" + fi done } diff --git a/nixpkgs/pkgs/build-support/setup-hooks/make-wrapper.sh b/nixpkgs/pkgs/build-support/setup-hooks/make-wrapper.sh index bc12be0fa36c..06891893e8c1 100644 --- a/nixpkgs/pkgs/build-support/setup-hooks/make-wrapper.sh +++ b/nixpkgs/pkgs/build-support/setup-hooks/make-wrapper.sh @@ -8,7 +8,7 @@ assertExecutable() { } # construct an executable file that wraps the actual executable -# makeWrapper EXECUTABLE ARGS +# makeWrapper EXECUTABLE OUT_PATH ARGS # ARGS: # --argv0 NAME : set name of executed process to NAME diff --git a/nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh b/nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh index 25ac12996cc1..b5ceb4a13d85 100644 --- a/nixpkgs/pkgs/build-support/setup-hooks/wrap-gapps-hook.sh +++ b/nixpkgs/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 } |