8af88291989ee2216a757281456ee9daa07b2b32
[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 echo "[${BUILD_FOLDER}]"
23 cd ${BUILD_FOLDER}
24 echo "$PWD"
25
26 echo ""
27 echo "=== Running python setup.py ==="
28 echo "  ${GAME_NAME} version: ${GAME_VERSION}"
29 echo "  Writing log to ${PY2APP_LOG}"
30
31 python setup.py py2app >${PY2APP_LOG} 2>&1
32
33 echo ""
34 echo "=== Removing useless cruft that just takes up space ==="
35 echo ""
36
37 for dir in docs examples tests; do
38     find "dist/" -path "*/Resources/lib/*/pygame/${dir}/*" -delete
39 done
40
41 echo "=== Adding magic icon ==="
42 echo ""
43
44 cp data/icons/*.icns dist/${GAME_NAME}.app/Contents/Resources/
45
46 echo "=== Building DMG ==="
47 echo ""
48
49 cd ${BASEDIR}
50
51 pwd
52 rm dist/${DMG_NAME} > /dev/null
53
54 echo -e "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.\n\nIf this doesn't work, please let me (<firxen@gmail.com>) know, especially if you have any ideas about how to fix it.\n\nYou should also be able to use the unix tarball available at the same place you got this dmg.\n\nThanks." > ${BUILD_FOLDER}/dist/IMPORTANT\ NOTE.txt
55
56 hdiutil create -volname ${GAME_NAME} -srcfolder ${BUILD_FOLDER}/dist/*.app/ -srcfolder ${BUILD_FOLDER}/dist/IMPORTANT\ NOTE.txt dist/${DMG_NAME}
57
58 echo ""
59 echo "=== Done ==="
60 echo ""
61 du -sh dist/* | sed 's/^/   /'
62 echo ""
63