File: ost-nightly-build.sh

package info (click to toggle)
openstructure 2.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 206,240 kB
  • sloc: cpp: 188,571; python: 36,686; ansic: 34,298; fortran: 3,275; sh: 312; xml: 146; makefile: 29
file content (169 lines) | stat: -rw-r--r-- 5,844 bytes parent folder | download | duplicates (2)
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash

## Script to compile a nightly build of OpenStructure from the git repo
##
## This script requires that you can clone the OST repo and it uses the sciCORE 
## software stack for dependencies so it will only work in the sciCORE login nodes
##
## Author: Pablo Escobar <pablo.escobarlopez@unibas.ch>


# print help if no arguments supplied or -h or --help
if [[ $# -eq 0 ]] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
	echo "Usage: $0 branch_to_clone"
	exit 1
fi	

function main {

CURRENT_DATE=$(date +"%Y%m%dT%H%M%SZ")
GIT_BRANCH=$1

# create a temporary directory to download the sources and do the build
TEMP_DIR="${TMPDIR}/${USER}/ost-builds/$CURRENT_DATE"
echo -e "\ncreating temporary dir to clone and build in $TEMP_DIR\n"
mkdir -p $TEMP_DIR

# clone the development branch of OST to $TEMP_DIR
git_cmd="git clone -b $GIT_BRANCH ssh://git@git.scicore.unibas.ch:2222/schwede/openstructure.git $TEMP_DIR/openstructure"
echo "cloning the OST code: $GIT_BRANCH branch"
echo -e "running $git_cmd"
$git_cmd

# sanity check to verify that the cloned branch exists
cd $TEMP_DIR/openstructure
git checkout $GIT_BRANCH
if [[ $? != 0 ]]; then
	echo -e "\ngit branch $GIT_BRANCH not found in cloned repository. Are you sure this is an existing branch?" 
	echo -e "Aborting.... \n" 
	exit 1
fi

# fetch the latest git commit ID. We will use this in the module name together with the branch name
cd $TEMP_DIR/openstructure
LATEST_COMMIT=`git rev-parse HEAD | cut -c1-8`

# create a tarball with the sources. We will pass this to easybuild
TARBALL_NAME="OpenStructure-nightly-${CURRENT_DATE}_${GIT_BRANCH}_commit${LATEST_COMMIT}.tar.bz2"
echo -e "\nCreating a tarball with the source code to feed EasyBuild"
echo -e "running tar -cjf $TARBALL_NAME openstructure"
cd $TEMP_DIR
tar -cjf $TARBALL_NAME openstructure

# create the installation directory if it doesn't exists
# by default $INSTALL_DIR is in the cluster shared scratch so the module
# can be used from any compute node
INSTALL_DIR="/scicore/scratch/$USER/ost-nightly-builds"
echo -e "\nCreating install dir $INSTALL_DIR if it doesn't exists"
if [ ! -d "$INSTALL_DIR" ]; then
	mkdir -p $INSTALL_DIR
fi

# create a easyconfig to build OST
echo -e "\nCreating an easyconfig in $TEMP_DIR/ost-easyconfig.eb based on the provided template"
generate_easyconfig_template  # this function is defined at the bottom of the script to improve readability

echo -e "\nSetting up the modules environment by executing 'source /etc/profile.d/lmod.sh'"
source /etc/profile.d/lmod.sh

echo -e "\nLoading the Easybuild module executing 'module load EasyBuild'"
module load EasyBuild

echo -e "\nRunning EasyBuild"
eb_command="eb --optarch=GENERIC --sourcepath=$TEMP_DIR --buildpath=$TEMP_DIR/easybuild_build_dir --installpath=$INSTALL_DIR $TEMP_DIR/ost-easyconfig.eb"
echo $eb_command
$eb_command

if [[ $? != 0 ]]; then
	echo -e "\nBuild failed. Not deleting temp dir $TEMP_DIR"
	exit 1
else
        echo -e "\nBuild completed succesfully. Deleting temp dir $TEMP_DIR"
	rm -fr $TEMP_DIR
	if [[ $? != 0 ]]; then
		echo -e "\nError deleting temp dir in $TEMP_DIR"
		exit 1
	else
		echo -e "\nrun 'module use $INSTALL_DIR/modules/all/' to add the new modules to your \$MODULEPATH"
		echo -e "If you don't see the new module try deleting your Lmod's cache doing 'rm ~/.lmod.d/.cache/*'\n"
	fi

fi

} # end of main function

function generate_easyconfig_template {

cat > $TEMP_DIR/ost-easyconfig.eb << EOF
# This file is an EasyBuild reciPY as per https://github.com/hpcugent/easybuild
# Author: Pablo Escobar Lopez
# sciCORE - University of Basel
# SIB Swiss Institute of Bioinformatics

easyblock = "CMakeMake"

name = 'OpenStructure-nightly'
version = '${CURRENT_DATE}'
versionsuffix = '_${GIT_BRANCH}_commit${LATEST_COMMIT}'

homepage = 'http://www.openstructure.org'
description = "Open-Source Computational Structural Biology Framework"

toolchain = {'name': 'goolf', 'version': '1.4.10'}

sources = ['$TARBALL_NAME']

builddependencies = [('CMake', '3.10.2')]

pythonversion = "3.6.6"
pythonshortversion = ".".join(pythonversion.split(".")[:-1])

dependencies = [
    ('Python', pythonversion),
    ('Boost', '1.53.0', '-Python-%s' % (pythonversion)),
    ('numpy', '1.9.1', '-Python-%s' % (pythonversion)),
    ('Qt', '4.8.4'),
    ('Eigen', '3.2.1'),
#   ('FFTW', '3.3.3'),  # this dependency is already included with toolchain goolf-1.4.10
    ('zlib', '1.2.8'),
    ('bzip2', '1.0.6'),
    ('libpng', '1.6.17'), 
    ('LibTIFF', '4.0.3'), 
    ('libjpeg-turbo', '1.4.0'), 
    ('OpenMM', '6.1-Linux64', '', True), 
    ('FFTW', '3.3.3', '-dynamic', ('gompi', '1.4.10')), 
]


configopts += " -DCOMPOUND_LIB=/scicore/home/schwede/GROUP/OpenStructure/ChemLib/1.6/compounds.chemlib"

configopts += " -DPython_ROOT_DIR=\$EBROOTPYTHON -DEIGEN3_INCLUDE_DIR=\$EBROOTEIGEN -DFFTW_LIBRARY=\$EBROOTFFTW/lib/libfftw3f.a -DFFTW_INCLUDE_DIR=\$EBROOTFFTW/include -DBOOST_ROOT=\$EBROOTBOOST -DQT_QMAKE_EXECUTABLE=\$EBROOTQT/bin/qmake -DBoost_USE_MULTITHREADED=OFF"

configopts += " -DENABLE_MM=1 -DOPEN_MM_LIBRARY=\$EBROOTOPENMM/lib/libOpenMM.so -DOPEN_MM_PLUGIN_DIR=\$EBROOTOPENMM/lib/plugins -DOPEN_MM_INCLUDE_DIR=\$EBROOTOPENMM/include"

runtest = 'check'

sanity_check_paths = { 
    'files': ["bin/ost", "bin/chemdict_tool"],
    'dirs': ["include/ost"],
}

# add \$INSTALLDIR/lib64/python3.6/dist-packages to PYTHONPATH
modextrapaths = {
    'PYTHONPATH': 'lib64/python%s/dist-packages' % (pythonshortversion)
}

# OST_ROOT env var points to install directory
modextravars = {
    'OST_ROOT': '%(installdir)s'
}

postinstallcmds = ["rm -fr %(installdir)s/share/openstructure/compounds.chemlib",
                   "cd %(installdir)s/share/openstructure/ && ln -s /scicore/home/schwede/GROUP/OpenStructure/ChemLib/1.6/compounds.chemlib compounds.chemlib",]

moduleclass = 'bio'
EOF

}

main "$@"