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 SVNPATH=https://svn.planet-lab.org/svn
23 # cron does not set USER?
24 [ -z "$USER" ] && export USER=$LOGNAME
27 while getopts "d:r:m:f:b:x:v:h" opt ; do
51 echo "usage: `basename $0` [OPTION]..."
52 echo " -d directory SVN repository root (default $SVNPATH)"
53 echo " -r revision SVN revision to checkout (default $TAG)"
54 echo " -v Vserver Vserver reference to build within (optional)"
55 echo " -m address Notify recipient of failures (default: none)"
56 echo " -f distro Distribution to build (default: $PLDISTRO)"
57 echo " -b base Run operations in specified base directory (default $BASE)"
58 echo " -x N Remove all but the last N runs from the base directory (default: none)"
63 shift $(($OPTIND - 1))
65 # Base operations in specified directory
71 if [ -n "$BUILDS" ] ; then
72 ls -t | sed -n ${BUILDS}~1p | xargs rm -rf
75 # Create a unique build base
76 BASE=build_${TAG/trunk/`date +%Y.%m.%d`}
77 [ -n "${VSERVER}" ] && BASE=${VSERVER}_${BASE}
79 while ! mkdir ${BASE}${i} 2>/dev/null ; do
80 [ -z ${i} ] && BASE=${BASE}.
82 if [ $i -gt 100 ] ; then
83 echo "$0: Failed to create release directory `pwd`/${BASE}${i}"
89 # Redirect output from here
94 # Notify recipient of failure
95 if [ -n "$MAILTO" ] ; then
96 tail -c 8k ${BASE}/log | mail -s "Failures for ${BASE}" $MAILTO
102 # Notify recipient of failure
103 vnamespace -e $BASE umount ${BASEDIR}/${BASE}/data
105 vserver --silent $BASE delete
115 if [ -n "$VSERVER" ] ; then
116 vserver $BASE build -m clone --rootdir ${BASEDIR} -- --source /vservers/${VSERVER}
118 trap vfailure ERR INT
119 if [ -d /data ] ; then
120 vnamespace -e $BASE mount -o ro --bind /data ${BASEDIR}/${BASE}/data
123 # Checkout build directory
124 VSUEXEC="vserver $BASE exec su - build -c"
126 $VSUEXEC "svn checkout ${SVNPATH}/${MODULE}/${TAG} ${MODULE}"
129 #XXX vserver $BASE suexec build ${MODULE}/make.sh TAG=${TAG} PLDISTRO=${PLDISTRO}
131 # Install to boot server
135 vnamespace -e $BASE umount ${BASEDIR}/${BASE}/data
138 # Checkout build directory
139 svn checkout ${SVNPATH}/${MODULE}/${TAG} ${BASE}
141 # Build myplc-devel-native, install it to ensure we've got the right packages, and let it rip
142 make TAG=${TAG} PLDISTRO=${PLDISTRO} -C ${BASE} BASE=$BASE BUILDS=$BUILDS MyPLC-devel-native
143 sudo yum -y localinstall RPMS/i386/MyPLC-devel-native-*.*.rpm
146 make TAG=${TAG} PLDISTRO=${PLDISTRO} -C ${BASE} BASE=$BASE BUILDS=$BUILDS
148 # Install to boot server
150 #make TAG=${TAG} PLDISTRO=${PLDISTRO} -C ${BASE} install BASE=$BASE BUILDS=$BUILDS