Created
March 26, 2013 06:16
-
-
Save eckrel/5243495 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
#!/bin/sh | |
FIND_PYTHON_PATH=~/.pyenv/versions/anaconda | |
echo "where is anaconda path [${FIND_PYTHON_PATH}]: " | |
read INPUT | |
if [ "$INPUT" != "" ] ; then | |
FIND_PYTHON_PATH="$INPUT" | |
fi | |
OPENCV_LIB_PATH=~/lib/opencv/lib | |
echo "where is opencv lib path [${OPENCV_LIB_PATH}]" | |
read INPUT | |
if [ "$INPUT" != "" ] ; then | |
OPENCV_LIB_PATH="$INPUT" | |
fi | |
echo "find files in $OPENCV_LIB_PATH ..." | |
libs_opencv=(`find $OPENCV_LIB_PATH -name "*.dylib" -type f`) | |
libs_cv2so=(`find $FIND_PYTHON_PATH -name cv2.so -type f`) | |
# libs_all=(${libs_opencv[@]} ${libs_cv2so[@]}) | |
echo "== fixed files are ==" | |
for item in "${libs_opencv[@]}"; do echo "$item"; done | |
echo | |
echo | |
echo "exec OK? [y/N]: " | |
read INPUT | |
if [ "$INPUT" != "y" ]; then | |
exit | |
fi | |
echo "== execution ==" | |
for item in "${libs_opencv[@]}"; do | |
# backup | |
cp $item ${item}.orig | |
current_path=`otool -D $item | grep "lib/libopencv_.*\.dylib$" | head -1 | awk '{print \$1}'` | |
path_name=${current_path##*/} | |
next_path="@loader_path/${path_name}" | |
while [ "$current_path" != "" ]; do | |
install_name_tool -id $next_path $item | |
current_path=`otool -D $item | grep "lib/libopencv_.*\.dylib$" | head -1 | awk '{print \$1}'` | |
path_name=${current_path##*/} | |
next_path="@loader_path/${path_name}" | |
done | |
# fix id? | |
current_path=`otool -L $item | grep "\tlib/libopencv_.*\.dylib " | head -1 | awk '{print \$1}'` | |
path_name=${current_path##*/} | |
next_path="@loader_path/${path_name}" | |
while [ "$current_path" != "" ]; do | |
install_name_tool -change $current_path $next_path $item | |
current_path=`otool -L $item | grep "\tlib/libopencv_.*\.dylib " | head -1 | awk '{print \$1}'` | |
path_name=${current_path##*/} | |
next_path="@loader_path/${path_name}" | |
done | |
cp $item $FIND_PYTHON_PATH/lib/ | |
echo "$item: FIXED" | |
done | |
for item in "${libs_cv2so[@]}"; do | |
cp $item ${item}.orig | |
# fix id? | |
current_path=`otool -L $item | grep "\tlib/libopencv_.*\.dylib " | head -1 | awk '{print \$1}'` | |
path_name=${current_path##*/} | |
next_path="@loader_path/../../${path_name}" | |
while [ "$current_path" != "" ]; do | |
install_name_tool -change $current_path $next_path $item | |
current_path=`otool -L $item | grep "\tlib/libopencv_.*\.dylib " | head -1 | awk '{print \$1}'` | |
path_name=${current_path##*/} | |
next_path="@loader_path/../../${path_name}" | |
done | |
echo "$item: FIXED" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment