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.34 2006/06/07 21:18:28 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:f:b: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 " -f distro Distribution to build (default: $PLDISTRO)"
54 echo " -b base Run operations in specified base directory (default $BASE)"
55 echo " -x N Remove all but the last N runs from the base directory (default: none)"
60 shift $(($OPTIND - 1))
62 # Base operations in specified directory
67 if [ -n "$BUILDS" ] ; then
68 ls -t | sed -n ${BUILDS}~1p | xargs rm -rf
71 # Create a unique build base
72 BASE=${TAG/HEAD/`date +%Y.%m.%d`}
74 while ! mkdir ${BASE}${i} 2>/dev/null ; do
75 [ -z ${i} ] && BASE=${BASE}.
77 if [ $i -gt 100 ] ; then
78 echo "$0: Failed to create release directory `pwd`/${BASE}${i}"
84 # Redirect output from here
89 cvs -d ${CVSROOT} checkout -r ${TAG} -d ${BASE} ${MODULE}
90 make TAG=${TAG} PLDISTRO=${PLDISTRO} -C ${BASE} && \
91 make TAG=${TAG} PLDISTRO=${PLDISTRO} -C ${BASE} install BASE=$BASE BUILDS=$BUILDS
94 if [ $rc -ne 0 ] ; then
95 # Notify recipient of failure
96 if [ -n "$MAILTO" ] ; then
97 tail -c 8k ${BASE}/log | mail -s "Failures for ${BASE}" $MAILTO