2021-11-15 17:15:59 +01:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
2021-11-15 17:20:06 +01:00
|
|
|
# Options
|
2021-11-15 17:15:59 +01:00
|
|
|
WANTED_LIB=$1
|
|
|
|
NEW_PATH=$2
|
|
|
|
EXEC=$3
|
|
|
|
|
2021-11-15 17:20:06 +01:00
|
|
|
# Function to extract the first element of a space seperated list
|
2021-11-15 17:15:59 +01:00
|
|
|
get_first_arg() {
|
|
|
|
echo $1
|
|
|
|
}
|
|
|
|
|
2021-11-15 17:20:06 +01:00
|
|
|
# Get current path
|
|
|
|
CURRENT_PATH=$(get_first_arg $(otool -L $EXEC | grep $WANTED_LIB))
|
2021-11-15 17:15:59 +01:00
|
|
|
|
2021-11-16 14:18:33 -06:00
|
|
|
# Change to the new path if found
|
|
|
|
if [ ! -z "$CURRENT_PATH" ]; then
|
|
|
|
install_name_tool -change $CURRENT_PATH $NEW_PATH $EXEC
|
|
|
|
fi
|