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.43 2007/02/01 16:03:33 mlhuang Exp $
13 PATH=/sbin:/bin:/usr/sbin:/usr/bin
16 if [ -f CVS/Root ] ; then
17 CVSROOT=$(cat CVS/Root)
18 TAG=$(cvs status build.sh | sed -ne 's/[[:space:]]*Sticky Tag:[[:space:]]*\([^[:space:]]*\).*/\1/p')
19 if [ "$TAG" = "(none)" ] ; then
23 CVSROOT=:pserver:anon@cvs.planet-lab.org:/cvs
31 # cron does not set USER?
32 [ -z "$USER" ] && export USER=$LOGNAME
34 # Export certain variables
38 while getopts "d:r:m:f:b:x:h" opt ; do
59 echo "usage: `basename $0` [OPTION]..."
60 echo " -d directory CVS repository root (default $CVSROOT)"
61 echo " -r revision CVS revision to checkout (default $TAG)"
62 echo " -m address Notify recipient of failures (default: none)"
63 echo " -f distro Distribution to build (default: $PLDISTRO)"
64 echo " -b base Run operations in specified base directory (default $BASE)"
65 echo " -x N Remove all but the last N runs from the base directory (default: none)"
70 shift $(($OPTIND - 1))
72 # Base operations in specified directory
77 if [ -n "$BUILDS" ] ; then
78 ls -t | sed -n ${BUILDS}~1p | xargs rm -rf
81 # Create a unique build base
82 BASE=${TAG/HEAD/`date +%Y.%m.%d`}
84 while ! mkdir ${BASE}${i} 2>/dev/null ; do
85 [ -z ${i} ] && BASE=${BASE}.
87 if [ $i -gt 100 ] ; then
88 echo "$0: Failed to create release directory `pwd`/${BASE}${i}"
94 # Redirect output from here
99 # Notify recipient of failure
100 if [ -n "$MAILTO" ] ; then
101 tail -c 8k ${BASE}/log | mail -s "Failures for ${BASE}" $MAILTO
110 # Checkout build directory
111 cvs -d ${CVSROOT} checkout -r ${TAG} -d ${BASE} ${MODULE}
114 ${BASE}/make.sh TAG=${TAG} PLDISTRO=${PLDISTRO}
116 # Install to boot server
117 make TAG=${TAG} PLDISTRO=${PLDISTRO} -C ${BASE} install BASE=$BASE BUILDS=$BUILDS