3 # PlanetLab release build script. Intended to be used by scripts and
4 # crontabs to build nightly releases (default). Can also be invoked
5 # manually to build a tagged release (-r) in the current directory.
7 # $Id: build.sh,v 1.15 2004/10/04 22:29:19 mlhuang Exp $
11 CVSROOT=:pserver:anon@build.planet-lab.org:/cvs
17 # Alpha node repository
18 ALPHA_BOOT=build@boot.planet-lab.org
19 ALPHA_ROOT=/www/planetlab/install-rpms/archive/planetlab-alpha
20 ALPHA_RPMS=/www/planetlab/install-rpms/planetlab-alpha
22 # Export certain variables
26 while getopts "d:r:m:b:x:h" opt ; do
44 echo "usage: `basename $0` [OPTION]..."
45 echo " -d directory CVS repository root (default $CVSROOT)"
46 echo " -r revision CVS revision to checkout (default $TAG)"
47 echo " -m address Notify recipient of failures (default: none)"
48 echo " -b base Run operations in specified base directory (default $BASE)"
49 echo " -x N Remove all but the last N runs from the base directory (default: none)"
55 # Base operations in specified directory
60 if [ -n "$BUILDS" ] ; then
61 ls -t | sed -n ${BUILDS}~1p | xargs rm -rf
64 # Create a unique build base
65 BASE=${TAG/HEAD/`date +%Y.%m.%d`}
67 while ! mkdir ${BASE}${i} 2>/dev/null ; do
68 [ -z ${i} ] && BASE=${BASE}.
70 if [ $i -gt 100 ] ; then
71 echo "$0: Failed to create release directory `pwd`/${BASE}${i}"
77 # Redirect output from here
82 cvs -d ${CVSROOT} export -r ${TAG} -d ${BASE} ${MODULE}
86 if [ $rc -ne 0 ] ; then
87 # Notify recipient of failure
88 if [ -n "$MAILTO" ] ; then
89 tail -100 ${BASE}/log | mail -s "Failures for ${BASE}" $MAILTO
91 elif [ -n "$BUILDS" ] ; then
92 # Remove old nightly runs
93 echo "cd ${ALPHA_ROOT} && ls -t | sed -n ${BUILDS}~1p | xargs rm -rf" | ssh ${ALPHA_BOOT} /bin/bash -s
94 # Update alpha node repository
95 for i in RPMS SRPMS ; do
96 ssh ${ALPHA_BOOT} mkdir -p ${ALPHA_ROOT}/${BASE}/${i}
97 find ${BASE}/${i} -type f | xargs -i scp {} ${ALPHA_BOOT}:${ALPHA_ROOT}/${BASE}/${i}
98 ssh ${ALPHA_BOOT} yum-arch ${ALPHA_ROOT}/${BASE}/${i} >/dev/null
101 ssh ${ALPHA_BOOT} ln -nsf ${ALPHA_ROOT}/${BASE}/RPMS/ ${ALPHA_RPMS}