Add some packaging notes to darwin-py2app.sh.
[naja.git] / packaging / darwin-py2app.sh
1 #!/bin/sh
2 # Copyright 2009-2014 Jeremy Thurgood <firxen@gmail.com>
3 # GPL - see COPYING for details
4 #
5 # Usage: darwin-py2app
6
7 # NOTE:
8 #
9 # This requires a 32-bit Python build from python.org and a binary pygame
10 # distribution.
11 # I used these:
12 #   https://www.python.org/ftp/python/2.7.6/python-2.7.6-macosx10.3.dmg
13 #   http://pygame.org/ftp/pygame-1.9.1release-python.org-32bit-py2.7-macosx10.3.dmg
14 #
15 # Install these in /Library/Frameworks and build the virtualenv with
16 # --system-site-packages to make the pygame installation available.
17
18 GAME_NAME=`sed -ne 's/NAME_STR = "\(.*\)"/\1/p' setup.py`
19 GAME_VERSION=`sed -ne 's/VERSION_STR = "\(.*\)"/\1/p' setup.py`
20 BUILD_NAME="${GAME_NAME}-${GAME_VERSION}"
21 BUILD_FOLDER="build/${BUILD_NAME}"
22 DMG_NAME="${BUILD_NAME}.dmg"
23 PY2APP_LOG="py2app.log"
24
25 BASEDIR=`pwd`
26
27 echo "=== Setting up build environment ==="
28
29 python setup.py sdist > /dev/null
30 mkdir build
31 (cd build; tar xzf ../dist/${BUILD_NAME}.tar.gz)
32
33 cd ${BUILD_FOLDER}
34
35 echo ""
36 echo "=== Running python setup.py ==="
37 echo "  ${GAME_NAME} version: ${GAME_VERSION}"
38 echo "  Writing log to ${PY2APP_LOG}"
39
40 python setup.py py2app >${PY2APP_LOG} 2>&1
41
42 echo ""
43 echo "=== Removing useless cruft that just takes up space ==="
44 echo ""
45
46 for dir in docs examples tests; do
47     find "dist/" -path "*/Resources/lib/*/pygame/${dir}/*" -delete
48 done
49
50 echo "=== Adding magic icon ==="
51 echo ""
52
53 cp data/icons/*.icns dist/${GAME_NAME}.app/Contents/Resources/
54
55 echo "=== Building DMG ==="
56 echo ""
57
58 cd ${BASEDIR}
59
60 rm dist/${DMG_NAME} > /dev/null
61
62 cat > ${BUILD_FOLDER}/dist/IMPORTANT\ NOTE.txt <<EOF
63 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.
64
65 If this doesn't work, please let me (<firxen@gmail.com>) know, especially if you have any ideas about how to fix it.
66
67 You should also be able to use the unix tarball available at the same place you got this dmg.
68
69 Thanks.
70 EOF
71
72 hdiutil create -volname ${GAME_NAME} -srcfolder ${BUILD_FOLDER}/dist/*.app/ -srcfolder ${BUILD_FOLDER}/dist/IMPORTANT\ NOTE.txt dist/${DMG_NAME}
73
74 echo ""
75 echo "=== Done ==="
76 echo ""
77 du -sh dist/* | sed 's/^/   /'
78 echo ""
79