Skip to content

Commit

Permalink
Handle @rpath in installed names.
Browse files Browse the repository at this point in the history
Convert to @executable_path like prefixes.
  • Loading branch information
jralls committed May 9, 2022
1 parent 6dd89ea commit df5aa76
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
3 changes: 3 additions & 0 deletions bundler/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,11 @@ def fix_rpaths(self, project, target, frameworks = []):
"run-install-name-tool-change.sh")
for prefix in project.get_meta().prefixes:
prefix_path = project.get_prefix(prefix)
bundle_libdir = os.path.join(self.bundledir, 'lib')
call([cmd, target, prefix_path, self.bundledir, "change"])
call([cmd, target, prefix_path, self.bundledir, "id"])
call([cmd, target, '@rpath', bundle_libdir, "change"])
call([cmd, target, '@rpath', bundle_libdir, "id"])
for fw in frameworks:
call([cmd, path, fw.get_name(), fw.get_bundlename(), 'change'])

Expand Down
17 changes: 12 additions & 5 deletions bundler/run-install-name-tool-change.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,23 @@ ACTION=$4

chmod u+w $LIBRARY

if [ "x$ACTION" == "xchange" ]; then
if [ "x$ACTION" = "xchange" ]; then
libs="`otool -L $LIBRARY 2>/dev/null | fgrep compatibility | cut -d\( -f1 | grep $WRONG_PREFIX | sort | uniq`"
for lib in $libs; do
if ! echo $lib | grep --silent "@executable_path" ; then
fixed=`echo $lib | sed -e s,\$WRONG_PREFIX,\$RIGHT_PREFIX,`
fixed=`echo $lib | sed -e s,\${WRONG_PREFIX},\${RIGHT_PREFIX},`
install_name_tool -change $lib $fixed $LIBRARY
fi
done;
elif [ "x$ACTION" == "xid" ]; then
lib="`otool -D $LIBRARY 2>/dev/null | grep ^$WRONG_PREFIX | sed s,\${WRONG_PREFIX},,`"
install_name_tool -id "$RIGHT_PREFIX/$lib" $LIBRARY;
elif [ "x$ACTION" = "xid" ]; then
# echo "$LIBRARY $WRONG_PREFIX to $RIGHT_PREFIX"
lib=$(otool -D "$LIBRARY" 2>/dev/null | grep ^"$WRONG_PREFIX" | sed s,"$WRONG_PREFIX",,)
if [ $lib ]; then
# echo "Rewrite $lib"
install_name_tool -id "${RIGHT_PREFIX}/${lib}" $LIBRARY;
# else
# path=$(otool -D "$LIBRARY" 2>/dev/null | sed -n 2p)
# echo "Empty Result $path"
fi
fi

0 comments on commit df5aa76

Please sign in to comment.