diff options
author | Guy Harris <guy@alum.mit.edu> | 2013-07-13 22:43:35 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2013-07-13 22:43:35 +0000 |
commit | bc239a7286a428efb02f2ef76d2c528ccfa9abd0 (patch) | |
tree | a68816f408a93204ed96256747ac8740e05d80a2 /packaging/macosx | |
parent | 94f44f76011dd9fad48c3e5fc2629e3cd11e0d5c (diff) |
On OS X, set the rpath for executables to include
@executable_path/../lib as well as /usr/local/lib, so we can use @rpath
in the install names in the executables and libraries in the application
bundle.
Have the osx-app.sh script tweak all references to libraries from
/usr/local/lib in all executables, libraries, and plugins in the app
bundle to use @rpath. (The "all" is important; it fixes the GTK+ crash
mentioned in the comment in osx-app.sh. The notion of doing all of them
came from the osx-app.sh script in a newer version of Inkscape.)
This renders the setting of DYLD_LIBRARY_PATH in the wrapper scripts in
the bundle unnecessary; remove it. (Ideally, we should try to get rid
of the wrapper scripts entirely, but that might have to wait for us to
switch to using Qt.)
svn path=/trunk/; revision=50560
Diffstat (limited to 'packaging/macosx')
-rwxr-xr-x | packaging/macosx/Resources/bin/wireshark | 2 | ||||
-rwxr-xr-x | packaging/macosx/osx-app.sh | 156 |
2 files changed, 116 insertions, 42 deletions
diff --git a/packaging/macosx/Resources/bin/wireshark b/packaging/macosx/Resources/bin/wireshark index ce882f051d..cc347ac61e 100755 --- a/packaging/macosx/Resources/bin/wireshark +++ b/packaging/macosx/Resources/bin/wireshark @@ -28,7 +28,7 @@ APPNAME=`basename "$0"` # MacPorts (former DarwinPorts) export PATH="/opt/local/bin:/sw/bin/:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/local/bin:$CWD:$PATH" -export DYLD_LIBRARY_PATH="$TOP/lib" +# export DYLD_LIBRARY_PATH="$TOP/lib" export WIRESHARK_DATA_DIR="$TOP/share/wireshark" export WIRESHARK_PLUGIN_DIR="$TOP/lib/wireshark/plugins" diff --git a/packaging/macosx/osx-app.sh b/packaging/macosx/osx-app.sh index 56f4a74189..f9374cdb46 100755 --- a/packaging/macosx/osx-app.sh +++ b/packaging/macosx/osx-app.sh @@ -380,47 +380,121 @@ if [ "$strip" = "true" ]; then strip -ur "$binpath" fi -# NOTE: This works for all the dylibs but causes GTK to crash at startup. -# Instead we leave them with their original install_names and set -# DYLD_LIBRARY_PATH within the app bundle before running Wireshark. -# XXX - is that because some plugins need fixing? +# NOTE: we must rpathify *all* files, *including* plugins for GTK+ etc., +# to keep GTK+ from crashing at startup. # -# fixlib () { -# # Fix a given executable or library to be relocatable -# if [ ! -d "$1" ]; then -# echo $1 -# libs="`otool -L $1 | egrep -v '/System|/usr/lib|/opt' | fgrep compatibility | cut -d\( -f1`" -# for lib in $libs; do -# echo " $lib" -# base=`echo $lib | awk -F/ '{print $NF}'` -# first=`echo $lib | cut -d/ -f1-3` -# to=@rpath/$base -# if [ $first != /usr/lib -a $first != /usr/X11R6 ]; then -# /usr/bin/install_name_tool -change $lib $to $1 -# if [ "`echo $lib | fgrep libcrypto`" = "" ]; then -# /usr/bin/install_name_tool -id $to ../lib/$base -# for ll in $libs; do -# base=`echo $ll | awk -F/ '{print $NF}'` -# first=`echo $ll | cut -d/ -f1-3` -# to=@rpath/$base -# if [ $first != /usr/lib -a $first != /usr/X11R6 -a "`echo $ll | fgrep libcrypto`" = "" ]; then -# /usr/bin/install_name_tool -change $ll $to ../lib/$base -# fi -# done -# fi -# fi -# done -# fi -# } -# -# Fix package deps -# (cd "$package/Contents/Resources/bin" -# for file in *; do -# fixlib "$file" -# done -# cd ../lib -# for file in *; do -# fixlib "$file" -# done) +rpathify_file () { + # Fix a given executable, library, or plugin to be relocatable + if [ ! -d "$1" ]; then + # + # OK, what type of file is this? + # + filetype=`otool -hv "$1" | sed -n '4p' | awk '{print $5}'` + case "$filetype" in + + EXECUTE|DYLIB|BUNDLE) + # + # Executable, library, or plugin. (Plugins + # can be either DYLIB or BUNDLE; shared + # libraries are DYLIB.) + # + # For DYLIB and BUNDLE, fix the shared + # library identification. + # + if [[ "$filetype" = "DYLIB" || "$filetype" = "BUNDLE" ]]; then + echo "Changing shared library identification of $1" + base=`echo $1 | awk -F/ '{print $NF}'` + # + # The library will end up in a directory in + # the rpath; this is what we should change its + # ID to. + # + to=@rpath/$base + /usr/bin/install_name_tool -id $to $1 + fi + + # + # Get the list of dynamic libraries on which this + # file depends, and select only the libraries that + # are in $LIBPREFIX, as those are the only ones + # that we'll be shipping in the app bundle; the + # other libraries are system-supplied or supplied + # as part of X11, will be expected to be on the + # system on which the bundle will be installed, + # and should be referred to by their full pathnames. + # + libs="`otool -L $1 | egrep "$LIBPREFIX.* \(compatibility" | cut -d\( -f1`" + for lib in $libs; do + # + # Get the file name of the library. + # + base=`echo $lib | awk -F/ '{print $NF}'` + # + # The library will end up in a directory in + # the rpath; this is what we should change its + # file name to. + # + to=@rpath/$base + # + # Change the reference to that library. + # + echo "Changing reference to $lib in $1" + /usr/bin/install_name_tool -change $lib $to $1 + done + ;; + esac + fi +} + +rpathify_dir () { + # + # Make sure we *have* that directory + # + if [ -d "$1" ]; then + (cd "$1" + # + # Make sure we *have* files to fix + # + files=`ls $2 2>/dev/null` + if [ ! -z "$files" ]; then + for file in $files; do + rpathify_file "$file" "`pwd`" + done + fi + ) + fi +} + +rpathify_files () { + # + # Fix package deps + # + rpathify_dir "$pkglib" "*.dylib" + rpathify_dir "$pkglib/gtk-2.0/$gtk_version/loaders" "*.so" + rpathify_dir "$pkglib/gtk-2.0/$gtk_version/engines" "*.so" + rpathify_dir "$pkglib/gtk-2.0/$gtk_version/immodules" "*.so" + rpathify_dir "$pkglib/gtk-2.0/$gtk_version/printbackends" "*.so" + rpathify_dir "$pkglib/gnome-vfs-2.0/modules" "*.so" + rpathify_dir "$pkglib/gdk-pixbuf-2.0/$gtk_version/loaders" "*.so" + rpathify_dir "$pkglib/pango/$pango_version/modules" "*.so" + rpathify_dir "$pkgbin" "*" +} + +PATHLENGTH=`echo $LIBPREFIX | wc -c` +if [ "$PATHLENGTH" -ge "6" ]; then + # If the LIBPREFIX path is long enough to allow + # path rewriting, then do this. + # 6 is the length of @rpath, which replaces LIBPREFIX. + rpathify_files +else + echo "Could not rewrite dylib paths for bundled libraries. This requires" >&2 + echo "the support libraries to be installed in a PREFIX of at least 6 characters in length." >&2 + echo "" >&2 + echo "The package will still work if the following line is uncommented in" >&2 + echo "Wireshark.app/Contents/Resources/bin/{various scripts}:" >&2 + echo ' export DYLD_LIBRARY_PATH="$TOP/lib"' >&2 + exit 1 + +fi exit 0 |