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