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@335
|
33 find "$app.app" -type f -print | while read x; do
|
Chris@667
|
34 current=$(otool -L "$x" | grep "$fwk" | grep amework | grep -v ':$' | awk '{ print $1; }')
|
Chris@335
|
35 [ -z "$current" ] && continue
|
Chris@335
|
36 echo "$x has $current"
|
Chris@335
|
37 relative=$(echo "$x" | sed -e "s,$app.app/Contents/,," \
|
Chris@335
|
38 -e 's,[^/]*/,../,g' -e 's,/[^/]*$,/Frameworks/'"$fwk"',' )
|
Chris@335
|
39 echo "replacing with relative path $relative"
|
Chris@335
|
40 install_name_tool -change "$current" "@loader_path/$relative" "$x"
|
Chris@335
|
41 done
|
Chris@335
|
42 done
|
Chris@335
|
43
|
Chris@667
|
44 find "$app.app" -type f -print | while read x; do
|
Chris@667
|
45 qtdep=$(otool -L "$x" | grep Qt | grep amework | grep -v ':$' | grep -v '@loader_path' | awk '{ print $1; }')
|
Chris@667
|
46 if [ -n "$qtdep" ]; then
|
Chris@667
|
47 echo
|
Chris@667
|
48 echo "ERROR: File $x depends on Qt framework(s) not apparently present in the bundle:"
|
Chris@667
|
49 echo $qtdep
|
Chris@667
|
50 exit 1
|
Chris@667
|
51 fi
|
Chris@667
|
52 done
|
Chris@667
|
53
|
Chris@335
|
54 echo "Done: be sure to run the app and see that it works!"
|
Chris@335
|
55
|
Chris@335
|
56
|