package.sh 3.52 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash

# This script is to package the nMolDyn package for Mac OS X

#############################
# CONFIGURATION
#############################

## Add some colors
VERT="\\033[1;32m"
NORMAL="\\033[0;39m"
ROUGE="\\033[1;31m"
ROSE="\\033[1;35m"
BLEU="\\033[1;34m"
BLANC="\\033[0;02m"
BLANCLAIR="\\033[1;08m"
JAUNE="\\033[1;33m"
CYAN="\\033[1;36m"

##Select the build target
BUILD_TARGET=darwin

##Do we need to create the final archive
ARCHIVE_FOR_DISTRIBUTION=1
##Which version name are we appending to the final archive
export BUILD_NAME=1.0
TARGET_DIR=MDANSE-${BUILD_NAME}-${BUILD_TARGET}

#############################
# Darwin
#############################

if [ "$BUILD_TARGET" = "darwin" ]; then
	
	
	cd ../..
	
	# take the latest version of nmoldyn available on the forge
	echo -e "$BLEU""Getting last MDANSE revision" "$NORMAL"

	# Get revision number from git (without trailing newline)
	REV_NUMBER=$(git rev-list --count HEAD)
	echo "$BLEU""Revision number is -->${REV_NUMBER}<--" "$NORMAL"

	# Add current revision number to python source code (will appear in "About..." dialog)
	# see http://stackoverflow.com/questions/7648328/getting-sed-error
	sed -i "" "s/__revision__ = \"undefined\"/__revision__ = \"${REV_NUMBER}\"/" MDANSE/__pkginfo__.py
	
	# Now build last version and install it in our homebrewed python
	echo -e "$BLEU""Building MDANSE" "$NORMAL"
	/usr/local/bin/python setup.py build
	/usr/local/bin/python setup.py install
	
	TARGET_DIR=MDANSE-${BUILD_NAME}-b${REV_NUMBER}-MacOS
	
	echo -e "$BLEU""Packaging MDANSE" "$NORMAL"
	rm -rf scripts/darwin/build
	rm -rf scripts/darwin/dist
	
	# debug option for py2app, if needed
	export DISTUTILS_DEBUG=0
	
	/usr/local/bin/python build_mdanse.py py2app
	rc=$?
	if [[ $rc != 0 ]]; then
		echo -e "$ROUGE""Cannot build app." "$NORMAL"
		exit 1
	fi

	# Do some manual cleanup, e.g.
	# matplotlib/tests ==> 45.2 Mb
	rm -rf scripts/darwin/dist/MDANSE.app/Contents/Resources/lib/python2.7/matplotlib/tests
	rm -rf scripts/darwin/dist/MDANSE.app/Contents/Resources/mpl-data/sample_data 


	#Add MDANSE version file (should read the version from the bundle with pyobjc, but will figure that out later)
	echo "$BUILD_NAME b$REV_NUMBER"> scripts/darwin/dist/MDANSE.app/Contents/Resources/version

	cd scripts/darwin

	# Archive app
	echo -e "$BLEU" "Archiving ${TARGET_DIR}.tar.gz ..." "$NORMAL"
	cd dist
	gnutar cfp - MDANSE.app | gzip --best -c > ../../../${TARGET_DIR}.tar.gz
	cd ..

# Reminder on pre-configured DmgTemplate
#>hdiutil convert DmgTemplateCompressed.dmg -format UDRW -o DmgTemplateCompressedRW.dmg
#>hdiutil convert DmgTemplateCompressedRW.dmg -format UDZO -o DmgTemplateCompressed.dmg

	TODAY=$(date +"%m-%d-%y-%Hh%Mm%S")
	# Create sparse image for distribution
	echo -e "$BLEU" "Creating new MDANSE.dmg.sparseimage ..." "$NORMAL"
	hdiutil detach /Volumes/MDANSE/ -quiet
	# Keep previous build, in case of
	mv -f MDANSE.dmg.sparseimage MDANSE.dmg.sparseimage.${TODAY}.old
	hdiutil convert DmgTemplateCompressed.dmg -format UDSP -o MDANSE.dmg.sparseimage
	hdiutil resize -size 1024m MDANSE.dmg.sparseimage
	hdiutil attach nMolDyn.dmg.sparseimage
	echo -e "$BLEU" "Copying MDANSE.app on dmg ..." "$NORMAL"
	cp -a dist/MDANSE.app /Volumes/MDANSE/MDANSE/
	echo -e "$BLEU" "Copying UserData/ on dmg ..." "$NORMAL"
	cp -R ../../MDANSE/UserData/ /Volumes/MDANSE/MDANSE/
	# Reset Custom icon on MDANSE folder
	SetFile -a C /Volumes/MDANSE/MDANSE/
	hdiutil detach /Volumes/MDANSE
	hdiutil convert MDANSE.dmg.sparseimage -format UDZO -imagekey zlib-level=9 -ov -o ../../${TARGET_DIR}.dmg
	echo -e "$VERT" "Done." "$NORMAL"
	exit
fi