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.29 2005/05/04 19:13:44 mlhuang Exp $
14 CVSROOT=:pserver:anon@cvs.planet-lab.org:/cvs
21 # cron does not set USER?
22 [ -z "$USER" ] && export USER=$LOGNAME
24 # Export certain variables
28 while getopts "d:r:m:nb:x:h" opt ; do
49 echo "usage: `basename $0` [OPTION]..."
50 echo " -d directory CVS repository root (default $CVSROOT)"
51 echo " -r revision CVS revision to checkout (default $TAG)"
52 echo " -m address Notify recipient of failures (default: none)"
53 echo " -b base Run operations in specified base directory (default $BASE)"
54 echo " -x N Remove all but the last N runs from the base directory (default: none)"
59 shift $(($OPTIND - 1))
61 # Base operations in specified directory
66 if [ -n "$BUILDS" ] ; then
67 ls -t | sed -n ${BUILDS}~1p | xargs rm -rf
70 # Create a unique build base
71 BASE=${TAG/HEAD/`date +%Y.%m.%d`}
73 while ! mkdir ${BASE}${i} 2>/dev/null ; do
74 [ -z ${i} ] && BASE=${BASE}.
76 if [ $i -gt 100 ] ; then
77 echo "$0: Failed to create release directory `pwd`/${BASE}${i}"
83 # Redirect output from here
88 cvs -d ${CVSROOT} export -r ${TAG} -d ${BASE} ${MODULE}
90 if [ "$INSTALL" = "yes" ] ; then
91 make -C ${BASE} install BASE=$BASE BUILDS=$BUILDS
95 if [ $rc -ne 0 ] ; then
96 # Notify recipient of failure
97 if [ -n "$MAILTO" ] ; then
98 tail -100 ${BASE}/log | mail -s "Failures for ${BASE}" $MAILTO