Chris@62
|
1 #!/bin/bash
|
Chris@62
|
2
|
Chris@62
|
3 # Execute this from the top-level directory of the project (the one
|
Chris@62
|
4 # that contains the .app bundle). Supply the name of the .app bundle
|
Chris@62
|
5 # as argument (the target will use $app.app regardless, but we need
|
Chris@62
|
6 # to know the source)
|
Chris@62
|
7
|
Chris@62
|
8 source="$1"
|
Chris@62
|
9 dmg="$2"
|
Chris@62
|
10 if [ -z "$source" ] || [ ! -d "$source" ] || [ -z "$dmg" ]; then
|
Chris@62
|
11 echo "Usage: $0 <source.app> <target-dmg-basename>"
|
Chris@62
|
12 echo " e.g. $0 MyApplication.app MyApplication"
|
Chris@62
|
13 echo " Version number and .dmg will be appended automatically,"
|
Chris@62
|
14 echo " but the .app name must include .app"
|
Chris@62
|
15 exit 2
|
Chris@62
|
16 fi
|
Chris@62
|
17 app=`basename "$source" .app`
|
Chris@62
|
18
|
Chris@62
|
19 version=`perl -p -e 's/^[^"]*"([^"]*)".*$/$1/' version.h`
|
Chris@62
|
20 case "$version" in
|
Chris@62
|
21 [0-9].[0-9]) bundleVersion="$version".0 ;;
|
Chris@62
|
22 [0-9].[0-9].[0-9]) bundleVersion="$version" ;;
|
Chris@62
|
23 *) echo "Error: Version $version is neither two- nor three-part number" ;;
|
Chris@62
|
24 esac
|
Chris@62
|
25
|
Chris@66
|
26 if file "$source/Contents/MacOS/$app" | grep -q script; then
|
Chris@66
|
27 echo
|
Chris@66
|
28 echo "Executable is already a script, leaving it alone."
|
Chris@66
|
29 else
|
Chris@66
|
30 echo
|
Chris@66
|
31 echo "Moving aside executable, adding script."
|
Chris@66
|
32
|
Chris@66
|
33 mv "$source/Contents/MacOS/$app" "$source/Contents/Resources/" || exit 1
|
Chris@66
|
34 cp "deploy/osx/$app.sh" "$source/Contents/MacOS/$app" || exit 1
|
Chris@66
|
35 chmod +x "$source/Contents/MacOS/$app"
|
Chris@66
|
36 fi
|
Chris@66
|
37
|
Chris@66
|
38 echo
|
Chris@66
|
39 echo "Copying in plugin."
|
Chris@66
|
40
|
Chris@100
|
41 cp ../pyin/pyin.{dylib,cat,n3} "$source/Contents/Resources/"
|
Chris@66
|
42
|
Chris@62
|
43 echo
|
Chris@62
|
44 echo "Fixing up paths."
|
Chris@62
|
45
|
Chris@62
|
46 deploy/osx/paths.sh "$app"
|
Chris@62
|
47
|
Chris@62
|
48 echo
|
Chris@62
|
49 echo "Making target tree."
|
Chris@62
|
50
|
Chris@62
|
51 volume="$app"-"$version"
|
Chris@62
|
52 target="$volume"/"$app".app
|
Chris@62
|
53 dmg="$dmg"-"$version".dmg
|
Chris@62
|
54
|
Chris@62
|
55 mkdir "$volume" || exit 1
|
Chris@62
|
56
|
Chris@62
|
57 ln -s /Applications "$volume"/Applications
|
Chris@62
|
58 cp README README.OSC COPYING CHANGELOG "$volume/"
|
Chris@100
|
59 cp -r "$source" "$target"
|
Chris@62
|
60
|
Chris@62
|
61 echo "Done"
|
Chris@62
|
62
|
Chris@62
|
63 echo "Writing version $bundleVersion in to bundle."
|
Chris@62
|
64 echo "(This should be a three-part number: major.minor.point)"
|
Chris@62
|
65
|
Chris@62
|
66 perl -p -e "s/TONY_VERSION/$bundleVersion/" deploy/osx/Info.plist \
|
Chris@62
|
67 > "$target"/Contents/Info.plist
|
Chris@62
|
68
|
Chris@62
|
69 echo "Done: check $target/Contents/Info.plist for sanity please"
|
Chris@62
|
70
|
Chris@62
|
71 deploy/osx/sign.sh "$volume" || exit 1
|
Chris@62
|
72
|
Chris@62
|
73 echo
|
Chris@62
|
74 echo "Making dmg..."
|
Chris@62
|
75
|
Chris@62
|
76 hdiutil create -srcfolder "$volume" "$dmg" -volname "$volume" &&
|
Chris@62
|
77 rm -r "$volume"
|
Chris@62
|
78
|
Chris@62
|
79 echo "Done"
|