package.sh 3.38 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/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"

20
21
22
23
if [ -n "${RUN_NIGHTLY_BUILD}" ]
then
    VERSION_NAME="devel"
else
eric pellegrini's avatar
eric pellegrini committed
24
25
26
27
28
29
30
    if [[ ${CI_BUILD_TAG} =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]
    then
        VERSION_NAME=${BASH_REMATCH[1]}
    else
        echo -e "$ROUGE""Invalid version number ${CI_BUILD_TAG}" "$NORMAL"
        exit
    fi
31
fi
Jamie Hall's avatar
Jamie Hall committed
32
export VERSION_NAME
33

34
35
36
##Select the build target
BUILD_TARGET=darwin

Jamie Hall's avatar
Jamie Hall committed
37
cd ../../../
38

39
40
# old way to get MDANSE version
#declare -x MDANSE_VERSION=$(perl -pe '($_)=/([0-9]+([.][0-9]+)+)/' MDANSE/__pkginfo__.py)
Jamie Hall's avatar
Jamie Hall committed
41
42

# Which version name are we appending to the final archive
43
TARGET_DIR=MDANSE-${VERSION_NAME}-${BUILD_TARGET}
Jamie Hall's avatar
Jamie Hall committed
44
45
46
47
48

# 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)
49
REV_NUMBER=$(git rev-list --count HEAD)
Jamie Hall's avatar
Jamie Hall committed
50
echo -e "$BLEU""Revision number = ${REV_NUMBER}" "$NORMAL"
Jamie Hall's avatar
Jamie Hall committed
51
52
53

# Add current revision number to python source code (will appear in "About..." dialog)
# see http://stackoverflow.com/questions/7648328/getting-sed-error
54
sed -i '' 's/.*__version__.*/__version__ = \"${VERSION_NAME}\"/' MDANSE/__pkginfo__.py
Jamie Hall's avatar
Jamie Hall committed
55
sed -i '' 's/.*__revision__.*/__revision__ = \"${REV_NUMBER}\"/' MDANSE/__pkginfo__.py
Jamie Hall's avatar
Jamie Hall committed
56
57
58
59
60
61
62
63
64
65
66
67
68
69

# Now build last version and install it in our homebrewed python
echo -e "$BLEU""Building MDANSE" "$NORMAL"

# 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
Jamie Hall's avatar
Jamie Hall committed
70
71
/usr/local/bin/python setup.py build >> BuildServer/Darwin/Scripts/build_log.txt 2>&1
/usr/local/bin/python setup.py install >> BuildServer/Darwin/Scripts/build_log.txt 2>&1
Jamie Hall's avatar
Jamie Hall committed
72
73

# Performs the unit tests
Jamie Hall's avatar
Jamie Hall committed
74
75
76
cd Tests/UnitTests
nosetests --verbosity=3 -P .
cd ../..
Jamie Hall's avatar
Jamie Hall committed
77

Jamie Hall's avatar
Jamie Hall committed
78
79
80
81
cd Tests/FunctionalTests/Jobs
python BuildJobTests.py
nosetests --verbosity=3 --exe -P .
cd ../../..
Jamie Hall's avatar
Jamie Hall committed
82
83
84
85

echo -e "$BLEU""Packaging MDANSE" "$NORMAL"
rm -rf BuildServer/Darwin/Build
mkdir BuildServer/Darwin/Build
86

Jamie Hall's avatar
Jamie Hall committed
87
88
89
90
91
# debug option for py2app, if needed
export DISTUTILS_DEBUG=0

cd BuildServer/Darwin/Scripts

Jamie Hall's avatar
Jamie Hall committed
92
/usr/local/bin/python build.py py2app >> build_log.txt 2>&1
Jamie Hall's avatar
Jamie Hall committed
93
94
95
96
97

rc=$?
if [[ $rc != 0 ]]; then
	echo -e "$ROUGE""Cannot build app." "$NORMAL"
	exit 1
98
99
fi

Jamie Hall's avatar
Jamie Hall committed
100
101
102
103
104
cd ../Build

# Do some manual cleanup, e.g.
# matplotlib/tests ==> 45.2 Mb
rm -rf dist/MDANSE.app/Contents/Resources/lib/python2.7/matplotlib/tests
105
rm -rf dist/MDANSE.app/Contents/Resources/mpl-data/sample_data
Jamie Hall's avatar
Jamie Hall committed
106

107
MDANSE_DMG=MDANSE-${VERSION_NAME}-${BUILD_TARGET}.dmg
Jamie Hall's avatar
Jamie Hall committed
108

Jamie Hall's avatar
Jamie Hall committed
109
#Add MDANSE version file (should read the version from the bundle with pyobjc, but will figure that out later)
110
echo "${VERSION_NAME}" > dist/MDANSE.app/Contents/Resources/version
Jamie Hall's avatar
Jamie Hall committed
111
112
113
114
115
116
117
118

rm -f ./${MDANSE_DMG}
rm -f ./rw.${MDANSE_DMG}

hdiutil unmount /Volumes/MDANSE -force -quiet

sleep 5

Jamie Hall's avatar
CI    
Jamie Hall committed
119
../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
Jamie Hall's avatar
Jamie Hall committed
120
121

exit