package.sh 3.15 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
#!/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
Jamie Hall's avatar
Jamie Hall committed
34
	cd ../../../
35
36
37
38
39
	
	# 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)
Jamie Hall's avatar
Jamie Hall committed
40
	export REV_NUMBER=$(git rev-list --count HEAD)
41
42
43
44
45
46
47
48
	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"
49
	
50
51
52
53
54
55
56
57
58
59
	# Clean up temporary build directories
	rm -rf build
	rm -rf dist
	
	# Remove previous install of MDANSE
	rm /usr/local/bin/mdanse*
	rm /usr/local/lib/python2.7/site-packages/MDANSE*.egg-info
	rm -rf /usr/local/lib/python2.7/site-packages/MDANSE
	
	# Build and install MDANSE to the homebrewed python
60
	/usr/local/bin/python setup.py build
Jamie Hall's avatar
Jamie Hall committed
61
	/usr/local/bin/python setup.py install
62
63
64
65
66
67
68
69
70
71

    # Performs the unit tests
	cd Tests/UnitTests
    nosetests --verbosity=3 -P .
	cd ../..
	
	cd Tests/FunctionalTests/Jobs
	python BuildJobTests.py
    nosetests --verbosity=3 --exe -P .
	cd ../../..
72
73
74
75
	
	TARGET_DIR=MDANSE-${BUILD_NAME}-b${REV_NUMBER}-MacOS
	
	echo -e "$BLEU""Packaging MDANSE" "$NORMAL"
76
77
	rm -rf BuildServer/Darwin/Build
	mkdir BuildServer/Darwin/Build
78
79
80
	
	# debug option for py2app, if needed
	export DISTUTILS_DEBUG=0
Jamie Hall's avatar
Jamie Hall committed
81

82
    cd BuildServer/Darwin/Scripts
Jamie Hall's avatar
Jamie Hall committed
83
84

	/usr/local/bin/python build.py py2app
85
	
86
87
88
89
90
	rc=$?
	if [[ $rc != 0 ]]; then
		echo -e "$ROUGE""Cannot build app." "$NORMAL"
		exit 1
	fi
91
92
	
    cd ../Build
Jamie Hall's avatar
Jamie Hall committed
93

94
95
	# Do some manual cleanup, e.g.
	# matplotlib/tests ==> 45.2 Mb
96
97
98
	rm -rf dist/MDANSE.app/Contents/Resources/lib/python2.7/matplotlib/tests
	rm -rf dist/MDANSE.app/Contents/Resources/mpl-data/sample_data 
	
99
	#Add MDANSE version file (should read the version from the bundle with pyobjc, but will figure that out later)
100
101
102
103
104
105
	echo "$BUILD_NAME b$REV_NUMBER"> dist/MDANSE.app/Contents/Resources/version
	
	rm -f ./MDANSE.dmg
	rm -f ./rw.MDANSE.dmg
	
	hdiutil unmount /Volumes/MDANSE -force -quiet
Jamie Hall's avatar
Jamie Hall committed
106
	
107
108
	sleep 5
	
109
	../Tools/create-dmg/create-dmg --background "../Resources/background.jpg" --volname "MDANSE" --window-pos 200 120 --window-size 800 400 --icon MDANSE.app 200 190 --hide-extension MDANSE.app --app-drop-link 600 185 MDANSE.dmg ./dist
eric pellegrini's avatar
eric pellegrini committed
110
	
eric pellegrini's avatar
eric pellegrini committed
111
	curl -T MDANSE.img ftp://$CI_FTP_USER_USERNAME:$CI_FTP_USER_PASSWORD@ftp.ill.fr/mdanse/
112
113
114
115
	exit
fi