Merge pull request #54909 from tollb/fix/wrap-gapps-hook_unnecessary_symlink_wrap
wrap-gapps-hook.sh: only wrap links when required
This commit is contained in:
commit
d42ef371c9
@ -36,16 +36,40 @@ wrapGAppsHook() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z "$dontWrapGApps" ]]; then
|
if [[ -z "$dontWrapGApps" ]]; then
|
||||||
|
targetDirsThatExist=()
|
||||||
|
targetDirsRealPath=()
|
||||||
|
|
||||||
|
# wrap binaries
|
||||||
targetDirs=( "${prefix}/bin" "${prefix}/libexec" )
|
targetDirs=( "${prefix}/bin" "${prefix}/libexec" )
|
||||||
for targetDir in "${targetDirs[@]}"; do
|
for targetDir in "${targetDirs[@]}"; do
|
||||||
if [[ -d "${targetDir}" ]]; then
|
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
|
| while IFS= read -r -d '' file; do
|
||||||
echo "Wrapping program ${file}"
|
echo "Wrapping program '${file}'"
|
||||||
wrapProgram "${file}" "${gappsWrapperArgs[@]}"
|
wrapProgram "${file}" "${gappsWrapperArgs[@]}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
done
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user