build_deb.sh 3.61 KB
Newer Older
eric pellegrini's avatar
eric pellegrini committed
1
#!/bin/bash
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

export ARCH=$1
export DISTRO=$2

#############################
# 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"

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

33
34
35
36
37
38
39
##Select the build target
BUILD_TARGET=debian

cd
cd $CI_PROJECT_DIR

# Get revision number from git (without trailing newline)
eric pellegrini's avatar
eric pellegrini committed
40
REV_NUMBER=$(git rev-list --count HEAD)
Jamie Hall's avatar
Jamie Hall committed
41
echo -e "$BLEU""Revision number = ${REV_NUMBER}<--" "$NORMAL"
42
43
44

# Add current revision number to python source code (will appear in "About..." dialog)
# see http://stackoverflow.com/questions/7648328/getting-sed-error
45
46
sed -i "s/.*__version__.*/__version__ = \"${VERSION_NAME}\"/" MDANSE/__pkginfo__.py
sed -i "s/.*__revision__.*/__revision__ = \"${REV_NUMBER}\"/" MDANSE/__pkginfo__.py
47
sed -i "s/.*__date__.*/__date__ = \"`date +"%d-%m-%Y"`\"/" MDANSE/__pkginfo__.py
Jamie Hall's avatar
Jamie Hall committed
48

49
#MDANSE_VERSION=$(grep -Po '(?<=__version__ = \")\d.\d.\d' MDANSE/__pkginfo__.py)
50
51
52

# Now build last version
echo "$BLEU""Building MDANSE" "$NORMAL"
53
python setup.py build
54

55
56
57
58
59
60
61
62
63
64
65
66
export PYTHONPATH=${PWD}/build/lib.linux-x86_64-2.7

# 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 ../../..

67
68
echo "$BLEU""Build debian tree" "$NORMAL"

69
# Set automatically the good version number for the Debian control file
70
sed -i "s/Version:.*/Version: ${VERSION_NAME}/g" BuildServer/Debian/DEBIAN/control
71

Jamie Hall's avatar
CI    
Jamie Hall committed
72
DEBIAN_ROOT_DIR=BuildServer/Debian/Build
73
74

# Copy all the debian files (e.g. control, copyright, md5sum ...) into DEBIAN directory
75
mkdir ${DEBIAN_ROOT_DIR}
76
cp -r BuildServer/Debian/DEBIAN ${DEBIAN_ROOT_DIR}/
77
78
79
80
81
chmod -R 755 ${DEBIAN_ROOT_DIR}/DEBIAN

# Build the /usr/share/applications directory inside the debian root directory and copy the mdanse desktop file inside
DEBIAN_APP_DIR=${DEBIAN_ROOT_DIR}/usr/share/applications
mkdir -p ${DEBIAN_APP_DIR}
82
cp BuildServer/Debian/MDANSE.desktop ${DEBIAN_APP_DIR}/
83
84
85
86

# Build the /usr/share/pixmaps directory inside the debian root directory and copy the mdanse icon file inside
DEBIAN_PIXMAPS_DIR=${DEBIAN_ROOT_DIR}/usr/share/pixmaps
mkdir -p ${DEBIAN_PIXMAPS_DIR}
87
cp MDANSE/GUI/Icons/mdanse.png ${DEBIAN_PIXMAPS_DIR}/
88
89
90
91

# Build the /usr/local/bin directory inside the debian root directory and copy the mdanse scripts inside
DEBIAN_BIN_DIR=${DEBIAN_ROOT_DIR}/usr/local/bin
mkdir -p ${DEBIAN_BIN_DIR}
eric pellegrini's avatar
eric pellegrini committed
92
cp build/scripts-2.7/* ${DEBIAN_BIN_DIR}/
93
94
95
96
97
dos2unix ${DEBIAN_BIN_DIR}/mdanse_*

# Build the usr/local/lib/python2.7/dist-packages directory inside the debian root directory and copy the MDANSE package inside
DEBIAN_DIST_DIR=${DEBIAN_ROOT_DIR}/usr/local/lib/python2.7/dist-packages
mkdir -p ${DEBIAN_DIST_DIR}
eric pellegrini's avatar
eric pellegrini committed
98
cp -r build/lib.linux-x86_64-2.7/MDANSE ${DEBIAN_DIST_DIR}
99
100
101
102
# also copy the localy installed ScientificPython and MMTK
cp -r /usr/local/lib/python2.7/dist-packages/Scientific* ${DEBIAN_DIST_DIR}
cp -r /usr/local/lib/python2.7/dist-packages/MMTK* ${DEBIAN_DIST_DIR}

103
104
# Compute the Installed-Size field for the debian package
instSize=$(du ${DEBIAN_ROOT_DIR} -b -s | cut -f1)
105
sed -i "s/Installed-Size:.*/Installed-Size: $((1+(instSize/1024)))/g" ${DEBIAN_ROOT_DIR}/DEBIAN/control
106

107
export TMPDIR=.
108
fakeroot dpkg-deb -b ${DEBIAN_ROOT_DIR} ${DEBIAN_ROOT_DIR}/MDANSE-${VERSION_NAME}-${DISTRO}-${ARCH}.deb