annotate deploy/osx/paths.sh @ 731:2cb03c4665aa

Include kdiff3 executable in bundle on macOS
author Chris Cannam
date Mon, 17 Dec 2018 11:18:55 +0000
parents 646e48a0d3a5
children
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@699 34 if [ -x "$x" ]; then
Chris@699 35 current=$(otool -L "$x" |
Chris@699 36 grep "$fwk" | grep amework | grep -v ':$' |
Chris@699 37 awk '{ print $1; }')
Chris@670 38
Chris@699 39 [ -z "$current" ] && continue
Chris@670 40
Chris@699 41 echo "$x has $current"
Chris@670 42
Chris@699 43 case "$x" in
Chris@699 44 # *PyQt*)
Chris@699 45 # These are "special" Qt libraries used by
Chris@699 46 # the PyQt module. They need to refer to their
Chris@699 47 # own local neighbours. Ugh, but let's handle
Chris@699 48 # those manually here.
Chris@699 49 # relative="$fwk.so"
Chris@699 50 # ;;
Chris@699 51 *)
Chris@699 52 # The normal Qt case
Chris@699 53 relative=$(echo "$x" |
Chris@699 54 sed -e "s,$app.app/Contents/,," \
Chris@699 55 -e 's,[^/]*/,../,g' \
Chris@699 56 -e 's,/[^/]*$,/Frameworks/'"$fwk"',' )
Chris@699 57 ;;
Chris@699 58 esac
Chris@670 59
Chris@699 60 echo "replacing with relative path $relative"
Chris@699 61 install_name_tool -change \
Chris@699 62 "$current" "@loader_path/$relative" "$x"
Chris@699 63 fi
Chris@670 64 done
Chris@335 65 done
Chris@335 66
Chris@667 67 find "$app.app" -type f -print | while read x; do
Chris@699 68 if [ -x "$x" ]; then
Chris@699 69 qtdep=$(otool -L "$x" | grep Qt | grep amework | grep -v ':$' | grep -v '@loader_path' | awk '{ print $1; }')
Chris@699 70 if [ -n "$qtdep" ]; then
Chris@699 71 echo
Chris@699 72 echo "ERROR: File $x depends on Qt framework(s) not apparently present in the bundle:"
Chris@699 73 echo $qtdep
Chris@699 74 exit 1
Chris@699 75 fi
Chris@667 76 fi
Chris@667 77 done
Chris@667 78
Chris@335 79 echo "Done: be sure to run the app and see that it works!"
Chris@335 80
Chris@335 81