-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathbuild.sh
executable file
·437 lines (348 loc) · 9.47 KB
/
build.sh
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
#!/bin/bash
#
# Headless building script
#
# Used environment variables
#
# $WORKSPACE : root path containing all build artifacts
# $OSNAME : the target platform name i.e. linux, macosx, windows
# $OSARCH : the target platform architecture i.e. i386, x64
# $BUILD_REPO : (optional) shared path to cache thirdy parts tools compiled binaries
# $GIT_REVISION : (optional) the svn revision used to mark this build
# $VERSION : (optional) the version used to tag this build
# $BUILD_REPO : (optional) the path where compiled binaries will be cached
# $USER_BIN : (deprecated) path where store binary to be used
#
# Required dependencies:
# - wget
# - antiword
# - installbuild (http://installbuilder.bitrock.com)
#
#
# Release flag
#
export RELEASE=${RELEASE:-0}
#
# default SVN revision number
#
if [ -z $GIT_REVISION ]; then
GIT_REVISION=`( cd $WORKSPACE/tcoffee; git rev-parse --short HEAD; )`
fi
if [ "$GIT_REVISION" == "" ]; then
echo 'Missing $GIT_REVISION value. Cannot continue the build process.'
exit 1
fi
#
# The build number is generated automatically by the build containg (Hudson/Jenkins)
#
if [ -z $BUILD_NUMBER ]; then
BUILD_NUMBER=0
fi
#
# Define the VERSION number
export VERSION="`$WORKSPACE/tcoffee/lib/perl/lib/perl4makefile/read_program_version.pl -path=$WORKSPACE/tcoffee/lib/version -print`"
#export VERSION="`cat $WORKSPACE/tcoffee/lib/version/version_number.version`"
#
# The date timestamp string contains also the svn revision number
#
if [ -z $DATE ]; then
export DATE=`date +"%Y-%m-%d %H:%M:%S"`
fi
#
# BUILD_INFO
#
if [ -z $BUILD_INFO ]; then
export BUILD_INFO="`date +"%Y-%m-%d %H:%M:%S"` - Revision $GIT_REVISION - Build $BUILD_NUMBER"
fi
# default bin path
if [ -z $USER_BIN ]; then
export USER_BIN=$WORKSPACE/bin/
fi
#
# default third party binaries cache location
#
if [ -z $BUILD_REPO ]; then
export BUILD_REPO=$WORKSPACE/repo
fi
#
# default install builder location
#
if [ -z $INSTALLER ]; then
INSTALLER=$HOME/installbuilder/bin/builder
if [ $OSNAME == "macosx" ]
then
INSTALLER=$HOME/installbuilder/bin/Builder.app/Contents/MacOS/installbuilder.sh
fi
fi
#
# The Dropbox folder where to copy produces binaries
#
if [ -z $DROPBOX ]; then
DROPBOX=$HOME/Dropbox/upstream;
fi
#
# script directives
#
set -e
set -u
set -o nounset
set -o errexit
#set -x
#
# other common variables
#
SANDBOX=$WORKSPACE/sandbox
PERLM=$SANDBOX/perl
_SRC=$WORKSPACE/tcoffee/t_coffee/src
_G_USR=cbcrg.lab
_G_PWD=Zf4Na7vf8SX8
#
# Define the distribution directory that will contain produced artifacts
#
DIST_ROOT=$SANDBOX/distributions
if [ $RELEASE == 1 ]; then
DIST_BASE=$SANDBOX/distributions/Stable/
else
DIST_BASE=$SANDBOX/distributions/Beta/
fi
# Distribution package file name
DIST_DIR=$DIST_BASE/$VERSION
DIST_NAME=T-COFFEE_distribution_$VERSION.tar.gz
DIST_HOST='tcoffeeo@tcoffee.org:~/public_html/Packages/'
# Installer package file name
INST_NAME=T-COFFEE_installer_"$VERSION"_"$OSNAME"_"$OSARCH"
UNTARED=$SANDBOX/untared_distributions/T-COFFEE_distribution_"$VERSION"
TCDIR=$SANDBOX/build
TCBINDIR=$SANDBOX/build/bin/$OSNAME
#
# exported variabled (required by 'generic_makefile')
#
export HOME2=$SANDBOX
#
# Display the current environment
#
function env()
{
echo "[ env ]"
echo "- PWD : $PWD"
echo "- PATH : $PATH"
echo "- HOME : $HOME"
echo "- WORKSPACE : $WORKSPACE"
echo "- OSNAME : $OSNAME"
echo "- OSARCH : $OSARCH"
echo "- VERSION : $VERSION"
echo "- DATE : $DATE"
echo "- RELEASE : $RELEASE"
echo "- BUILD_INFO : $BUILD_INFO"
echo "- BUILD_REPO : $BUILD_REPO"
echo "- GIT_REVISION: $GIT_REVISION"
echo "- USER_BIN : $USER_BIN"
echo ". SANDBOX : $SANDBOX"
echo ". _SRC : $_SRC"
echo ". UNTARED : $UNTARED"
echo ". INSTALLER : $INSTALLER"
echo ". TCDIR : $TCDIR"
echo ". PERLM : $PERLM"
echo ". DIST_BASE : $DIST_BASE"
echo ". DIST_DIR : $DIST_DIR"
echo ". DIST_NAME : $DIST_NAME"
echo ". DIST_HOST : $DIST_HOST"
echo ". INST_NAME : $INST_NAME"
}
#
# clean current sandbox content
#
function clean()
{
echo "[ clean ]"
rm -rf $SANDBOX/*
}
#
# rename temporary makefile and run it
#
function build_dist()
{
echo "[ build_dist ]"
cd $_SRC
make distribution || true
# check that the distribution file has been created
DIST_FILE=$SANDBOX/distributions/$DIST_NAME
if [ ! -f $DIST_FILE ]
then
echo "Destination file has not been created: $DIST_FILE"
exit 1
fi
# Move created package to distribution directory define by $DIST_DIR
mkdir -p $DIST_BASE/$VERSION
mv $DIST_FILE $DIST_BASE/$VERSION
# Create a file containing the latest version number
echo $VERSION > $DIST_BASE/.version
}
#
# Upload all packages
#
function upload()
{
echo "[ upload_distribution ]"
scp -B -2 -r -i $WORKSPACE/tcoffee/build/tcoffee_org_id $DIST_BASE $DIST_HOST
}
#
# Compile T-Coffee distribution
# - distribution sources are located at $UNTARED path
# - target binaries will be located at $TCDIR
#
function build_binaries()
{
echo "[ build_binaries ]"
rm -rf $TCDIR
mkdir -p $TCDIR
mkdir -p $TCDIR/bin/$OSNAME
# Make sure that does not exist already binaries
rm -rf $UNTARED/bin
mkdir -p $UNTARED/bin/$OSNAME
# create t-coffee binaries installation
cd $UNTARED
./install all -tclinkdb=./tclinkdb.txt -repo=$BUILD_REPO -tcdir=$TCDIR -exec=$TCBINDIR || true
# Check that the binary has successfully compiled
if [ ! -f $TCBINDIR/t_coffee ]
then
echo "Target 't_coffee' binary has not been compiled"
exit 1
fi
# in order to keep compatibility with black-coffee.jar
cp $TCBINDIR/t_coffee $TCDIR/bin
# add perl modules
cp -r $PERLM $TCDIR
#mkdir -p $TCDIR/perl
#cp $WORKSPACE/tcoffee/build/cpanm $TCDIR/perl
#chmod +x $TCDIR/perl/cpanm
# add gfortran libraries
if [ $OSNAME == "macosx" ]
then
mkdir -p $TCDIR/gfortran
cp /usr/local/gfortran/lib/libgfortran.3.dylib $TCDIR/gfortran
cp /usr/local/gfortran/lib/libgfortran.a $TCDIR/gfortran
cp /usr/local/gfortran/lib/libgfortran.la $TCDIR/gfortran
fi
#
# add extra pack packages
#
# + hmmtop
cp $WORKSPACE/tcoffee/build/extra/hmmtop/2.1/$OSNAME-$OSARCH/* $TCDIR/plugins/$OSNAME
# + secondary_struc.py (by Carsten)
cp $WORKSPACE/tcoffee/build/extra/secondary_struc.py $TCDIR/plugins/$OSNAME/secondary_struc.py
chmod +x $TCDIR/plugins/$OSNAME/secondary_struc.py
# HH_search
cp $WORKSPACE/tcoffee/build/extra/HHsearch_1.5.1/$OSNAME-$OSARCH/* $TCDIR/plugins/$OSNAME/
}
#
# download perl packages
#
function build_perlm() {
echo "[ build_perlm ]"
chmod +x $WORKSPACE/tcoffee/build/cpanm
$WORKSPACE/tcoffee/build/cpanm -q -n -l $PERLM -L $PERLM SOAP::Lite XML::Simple LWP
}
#
# create platform independent paltform distribution
#
function pack_binaries() {
echo "[ pack_binaries ]"
echo Package name: $INST_NAME
# remove the t_coffee binaries from 'plugins' folder
# it have to exist in 'bin' folder
# Cedric This should now be fixed
# rm -rf $TCDIR/plugins/$OSNAME/t_coffee
# copy the sources
rm -rf $TCDIR/src
cp -r $UNTARED/t_coffee_source $TCDIR/src
find $TCDIR/src -name '*.o_*' | xargs rm -rf {}
find $TCDIR/src -name 't_coffee' | xargs rm -rf {}
find $TCDIR/src/ -type f -exec chmod 644 '{}' \;
# invoke the install builder
mkdir -p $DIST_DIR
"$INSTALLER" build $WORKSPACE/tcoffee/build/tcoffee-installer.xml --setvars product_version=$VERSION untared=$UNTARED osname=$OSNAME tcdir=$TCDIR outdir=$DIST_DIR outname=$INST_NAME
# mac osx specific step
if [ $OSNAME == "macosx" ]
then
$WORKSPACE/tcoffee/build/mkdmg.sh $DIST_DIR/$INST_NAME.app
mv $DIST_DIR/$INST_NAME.app.dmg $DIST_DIR/$INST_NAME.dmg
rm -rf $DIST_DIR/$INST_NAME.app
fi
# add execution attribute to the generated binary
if [ $OSNAME == "linux" ]
then
mv $DIST_DIR/$INST_NAME.run $DIST_DIR/$INST_NAME.bin
chmod u+x $DIST_DIR/$INST_NAME.bin
fi
}
function pack_tarball() {
# creates a tar with all precompiled binaries
if [[ $OSARCH == "x64" && $OSNAME == 'linux' ]]
then
echo "[ pack_tarball ]"
cd $SANDBOX
$DIST_DIR/$INST_NAME.bin --mode unattended --user_email tcoffee.msa@gmail.com --prefix $PWD/$INST_NAME
tar -zcvf $INST_NAME.tar.gz $INST_NAME/
mv $INST_NAME.tar.gz $DIST_DIR/
rm -rf $PWD/$INST_NAME
cd -
fi
}
function build_and_pack_stable() {
echo "[ build_and_pack_stable ]"
export CFLAGS="-O3"
export INST_NAME=T-COFFEE_installer_"$VERSION"_"$OSNAME"_"$OSARCH"
build_perlm
build_binaries
pack_binaries
pack_tarball
}
function build_and_pack_debug() {
echo "[ build_and_pack_debug ]"
export CFLAGS="-g -O1"
export INST_NAME=T-COFFEE_installer_"$VERSION"_"$OSNAME"_"$OSARCH"_debug
export DATE="`date +"%Y-%m-%d %H:%M:%S"` - Revision $GIT_REVISION - DEBUG"
build_binaries
pack_binaries
}
#
# Copy to dropbox for publishing
#
function copy_to_dropbox() {
echo "[ copy_to_dropbox ]"
mkdir -p $DROPBOX
if [ $RELEASE == 1 ]; then
DROPBOX_DIR=$DROPBOX/stable/"$OSNAME"_"$OSARCH"
else
DROPBOX_DIR=$DROPBOX/beta/"$OSNAME"_"$OSARCH"
fi
rm -rf $DROPBOX_DIR
mkdir -p $DROPBOX_DIR
cp -r $TCDIR/* $DROPBOX_DIR
}
#
#
# Execute all T-coffee core tasks (no server related)
#
function tcoffee() {
echo "[ tcoffee ]"
mkdir -p $SANDBOX && echo -n $VERSION > $SANDBOX/.version
build_dist
build_and_pack_stable
}
#
# when at least a parameter is specified they are invoked as function call
#
if [ $# -gt 0 ]
then
while [ "$*" != "" ]
do
echo "Target: $1"
$1
shift
done
else
echo "Usage: build <target>"
exit 1
fi