diff options
-rwxr-xr-x | packaging/macosx/osx-app.sh | 206 |
1 files changed, 129 insertions, 77 deletions
diff --git a/packaging/macosx/osx-app.sh b/packaging/macosx/osx-app.sh index 6a7f061f51..b12cb329c6 100755 --- a/packaging/macosx/osx-app.sh +++ b/packaging/macosx/osx-app.sh @@ -50,7 +50,6 @@ ui_toolkit="qt" wireshark_bin_name="wireshark" binary_list=" - androiddump capinfos dftest dumpcap @@ -60,6 +59,7 @@ binary_list=" rawshark text2pcap tshark + extcap/androiddump " cs_binary_list= @@ -487,6 +487,10 @@ if [ "$strip" = "true" ]; then fi if [ "$ui_toolkit" = "qt" ] ; then + # + # This may not work on Qt 5.5.0 or 5.5.1: + # https://bugreports.qt.io/browse/QTBUG-47868 + # macdeployqt "$bundle" -verbose=2 || exit 1 # @@ -502,92 +506,134 @@ fi # rpathify_file () { # Fix a given executable, library, or plugin to be relocatable - if [ ! -d "$1" ]; then + if [ ! -f "$1" ]; then + return 0; + fi + + # + # OK, what type of file is this? + # + filetype=$( otool -hv "$1" | sed -n '4p' | awk '{print $5}' ; exit ${PIPESTATUS[0]} ) + if [ $? -ne 0 ] ; then + echo "Unable to rpathify $1 in $( pwd ): file type failed." + exit 1 + fi + + case "$filetype" in + + EXECUTE|DYLIB|BUNDLE) # - # OK, what type of file is this? + # Executable, library, or plugin. (Plugins + # can be either DYLIB or BUNDLE; shared + # libraries are DYLIB.) # - filetype=`otool -hv "$1" | sed -n '4p' | awk '{print $5}'` - case "$filetype" in - - EXECUTE|DYLIB|BUNDLE) + # 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}'` # - # Executable, library, or plugin. (Plugins - # can be either DYLIB or BUNDLE; shared - # libraries are DYLIB.) + # The library will end up in a directory in + # the rpath; this is what we should change its + # ID to. # - # For DYLIB and BUNDLE, fix the shared - # library identification. + to=@rpath/$base + /usr/bin/install_name_tool -id $to $1 + + # + # If we're a library and we depend on something in + # @executable_path/../Frameworks, replace that with + # @rpath. # - 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 + otool -L $1 | grep @executable_path/../Frameworks | awk '{print $1}' | \ + while read dep_lib ; do + base=`echo $dep_lib | awk -F/ '{print $NF}'` + to="@rpath/$base" + echo "Changing reference to $dep_lib to $to in $1" + /usr/bin/install_name_tool -change $dep_lib $to $1 + done + fi + + # + # Find our local rpaths and remove them. + # + otool -l $1 | grep -A2 LC_RPATH \ + | awk '$1=="path" && $2 !~ /^@/ {print $2}' \ + | egrep -v "$exclude_prefixes" | \ + while read lc_rpath ; do + echo "Stripping LC_RPATH $lc_rpath from $1" + install_name_tool -delete_rpath $lc_rpath $1 + done + + # + # Add -Wl,-rpath,@executable_path/../Frameworks + # to the rpath, so it'll find the bundled + # frameworks and libraries if they're referred + # to by @rpath/, rather than having a wrapper + # script tweak DYLD_LIBRARY_PATH. + # + if [[ "$filetype" = "EXECUTE" ]]; then + if [ -d ../Frameworks ] ; then + framework_path=../Frameworks + elif [ -d ../../Frameworks ] ; then + framework_path=../../Frameworks + else + echo "Unable to find relative path to Frameworks for $1 from $( pwd )" + exit 1 fi + echo "Adding @executable_path/$framework_path to rpath of $1" + /usr/bin/install_name_tool -add_rpath @executable_path/$framework_path $1 + fi + + # + # Show the minimum supported version of Mac OS X + # for each executable or library + # + if [[ "$filetype" = "EXECUTE" || "$filetype" = "DYLIB" ]] && [[ "$VERSION" -ge "7" ]] ; then + echo "Minimum Mac OS X version for $1:" + otool -l $1 | grep -A3 LC_VERSION_MIN_MACOSX + 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 \ + | fgrep compatibility \ + | cut -d\( -f1 \ + | egrep -v "$exclude_prefixes" \ + | sort \ + | uniq \ + `" + + for lib in $libs; do # - # Add -Wl,-rpath,@executable_path/../Frameworks - # to the rpath, so it'll find the bundled - # frameworks and libraries if they're referred - # to by @rpath/, rather than having a wrapper - # script tweak DYLD_LIBRARY_PATH. + # Get the file name of the library. # - echo "Adding @executable_path/../Frameworks to rpath of $1" - /usr/bin/install_name_tool -add_rpath @executable_path/../Frameworks $1 - + base=`echo $lib | awk -F/ '{print $NF}'` # - # Show the minimum supported version of Mac OS X - # for each executable or library + # The library will end up in a directory in + # the rpath; this is what we should change its + # file name to. # - if [[ "$filetype" = "EXECUTE" || "$filetype" = "DYLIB" ]] && [[ "$VERSION" -ge "7" ]] ; then - echo "Minimum Mac OS X version for $1:" - otool -l $1 | grep -A3 LC_VERSION_MIN_MACOSX - fi - + to=@rpath/$base # - # 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. + # Change the reference to that library. # - libs="`\ - otool -L $1 \ - | fgrep compatibility \ - | cut -d\( -f1 \ - | egrep -v "$exclude_prefixes" \ - | sort \ - | uniq \ - `" - - 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 to $to in $1" - /usr/bin/install_name_tool -change $lib $to $1 - done - ;; - esac - fi + echo "Changing reference to $lib to $to in $1" + /usr/bin/install_name_tool -change $lib $to $1 + done + ;; + esac } rpathify_dir () { @@ -606,6 +652,8 @@ rpathify_dir () { done fi ) + rf_ret=$? + if [ $rf_ret -ne 0 ] ; then exit $rf_ret ; fi fi } @@ -614,6 +662,13 @@ rpathify_files () { # Fix bundle deps # rpathify_dir "$pkglib" "*.dylib" + rpathify_dir "$pkgbin" "*" + rpathify_dir "$pkgplugin" "*" + + if [ "$ui_toolkit" = "qt" ] ; then + rpathify_dir "$pkgbin/extcap" "*" + fi + if [ "$ui_toolkit" = "gtk" ] ; then rpathify_dir "$pkglib/gtk-2.0/$gtk_version/loaders" "*.so" rpathify_dir "$pkglib/gtk-2.0/$gtk_version/engines" "*.so" @@ -623,9 +678,6 @@ rpathify_files () { rpathify_dir "$pkglib/gdk-pixbuf-2.0/$gtk_version/loaders" "*.so" rpathify_dir "$pkglib/pango/$pango_version/modules" "*.so" fi - rpathify_dir "$pkgbin" "*" - rpathify_dir "$pkgbin/extcap" "*" - rpathify_dir "$pkgplugin" "*" } PATHLENGTH=`echo $LIBPREFIX | wc -c` |