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.10 2004/08/18 16:16:56 mlh-pl_rpm Exp $
11 CVSROOT=bui-pl_rpm@cvs.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
80 # XXX Hack to store the pup key as well as the bui key
82 for i in `grep -l "BEGIN.*PRIVATE KEY" $HOME/.ssh/*` ; do
83 SSH_ASKPASS=/bin/false ssh-add $i
87 cvs -d ${CVSROOT} export -r ${TAG} -d ${BASE} ${MODULE}
90 if [ $? -ne 0 ] ; then
91 # Notify recipient of failure or just dump to stdout
92 if [ -n "$MAILTO" ] ; then
93 NOTIFY="mail -s 'Failures for ${BASE}' $MAILTO"
99 if [ -f ${BASE}/log ] ; then
100 tail -100 ${BASE}/log
105 elif [ -n "$BUILDS" ] ; then
106 # Remove old nightly runs
107 echo "cd ${ALPHA_ROOT} && ls -t | sed -n ${BUILDS}~1p | xargs rm -rf" | ssh ${ALPHA_BOOT} sh -s
108 # Update alpha node repository
109 for i in RPMS SRPMS ; do
110 ssh ${ALPHA_BOOT} mkdir -p ${ALPHA_ROOT}/${BASE}/${i}
111 find ${BASE}/${i} -type f | xargs -i scp {} ${ALPHA_BOOT}:${ALPHA_ROOT}/${BASE}/${i}
112 ssh ${ALPHA_BOOT} yum-arch ${ALPHA_ROOT}/${BASE}/${i} >/dev/null
115 ssh ${ALPHA_BOOT} ln -nsf ${ALPHA_ROOT}/${BASE}/RPMS/ ${ALPHA_RPMS}
118 # Kill the current agent