2 ##export PATH=/usr/sbin:/sbin:/usr/bin:/bin
3 # use svn propset svn:keywords Revision to enable this
4 REVISION=$(echo '$Revision$' | sed -e 's,\$,,g' -e 's,^\w*:\s,,' )
10 # default values, tunable with command-line options
11 SVNPATH="svn+ssh://build@svn.onelab.eu/svn/build/trunk"
13 MAILTO="onelab-build@onelab.eu"
14 PLDISTROTAGS=onelab-tags.mk
15 TESTBUILDURL="http://build.onelab.eu/"
16 TESTBOX=onelab-test.inria.fr
17 TESTBOXSSH=root@onelab-test.inria.fr
18 TESTSVNPATH="svn+ssh://build@svn.onelab.eu/svn/new_plc_api/trunk/plctest"
19 TESTSCRIPT=TestMain.py
21 # plc chroot runs in UTC
22 DATE=$(date -u +'%Y.%m.%d')
24 ### in the root context
25 function do_chroot () {
26 chroot /plc/devel/root su - build <<EOF
27 $CHROOTBINDIR/$COMMAND $@
32 # Notify recipient of failure or success, manage various stamps
35 (echo -n "============================== $COMMAND: failure at" ; date ; tail -c 20k ${BUILD}/log-build.txt) >> ${BUILD}.broken
36 if [ -n "$MAILTO" ] ; then
37 tail -c 8k ${BUILD}/log-build.txt | mail -s "Failures for ${BUILD}" $MAILTO
45 if [ -n "$MAILTO" ] ; then
46 (echo "http://build.onelab.eu/$DISTRO/$BASE" ; echo "Completed on $(date)" ) | mail -s "Successfull build in ${BUILD}" $MAILTO
54 function create_base () {
56 while ! mkdir ${BASE}${i} 2>/dev/null ; do
57 [ -z ${i} ] && BASE=${BASE}.
59 if [ $i -gt 100 ] ; then
60 echo "$0: Failed to create release directory `pwd`/${BASE}${i}"
67 function use_base () {
68 [ ! -d $BASE ] && mkdir $BASE
69 if [ ! -d $BASE ] ; then
70 echo $COMMAND failed to create base $BASE
81 echo -n "============================== Starting $COMMAND:build on "
87 # if TAGSTAG specified : update PLDISTROTAGS with this tag
88 if [ -n "$TAGSTAG" ] ; then
90 svn up -r $TAGSTAG $PLDISTROTAGS
96 echo "Running make IN build $(pwd)"
97 make stage1=true ${MAKEOPTS[@]} PLDISTROTAGS=${PLDISTROTAGS} PLDISTRO=${DISTRO} ${MAKEVARS[@]} -C $BASE
98 # in case we use an older build
100 make ${MAKEOPTS[@]} PLDISTROTAGS=${PLDISTROTAGS} PLDISTRO=${DISTRO} ${MAKEVARS[@]} -C $BASE versions
102 make ${MAKEOPTS[@]} PLDISTROTAGS=${PLDISTROTAGS} PLDISTRO=${DISTRO} ${MAKEVARS[@]} -C $BASE $MAKETARGETS
104 # restore silent mode - otherwise cron gets it
108 function runtest () {
115 echo -n "============================== Starting $COMMAND:runtest on "
119 ### compute URL to the myplc package
121 buildname=$(basename $build)
123 rpm=$(find RPMS -name myplc\*.rpm )
124 url=${TESTBUILDURL}${DISTRO}/${buildname}/${rpm}
125 ### checkout the test material
126 svn co ${TESTSVNPATH} plctest
127 # compute test directory name on test box
128 testdir=plctest-${buildname}
129 # rsync/push test material onto the test box
130 ssh ${TESTBOXSSH} mkdir -p ${testdir}
131 rsync -a -v plctest/ ${TESTBOXSSH}:${testdir}
132 # invoke test on testbox
133 ssh ${TESTBOXSSH} python -u ${testdir}/${TESTSCRIPT} ${url}
134 #invoke make install from build to the testbox
135 make install PLCHOST=${TESTBOX}
137 if [ "$?" != 0 ] ; then
144 function show_env () {
148 echo SVNPATH=$SVNPATH
149 echo MAKEVARS="${MAKEVARS[@]}"
150 echo MAKEOPTS="${MAKEOPTS[@]}"
151 echo PLDISTROTAGS="$PLDISTROTAGS"
152 echo TAGSTAG="$TAGSTAG"
153 echo "XXXXXXXXXXXXXXXXXXXX Contents of tags definition file $PLDISTROTAGS"
154 cat $BASE/$PLDISTROTAGS
155 echo "XXXXXXXXXXXXXXXXXXXX end tags definition"
159 echo "Usage: $COMMAND [option] make-targets"
160 echo "This is revision $REVISION"
161 echo "Supported options"
162 echo " -b BASE - may include @, then replaced with current date"
163 echo " -u : uses directory given as BASE as is, even if already exists"
165 echo " -t PLDISTROTAGS"
166 echo " -r TAGSTAG - a tag that refers to PLDISTROTAGS - defaults to HEAD"
167 echo " -s MAKEVAR=value - spaces in value are not supported"
168 echo " -n dry-run : -n passed to make - no mail sent"
171 echo " -B : run build only"
172 echo " -T : run test only"
178 if [ -d /plc/devel/data ] ; then
185 while getopts "b:ud:t:r:s:nm:s:BTh" opt ; do
190 t) PLDISTROTAGS=$OPTARG ;;
191 r) TAGSTAG=$OPTARG ;;
192 s) MAKEVARS=(${MAKEVARS[@]} $OPTARG) ;;
193 n) MAILTO="" ; MAKEOPTS=(${MAKEOPTS[@]} -n) ;;
195 s) SVNPATH=$OPTARG ;;
197 T) DO_BUILD= ; USEOLD=true ;;
202 shift $(($OPTIND - 1))
209 ### set BASE from DISTRO, if unspecified
210 [ -z "$BASE" ] && BASE=${DISTRO}
211 BASE=$(echo ${BASE} | sed -e "s,@,${DATE},g")
213 if [ -n "$USEOLD" ] ; then
220 if [ -n "$DO_SEND" ] ; then
221 test_sendmail ${BUILD} >> ${BUILD}/log-build.txt 2>&1
224 if [ -n "$DO_BUILD" ] ; then
225 build >> ${BUILD}/log-build.txt 2>&1
226 touch ${BUILD}.build-ok
229 if [ -n "$DO_TEST" ] ; then
230 runtest ${BUILD} >> ${BUILD}/log-build.txt 2>&1
233 success >> ${BUILD}/log-build.txt 2>&1