diff options
Diffstat (limited to 'macosx/make-app-bundle.sh')
-rwxr-xr-x[-rw-r--r--] | macosx/make-app-bundle.sh | 102 |
1 files changed, 75 insertions, 27 deletions
diff --git a/macosx/make-app-bundle.sh b/macosx/make-app-bundle.sh index 05259702..b124d4a1 100644..100755 --- a/macosx/make-app-bundle.sh +++ b/macosx/make-app-bundle.sh @@ -1,41 +1,89 @@ #!/bin/sh +# exit when any command fails +set -e + +# keep track of the last executed command +trap 'last_command=$current_command; current_command=$BASH_COMMAND' DEBUG +# echo an error message before exiting +trap 'echo "--\n--\n--\n--\n\"${last_command}\" command failed with exit code $?."' EXIT + APPNAME=opentrack +# Alternative we could look at https://github.com/arl/macdeployqtfix ?? -dir="$1" -test -n "$dir" || exit 1 +#macosx directory +dir="$1" +test -n "$dir" +# install directory install="$2" -test -n "$install" || exit 1 -output_dir="$3" -test -n "$output_dir" || exit 1 -version="$4" -test -n "$version" || exit 1 +test -n "$install" +version="$3" +test -n "$version" tmp="$(mktemp -d "/tmp/$APPNAME-tmp.XXXXXXX")" -test $? -eq 0 || exit 1 +test $? -eq 0 + -rm -f -- "$install/.DS_Store" -sh "$dir/install-fail-tool" "$install" +# Add rpath for application so it can find the libraries +#install_name_tool -add_rpath @executable_path/../Frameworks "$install/$APPNAME.app/Contents/MacOS/$APPNAME" -cp -R "$dir/opentrack.app" "$tmp/" || exit 1 -cp -R "$install" "$tmp/$APPNAME.app/Contents/MacOS" || exit 1 -sed -i '' -e "s#@OPENTRACK-VERSION@#$version#g" "$tmp/$APPNAME.app/Contents/Info.plist" || exit 1 +# Copy our own plist and set correct version +cp "$dir/Info.plist" "$install/$APPNAME.app/Contents/" +sed -i '' -e "s#@OPENTRACK-VERSION@#$version#g" "$install/$APPNAME.app/Contents/Info.plist" -mkdir "$tmp/$APPNAME.iconset" || exit 1 -mkdir "$tmp/$APPNAME.app/Contents/Resources" || exit 1 -cp "$dir"/opentrack.sh "$tmp/$APPNAME.app/Contents/MacOS" || exit 1 +# Copy PkgInfo +cp "$dir/PkgInfo" "$install/$APPNAME.app/Contents/" -sips -z 16 16 "$dir/../gui/images/opentrack.png" --out "$tmp/$APPNAME.iconset/icon_16x16.png" || exit 1 -sips -z 32 32 "$dir/../gui/images/opentrack.png" --out "$tmp/$APPNAME.iconset/icon_16x16@2x.png" || exit 1 -sips -z 32 32 "$dir/../gui/images/opentrack.png" --out "$tmp/$APPNAME.iconset/icon_32x32.png" || exit 1 -sips -z 64 64 "$dir/../gui/images/opentrack.png" --out "$tmp/$APPNAME.iconset/icon_32x32@2x.png" || exit 1 -sips -z 128 128 "$dir/../gui/images/opentrack.png" --out "$tmp/$APPNAME.iconset/icon_128x128.png" || exit 1 +# Copy plugins +mkdir -p "$install/$APPNAME.app/Contents/MacOS/Plugins" +cp -r "$install/Plugins" "$install/$APPNAME.app/Contents/MacOS/" -iconutil -c icns -o "$tmp/$APPNAME.app/Contents/Resources/$APPNAME.icns" "$tmp/$APPNAME.iconset" -rm -r "$tmp/$APPNAME.iconset" +# Add framework and other libraries and fixup other libraries +macdeployqt "$install/$APPNAME.app" -libpath="$install/Library" +sh "$dir/install-fail-tool" "$install/$APPNAME.app/Contents/Frameworks" -cd "$tmp" || exit 1 -rm -f "$output_dir/$version-macosx.zip" -zip -9r "$output_dir/$version-macosx.zip" "$APPNAME.app" || exit 1 +# Create an 512 resolution size for the icon (for retina displays mostly) +#gm convert -size 512x512 "$dir/../gui/images/opentrack.png" "$tmp/opentrack.png" +convert "$dir/../gui/images/opentrack.png" -filter triangle -resize 512x512 "$tmp/opentrack.png" + +# Build iconset +mkdir "$tmp/$APPNAME.iconset" +sips -z 16 16 "$tmp/opentrack.png" --out "$tmp/$APPNAME.iconset/icon_16x16.png" +sips -z 32 32 "$tmp/opentrack.png" --out "$tmp/$APPNAME.iconset/icon_16x16@2x.png" +sips -z 32 32 "$tmp/opentrack.png" --out "$tmp/$APPNAME.iconset/icon_32x32.png" +sips -z 64 64 "$tmp/opentrack.png" --out "$tmp/$APPNAME.iconset/icon_32x32@2x.png" +sips -z 128 128 "$tmp/opentrack.png" --out "$tmp/$APPNAME.iconset/icon_128x128.png" +sips -z 256 256 "$tmp/opentrack.png" --out "$tmp/$APPNAME.iconset/icon_128x128@2x.png" +sips -z 512 512 "$tmp/opentrack.png" --out "$tmp/$APPNAME.iconset/icon_256x256@2x.png" +sips -z 512 512 "$tmp/opentrack.png" --out "$tmp/$APPNAME.iconset/icon_512x512.png" +iconutil -c icns -o "$install/$APPNAME.app/Contents/Resources/$APPNAME.icns" "$tmp/$APPNAME.iconset" rm -rf "$tmp" -ls -lh "$output_dir/$version-macosx.zip" + +#Build DMG +#https://github.com/andreyvit/create-dmg +rm -rf $install/../*.dmg +create-dmg \ + --volname "$APPNAME" \ + --volicon "$install/$APPNAME.app/Contents/Resources/$APPNAME.icns" \ + --window-pos 200 120 \ + --window-size 800 450 \ + --icon-size 80 \ + --background "$dir/dmgbackground.png" \ + --icon "$APPNAME.app" 200 180 \ + --app-drop-link 420 180 \ + --hide-extension "$APPNAME.app" \ + --add-folder "Document" "$install/doc" 20 40 \ + --no-internet-enable \ + --add-folder "source-code" "$install/source-code" 220 40 \ + --add-folder "Xplane-Plugin" "$install/xplane" 420 40 \ + "$version.dmg" \ + "$install/$APPNAME.app" + +# Check if we have a DMG otherwise fail +FILE=$install/../$version.dmg +if [ -f $FILE ]; then + ls -ial $install/../*.dmg +else + echo "Failed to create ${FILE}" + exit 2 +fi |