annotate deploy/osx/paths.sh @ 670:8f3075eeaac2 qt5

Attempt to fix library paths for PyQt libraries. Doesn't seem to be sufficient.
author Chris Cannam
date Fri, 27 May 2016 11:02:53 +0100
parents 0f3e086066fc
children 646e48a0d3a5
rev   line source
Chris@335 1 #!/bin/bash
Chris@335 2
Chris@667 3 set -e
Chris@667 4
Chris@335 5 app="$1"
Chris@335 6 if [ -z "$app" ]; then
Chris@335 7 echo "Usage: $0 <appname>"
Chris@335 8 echo "Provide appname without the .app extension, please"
Chris@335 9 exit 2
Chris@335 10 fi
Chris@335 11
Chris@667 12 set -u
Chris@667 13
Chris@667 14 frameworks="QtCore QtNetwork QtGui QtWidgets QtPrintSupport QtDBus"
Chris@667 15
Chris@335 16 echo
Chris@667 17 echo "I expect you to have already copied these frameworks from the Qt installation to"
Chris@667 18 echo "$app.app/Contents/Frameworks -- expect errors to follow if they're missing:"
Chris@667 19 echo "$frameworks"
Chris@335 20 echo
Chris@335 21
Chris@335 22 echo "Fixing up loader paths in binaries..."
Chris@335 23
Chris@667 24 for fwk in $frameworks; do
Chris@667 25 install_name_tool -id $fwk "$app.app/Contents/Frameworks/$fwk"
Chris@667 26 done
Chris@335 27
Chris@667 28 find "$app.app" -name \*.dylib -print | while read x; do
Chris@667 29 install_name_tool -id "`basename \"$x\"`" "$x"
Chris@667 30 done
Chris@667 31
Chris@667 32 for fwk in $frameworks; do
Chris@670 33 find "$app.app" -type f -print | while read x; do
Chris@670 34
Chris@670 35 current=$(otool -L "$x" |
Chris@670 36 grep "$fwk" | grep amework | grep -v ':$' |
Chris@670 37 awk '{ print $1; }')
Chris@670 38
Chris@670 39 [ -z "$current" ] && continue
Chris@670 40
Chris@670 41 echo "$x has $current"
Chris@670 42
Chris@670 43 case "$x" in
Chris@670 44 *PyQt4*)
Chris@670 45 # These are "special" Qt4 libraries used by
Chris@670 46 # the PyQt module. They need to refer to their
Chris@670 47 # own local neighbours. Ugh, but let's handle
Chris@670 48 # those manually here.
Chris@670 49 relative="$fwk.so"
Chris@670 50 ;;
Chris@670 51 *)
Chris@670 52 # The normal Qt5 case
Chris@670 53 relative=$(echo "$x" |
Chris@670 54 sed -e "s,$app.app/Contents/,," \
Chris@670 55 -e 's,[^/]*/,../,g' \
Chris@670 56 -e 's,/[^/]*$,/Frameworks/'"$fwk"',' )
Chris@670 57 ;;
Chris@670 58 esac
Chris@670 59
Chris@670 60 echo "replacing with relative path $relative"
Chris@670 61 install_name_tool -change \
Chris@670 62 "$current" "@loader_path/$relative" "$x"
Chris@670 63 done
Chris@335 64 done
Chris@335 65
Chris@667 66 find "$app.app" -type f -print | while read x; do
Chris@667 67 qtdep=$(otool -L "$x" | grep Qt | grep amework | grep -v ':$' | grep -v '@loader_path' | awk '{ print $1; }')
Chris@667 68 if [ -n "$qtdep" ]; then
Chris@667 69 echo
Chris@667 70 echo "ERROR: File $x depends on Qt framework(s) not apparently present in the bundle:"
Chris@667 71 echo $qtdep
Chris@667 72 exit 1
Chris@667 73 fi
Chris@667 74 done
Chris@667 75
Chris@335 76 echo "Done: be sure to run the app and see that it works!"
Chris@335 77
Chris@335 78