Created
February 12, 2015 17:32
-
-
Save loderunner/5b7f78f38f655990383f to your computer and use it in GitHub Desktop.
Change ids and install paths relative to @executable_path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USER_PREFIX=/Users | |
LOADER_PATH_PREFIX=@loader_path | |
for f in *.dylib; do | |
old_install_path="$(otool -D "$f" | sed '2q;d' | grep -E "$USER_PREFIX|$LOADER_PATH_PREFIX")" | |
if [ -n "$old_install_path" ]; then | |
new_install_path="$(sed -E "s%($USER_PREFIX|$LOADER_PATH_PREFIX).*%@executable_path/../Frameworks/%" <<< "$old_install_path")""$(basename "$old_install_path")" | |
echo "$old_install_path -> $new_install_path" | |
install_name_tool -id "$new_install_path" "$f" | |
fi | |
for old_install_path in $(otool -L "$f" | grep -E "$USER_PREFIX|$LOADER_PATH_PREFIX" | awk '{print $1}'); do | |
new_install_path="$(sed -E "s%($USER_PREFIX|$LOADER_PATH_PREFIX).*%@executable_path/../Frameworks/%" <<< "$old_install_path")""$(basename "$old_install_path")" | |
echo "$old_install_path -> $new_install_path" | |
install_name_tool -change "$old_install_path" "$new_install_path" "$f" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment