Chris@409: #!/bin/bash Chris@409: Chris@1077: set -e Chris@1077: Chris@409: app="$1" Chris@409: if [ -z "$app" ]; then Chris@409: echo "Usage: $0 " Chris@409: echo "Provide appname without the .app extension, please" Chris@409: exit 2 Chris@409: fi Chris@409: Chris@1077: set -u Chris@1077: Chris@1082: frameworks="QtCore QtNetwork QtGui QtXml QtSvg QtWidgets QtPrintSupport QtDBus" Chris@742: Chris@409: echo Chris@742: echo "I expect you to have already copied these frameworks from the Qt installation to" Chris@742: echo "$app.app/Contents/Frameworks -- expect errors to follow if they're missing:" Chris@742: echo "$frameworks" Chris@409: echo Chris@409: Chris@409: echo "Fixing up loader paths in binaries..." Chris@409: Chris@742: for fwk in $frameworks; do Chris@742: install_name_tool -id $fwk "$app.app/Contents/Frameworks/$fwk" Chris@742: done Chris@409: Chris@509: find "$app.app" -name \*.dylib -print | while read x; do Chris@509: install_name_tool -id "`basename \"$x\"`" "$x" Chris@509: done Chris@509: Chris@742: for fwk in $frameworks; do cannam@1286: find "$app.app" -type f -print | while read x; do cannam@1286: if [ -x "$x" ]; then cannam@1286: current=$(otool -L "$x" | grep "$fwk" | grep amework | grep -v ':$' | awk '{ print $1; }') cannam@1286: [ -z "$current" ] && continue cannam@1286: echo "$x has $current" cannam@1286: relative=$(echo "$x" | sed -e "s,$app.app/Contents/,," \ cannam@1286: -e 's,[^/]*/,../,g' \ cannam@1286: -e 's,/[^/]*$,/Frameworks/'"$fwk"',' ) cannam@1286: echo "replacing with relative path $relative" cannam@1286: install_name_tool -change "$current" "@loader_path/$relative" "$x" cannam@1286: fi cannam@1286: done Chris@409: done Chris@409: Chris@1077: find "$app.app" -type f -print | while read x; do cannam@1286: if [ -x "$x" ]; then cannam@1286: qtdep=$(otool -L "$x" | grep Qt | grep amework | grep -v ':$' | grep -v '@loader_path' | awk '{ print $1; }') cannam@1286: if [ -n "$qtdep" ]; then cannam@1286: echo cannam@1286: echo "ERROR: File $x depends on Qt framework(s) not apparently present in the bundle:" cannam@1286: echo $qtdep cannam@1286: exit 1 cannam@1286: fi Chris@1077: fi Chris@1077: done Chris@1077: Chris@409: echo "Done: be sure to run the app and see that it works!" Chris@409: Chris@409: