Created
November 29, 2018 04:59
-
-
Save stek29/80a40c4abd7792bc3a71e486fe1862e3 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
set -euo pipefail | |
getlibs() { | |
otool -l "$1" |\ | |
(grep -A2 LC_LOAD_DYLIB || true) |\ | |
(grep name || true) |\ | |
awk '{ print $2 }' |\ | |
(grep '/usr/local' || true) | |
} | |
patchdeps() { | |
getlibs "$1" | while read lib; do | |
BASELIB="$(basename "$lib")" | |
if [ ! -e "$BASELIB" ]; then | |
cp "$lib" "$BASELIB" | |
chmod +w "$BASELIB" | |
install_name_tool -id "@executable_path/$BASELIB" "$BASELIB" | |
patchdeps "$BASELIB" | |
fi | |
install_name_tool -change "$lib" "@executable_path/$BASELIB" "$1" | |
done | |
} | |
chmod +w "$1" | |
patchdeps "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment