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 # Mark Huang <mlhuang@cs.princeton.edu>
8 # Copyright (C) 2003-2005 The Trustees of Princeton University
10 # $Id: build.sh,v 1.28 2005/05/04 17:43:14 mlhuang Exp $
14 CVSROOT=:pserver:anon@cvs.planet-lab.org:/cvs
20 # cron does not set USER?
21 [ -z "$USER" ] && export USER=$LOGNAME
23 # Export certain variables
27 while getopts "d:r:m:b:x:h" opt ; do
45 echo "usage: `basename $0` [OPTION]..."
46 echo " -d directory CVS repository root (default $CVSROOT)"
47 echo " -r revision CVS revision to checkout (default $TAG)"
48 echo " -m address Notify recipient of failures (default: none)"
49 echo " -b base Run operations in specified base directory (default $BASE)"
50 echo " -x N Remove all but the last N runs from the base directory (default: none)"
56 # Base operations in specified directory
61 if [ -n "$BUILDS" ] ; then
62 ls -t | sed -n ${BUILDS}~1p | xargs rm -rf
65 # Create a unique build base
66 BASE=${TAG/HEAD/`date +%Y.%m.%d`}
68 while ! mkdir ${BASE}${i} 2>/dev/null ; do
69 [ -z ${i} ] && BASE=${BASE}.
71 if [ $i -gt 100 ] ; then
72 echo "$0: Failed to create release directory `pwd`/${BASE}${i}"
78 # Redirect output from here
83 cvs -d ${CVSROOT} export -r ${TAG} -d ${BASE} ${MODULE}
85 make -C ${BASE} install BASE=$BASE BUILDS=$BUILDS
88 if [ $rc -ne 0 ] ; then
89 # Notify recipient of failure
90 if [ -n "$MAILTO" ] ; then
91 tail -100 ${BASE}/log | mail -s "Failures for ${BASE}" $MAILTO