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 # $Id: build.sh,v 1.22 2004/12/07 22:41:56 mlhuang Exp $
11 CVSROOT=:pserver:anon@build.planet-lab.org:/cvs
17 # Export certain variables
21 while getopts "d:r:m:b:x:h" opt ; do
39 echo "usage: `basename $0` [OPTION]..."
40 echo " -d directory CVS repository root (default $CVSROOT)"
41 echo " -r revision CVS revision to checkout (default $TAG)"
42 echo " -m address Notify recipient of failures (default: none)"
43 echo " -b base Run operations in specified base directory (default $BASE)"
44 echo " -x N Remove all but the last N runs from the base directory (default: none)"
50 # Base operations in specified directory
55 if [ -n "$BUILDS" ] ; then
56 ls -t | sed -n ${BUILDS}~1p | xargs rm -rf
59 # Create a unique build base
60 BASE=${TAG/HEAD/`date +%Y.%m.%d`}
62 while ! mkdir ${BASE}${i} 2>/dev/null ; do
63 [ -z ${i} ] && BASE=${BASE}.
65 if [ $i -gt 100 ] ; then
66 echo "$0: Failed to create release directory `pwd`/${BASE}${i}"
72 # Redirect output from here
77 cvs -d ${CVSROOT} export -r ${TAG} -d ${BASE} ${MODULE}
81 if [ $rc -ne 0 ] ; then
82 # Notify recipient of failure
83 if [ -n "$MAILTO" ] ; then
84 tail -100 ${BASE}/log | mail -s "Failures for ${BASE}" $MAILTO
92 # XXX Should check out a tagged version of yumgroups.xml
93 echo "$(date) Getting yumgroups.xml"
94 cvs -d ${CVSROOT} checkout -p alpina/groups/v3_yumgroups.xml > ${BASE}/RPMS/yumgroups.xml
96 # Create package manifest
97 echo "$(date) Creating package manifest"
98 URLBASE=$(cd ${BASE} && pwd -P)
99 URLBASE="http://build.planet-lab.org/${URLBASE##$HOME/}/SRPMS"
100 ${BASE}/packages.sh -b ${URLBASE} ${BASE}/SRPMS > ${BASE}/SRPMS/packages.xml
102 # Upload packages to boot server
103 SERVER=build@boot.planet-lab.org
104 ARCHIVE=/var/www/html/install-rpms/archive
105 # Put nightly alpha builds in a subdirectory
106 if [ "$TAG" = "HEAD" ] ; then
107 ARCHIVE=$ARCHIVE/planetlab-alpha
108 REPOS=/var/www/html/install-rpms/planetlab-alpha
112 if [ -n "$BUILDS" ] ; then
113 echo "$(date) Removing old runs"
114 echo "cd $ARCHIVE && ls -t | sed -n ${BUILDS}~1p | xargs rm -rf" | ssh $SERVER /bin/bash -s
117 # Populate repository
118 echo "$(date) Populating repository"
119 for RPMS in RPMS SRPMS ; do
120 ssh $SERVER mkdir -p $ARCHIVE/$BASE/$RPMS/
121 find $BASE/$RPMS/ -type f | xargs -i scp {} $SERVER:$ARCHIVE/$BASE/$RPMS/
122 ssh $SERVER yum-arch $ARCHIVE/$BASE/$RPMS/ >/dev/null
125 # Update nightly alpha symlink
126 echo "$(date) Updating symlink"
127 if [ "$TAG" = "HEAD" ] ; then
128 ssh $SERVER ln -nsf $ARCHIVE/$BASE/RPMS/ $REPOS
131 echo "$(date) $BASE done"