Slightly better OS X build.
[naja.git] / packaging / darwin-py2app.sh
1 #!/bin/sh
2 # Copyright 2009 Jeremy Thurgood <firxen@gmail.com>
3 # GPL - see COPYING for details
4 #
5 # Usage: darwin-py2app
6
7 GAME_NAME=`sed -ne 's/NAME_STR = "\(.*\)"/\1/p' setup.py`
8 GAME_VERSION=`sed -ne 's/VERSION_STR = "\(.*\)"/\1/p' setup.py`
9 BUILD_NAME="${GAME_NAME}-${GAME_VERSION}"
10 BUILD_FOLDER="build/${BUILD_NAME}"
11 DMG_NAME="${BUILD_NAME}.dmg"
12 PY2APP_LOG="py2app.log"
13
14 BASEDIR=`pwd`
15
16 echo "=== Setting up build environment ==="
17
18 python setup.py sdist > /dev/null
19 mkdir build
20 (cd build; tar xzf ../dist/${BUILD_NAME}.tar.gz)
21
22 cd ${BUILD_FOLDER}
23
24 echo ""
25 echo "=== Running python setup.py ==="
26 echo "  ${GAME_NAME} version: ${GAME_VERSION}"
27 echo "  Writing log to ${PY2APP_LOG}"
28
29 python setup.py py2app >${PY2APP_LOG} 2>&1
30
31 echo ""
32 echo "=== Removing useless cruft that just takes up space ==="
33 echo ""
34
35 for dir in docs examples tests; do
36     find "dist/" -path "*/Resources/lib/*/pygame/${dir}/*" -delete
37 done
38
39 echo "=== Adding magic icon ==="
40 echo ""
41
42 cp data/icons/*.icns dist/${GAME_NAME}.app/Contents/Resources/
43
44 echo "=== Building DMG ==="
45 echo ""
46
47 cd ${BASEDIR}
48
49 rm dist/${DMG_NAME} > /dev/null
50
51 cat > ${BUILD_FOLDER}/dist/IMPORTANT\ NOTE.txt <<EOF
52 For some reason the game starts without a foreground window. Click on the icon in the dock (or minimize and restore from the menu) to get it back.
53
54 If this doesn't work, please let me (<firxen@gmail.com>) know, especially if you have any ideas about how to fix it.
55
56 You should also be able to use the unix tarball available at the same place you got this dmg.
57
58 Thanks.
59 EOF
60
61 hdiutil create -volname ${GAME_NAME} -srcfolder ${BUILD_FOLDER}/dist/*.app/ -srcfolder ${BUILD_FOLDER}/dist/IMPORTANT\ NOTE.txt dist/${DMG_NAME}
62
63 echo ""
64 echo "=== Done ==="
65 echo ""
66 du -sh dist/* | sed 's/^/   /'
67 echo ""
68