annotate deploy/osx/deploy.sh @ 558:77754355b37a

macOS build fixes
author Chris Cannam
date Mon, 18 Feb 2019 10:35:39 +0000
parents 2fcc15ca574a
children dd344309667f
rev   line source
Chris@62 1 #!/bin/bash
Chris@62 2
Chris@439 3 set -e
Chris@437 4
Chris@62 5 # Execute this from the top-level directory of the project (the one
Chris@62 6 # that contains the .app bundle). Supply the name of the .app bundle
Chris@62 7 # as argument (the target will use $app.app regardless, but we need
Chris@62 8 # to know the source)
Chris@62 9
Chris@62 10 source="$1"
Chris@62 11 dmg="$2"
Chris@62 12 if [ -z "$source" ] || [ ! -d "$source" ] || [ -z "$dmg" ]; then
Chris@62 13 echo "Usage: $0 <source.app> <target-dmg-basename>"
Chris@62 14 echo " e.g. $0 MyApplication.app MyApplication"
Chris@62 15 echo " Version number and .dmg will be appended automatically,"
Chris@62 16 echo " but the .app name must include .app"
Chris@62 17 exit 2
Chris@62 18 fi
Chris@62 19 app=`basename "$source" .app`
Chris@62 20
Chris@439 21 set -u
Chris@439 22
Chris@62 23 version=`perl -p -e 's/^[^"]*"([^"]*)".*$/$1/' version.h`
Chris@437 24 stem=${version%%-*}
Chris@437 25 case "$stem" in
Chris@437 26 [0-9].[0-9]) bundleVersion="$stem".0 ;;
Chris@437 27 [0-9].[0-9].[0-9]) bundleVersion="$stem" ;;
Chris@437 28 *) echo "Error: Version stem $stem (of version $version) is neither two- nor three-part number"; exit 1 ;;
Chris@62 29 esac
Chris@62 30
Chris@66 31 if file "$source/Contents/MacOS/$app" | grep -q script; then
Chris@66 32 echo
Chris@66 33 echo "Executable is already a script, leaving it alone."
Chris@66 34 else
Chris@66 35 echo
Chris@66 36 echo "Moving aside executable, adding script."
Chris@66 37
Chris@207 38 mv "$source/Contents/MacOS/$app" "$source/Contents/MacOS/$app.bin" || exit 1
Chris@66 39 cp "deploy/osx/$app.sh" "$source/Contents/MacOS/$app" || exit 1
Chris@66 40 chmod +x "$source/Contents/MacOS/$app"
Chris@66 41 fi
Chris@66 42
Chris@66 43 echo
Chris@265 44 echo "Copying in plugins from pyin/pyin.dylib and chp/chp.dylib."
Chris@265 45 echo "(make sure they're present, up-to-date and compiled with optimisation!)"
Chris@66 46
Chris@558 47 cp libpyin.dylib "$source/Contents/Resources/pyin.dylib"
Chris@558 48 cp libchp.dylib "$source/Contents/Resources/chp.dylib"
Chris@437 49
Chris@437 50 echo
Chris@437 51 echo "Copying in frameworks and plugins from Qt installation directory."
Chris@437 52
Chris@437 53 deploy/osx/copy-qt.sh "$app" || exit 2
Chris@66 54
Chris@62 55 echo
Chris@62 56 echo "Fixing up paths."
Chris@62 57
Chris@62 58 deploy/osx/paths.sh "$app"
Chris@62 59
Chris@62 60 echo
Chris@503 61 echo "Copying in qt.conf to set local-only plugin paths."
Chris@503 62 echo "Make sure all necessary Qt plugins are in $source/Contents/plugins/*"
Chris@503 63 echo "You probably want platforms/, accessible/ and imageformats/ subdirectories."
Chris@503 64 cp deploy/osx/qt.conf "$source"/Contents/Resources/qt.conf
Chris@503 65
Chris@503 66 echo
Chris@503 67 echo "Writing version $bundleVersion in to bundle."
Chris@503 68 echo "(This should be a three-part number: major.minor.point)"
Chris@503 69
Chris@503 70 perl -p -e "s/TONY_VERSION/$bundleVersion/" deploy/osx/Info.plist \
Chris@503 71 > "$source"/Contents/Info.plist
Chris@503 72
Chris@503 73 echo "Done: check $source/Contents/Info.plist for sanity please"
Chris@503 74
Chris@503 75 echo
Chris@62 76 echo "Making target tree."
Chris@62 77
Chris@62 78 volume="$app"-"$version"
Chris@62 79 target="$volume"/"$app".app
Chris@62 80 dmg="$dmg"-"$version".dmg
Chris@62 81
Chris@62 82 mkdir "$volume" || exit 1
Chris@62 83
Chris@62 84 ln -s /Applications "$volume"/Applications
Chris@538 85 cp README.md "$volume/README.txt"
Chris@538 86 cp README.OSC "$volume/README-OSC.txt"
Chris@538 87 cp COPYING "$volume/COPYING.txt"
Chris@538 88 cp CHANGELOG "$volume/CHANGELOG.txt"
Chris@538 89 cp CITATION "$volume/CITATION.txt"
Chris@437 90 cp -rp "$source" "$target"
Chris@62 91
Chris@62 92 echo "Done"
Chris@62 93
Chris@538 94 echo
Chris@538 95 echo "Code-signing volume..."
Chris@538 96
Chris@62 97 deploy/osx/sign.sh "$volume" || exit 1
Chris@62 98
Chris@538 99 echo "Done"
Chris@538 100
Chris@62 101 echo
Chris@62 102 echo "Making dmg..."
Chris@62 103
Chris@62 104 hdiutil create -srcfolder "$volume" "$dmg" -volname "$volume" &&
Chris@62 105 rm -r "$volume"
Chris@62 106
Chris@62 107 echo "Done"