Skip to content

Commit

Permalink
Merge pull request #193 from manicmaniac/fix-preinstall-script
Browse files Browse the repository at this point in the history
Fix preinstall script to prevent an effect from meta characters in variables
  • Loading branch information
manicmaniac authored May 18, 2023
2 parents 331f1a8 + 96af4e4 commit 36720e3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Package/Scripts/preinstall
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ get_rpaths() {
developer_dir="$(/usr/bin/xcode-select --print-path)"
if ! is_developer_dir_in_xcode "$developer_dir"; then
# shellcheck disable=SC2016
echo 'error: DEVELOPER_DIR is not in Xcode. Run `xcode-select --switch /path/to/Xcode.app/Contents/Developer` to set it to the correct path.' >&2
/usr/bin/printf 'error: DEVELOPER_DIR is not in Xcode. Run `xcode-select --switch /path/to/Xcode.app/Contents/Developer` to set it to the correct path.\n' >&2
exit 1
fi

if [ -z "$INSTALLER_PAYLOAD_DIR" ]; then
echo 'error: INSTALLER_PAYLOAD_DIR is not set. Do not run this script outside of installer context.' >&2
/usr/bin/printf 'error: INSTALLER_PAYLOAD_DIR is not set. Do not run this script outside of installer context.\n' >&2
exit 1
fi

IFS='
' # newline
for old_rpath in $(get_rpaths "${INSTALLER_PAYLOAD_DIR}/usr/local/bin/xcnew")
do
new_rpath="$(echo "$old_rpath" | /usr/bin/sed -e "s|.*/Contents/Developer|$developer_dir|")"
new_rpath="$(/usr/bin/printf "%s\n" "$old_rpath" | /usr/bin/awk -v developer_dir="$developer_dir" '{sub(".*/Contents/Developer", developer_dir); print}')"
/usr/bin/install_name_tool -rpath "$old_rpath" "$new_rpath" "${INSTALLER_PAYLOAD_DIR}/usr/local/bin/xcnew"
done

0 comments on commit 36720e3

Please sign in to comment.