wrapGAppsHook: Correct wrapProgram invocations

This change fixes several defects in the way `wrapGAppsHook` selected
the executable to wrap.

Previously, it would wrap any top-level files in the target `/bin` and
`/libexec` directories, including directories and non-executable
files.  In addition, it failed to wrap files in subdirectories.

Now, it uses `find` to iterate over these directory hierarchies,
selecting only executable files for wrapping.
This commit is contained in:
Taahir Ahmed 2017-04-15 21:50:13 -05:00
parent 100919ab5b
commit 2cd342cfb3

View File

@ -35,10 +35,16 @@ wrapGAppsHook() {
gappsWrapperArgs+=(--prefix $v : "$dummy") gappsWrapperArgs+=(--prefix $v : "$dummy")
done done
if [ -z "$dontWrapGApps" ]; then if [[ -z "$dontWrapGApps" ]]; then
for i in $prefix/bin/* $prefix/libexec/*; do targetDirs=( "${prefix}/bin" "${prefix}/libexec" )
echo "Wrapping app $i" for targetDir in "${targetDirs[@]}"; do
wrapProgram "$i" "${gappsWrapperArgs[@]}" if [[ -d "${targetDir}" ]]; then
find "${targetDir}" -type f -executable -print0 \
| while IFS= read -r -d '' file; do
echo "Wrapping program ${file}"
wrapProgram "${file}" "${gappsWrapperArgs[@]}"
done
fi
done done
fi fi
} }