Switch to use svn.
authorMarc Fiuczynski <mef@cs.princeton.edu>
Sat, 20 Oct 2007 00:53:31 +0000 (00:53 +0000)
committerMarc Fiuczynski <mef@cs.princeton.edu>
Sat, 20 Oct 2007 00:53:31 +0000 (00:53 +0000)
build.sh

index 78c6e53..1c5a8a7 100755 (executable)
--- a/build.sh
+++ b/build.sh
 PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
 # Set defaults
-if [ -f CVS/Root ] ; then
-    CVSROOT=$(cat CVS/Root)
-    TAG=$(cvs status build.sh | sed -ne 's/[[:space:]]*Sticky Tag:[[:space:]]*\([^[:space:]]*\).*/\1/p')
-    if [ "$TAG" = "(none)" ] ; then
-       TAG=HEAD
-    fi
-else
-    CVSROOT=:pserver:anon@cvs.planet-lab.org:/cvs
-    TAG=HEAD
-fi
-CVS_RSH=ssh
+SVNPATH=http://svn.planet-lab.org/svn
+TAG=trunk
 MODULE=build
 BASE=$PWD
 PLDISTRO=planetlab
+VSERVER=
 
 # cron does not set USER?
 [ -z "$USER" ] && export USER=$LOGNAME
 
-# Export certain variables
-export CVS_RSH
-
 # Get options
-while getopts "d:r:m:f:b:x:h" opt ; do
+while getopts "d:r:m:f:b:x:v:h" opt ; do
     case $opt in
        d)
-           CVSROOT=$OPTARG
+           SVNPATH=$OPTARG
            ;;
        r)
            TAG=$OPTARG
@@ -55,10 +44,14 @@ while getopts "d:r:m:f:b:x:h" opt ; do
        x)
            BUILDS=$OPTARG
            ;;
+       v)
+           VSERVER=$OPTARG
+           ;;
        h|*)
            echo "usage: `basename $0` [OPTION]..."
-           echo "      -d directory    CVS repository root (default $CVSROOT)"
-           echo "      -r revision     CVS revision to checkout (default $TAG)"
+           echo "      -d directory    SVN repository root (default $SVNPATH)"
+           echo "      -r revision     SVN revision to checkout (default $TAG)"
+           echo "      -v Vserver      Vserver reference to build within (optional)"
            echo "      -m address      Notify recipient of failures (default: none)"
            echo "      -f distro       Distribution to build (default: $PLDISTRO)"
            echo "      -b base         Run operations in specified base directory (default $BASE)"
@@ -72,6 +65,7 @@ shift $(($OPTIND - 1))
 # Base operations in specified directory
 mkdir -p $BASE
 cd $BASE || exit $?
+BASEDIR=$(pwd)
 
 # Remove old runs
 if [ -n "$BUILDS" ] ; then
@@ -79,7 +73,8 @@ if [ -n "$BUILDS" ] ; then
 fi
 
 # Create a unique build base
-BASE=${TAG/HEAD/`date +%Y.%m.%d`}
+BASE=build_${TAG/trunk/`date +%Y.%m.%d`}
+[ -n "${VSERVER}" ] && BASE=${VSERVER}_${BASE}
 i=
 while ! mkdir ${BASE}${i} 2>/dev/null ; do
     [ -z ${i} ] && BASE=${BASE}.
@@ -92,8 +87,8 @@ done
 BASE=${BASE}${i}
 
 # Redirect output from here
-exec 2>&1
-exec &>${BASE}/log
+#exec 2>&1
+#exec &>${BASE}/log
 
 failure() {
     # Notify recipient of failure
@@ -103,17 +98,51 @@ failure() {
     exit 1
 }
 
+vfailure() {
+    # Notify recipient of failure
+    vnamespace -e $BASE umount ${BASEDIR}/${BASE}/data
+    vserver $BASE stop
+    vserver --silent $BASE delete
+    failure
+    exit 1
+}
+
 trap failure ERR INT
 
 set -x
 
-# Checkout build directory
-cvs -d ${CVSROOT} checkout -r ${TAG} -d ${BASE} ${MODULE}
+VCMDPREFIX=
+if [ -n "$VSERVER" ] ; then
+    vserver $BASE build -m clone --rootdir ${BASEDIR} -- --source /vservers/${VSERVER}
+    vserver $BASE start
+    trap vfailure ERR INT
+    if [ -d /data ] ; then
+       vnamespace -e $BASE mount -o ro --bind /data ${BASEDIR}/${BASE}/data
+    fi
+
+    # Checkout build directory
+    VSUEXEC="vserver $BASE exec su - build -c"
+
+    $VSUEXEC "svn co ${SVNPATH}/${MODULE}/${TAG} ${MODULE}"
+
+    # Build
+    #XXX vserver $BASE suexec build ${MODULE}/make.sh TAG=${TAG} PLDISTRO=${PLDISTRO}
 
-# Build
-${BASE}/make.sh TAG=${TAG} PLDISTRO=${PLDISTRO}
+    # Install to boot server
+    # XXX not yet
 
-# Install to boot server
-make TAG=${TAG} PLDISTRO=${PLDISTRO} -C ${BASE} install BASE=$BASE BUILDS=$BUILDS
+    trap - ERR INT
+    vnamespace -e $BASE umount ${BASEDIR}/${BASE}/data
+    vserver $BASE stop
+else
+    # Checkout build directory
+    svn co ${SVNPATH}/${MODULE}/${TAG} ${BASE}
+
+    # Build
+    ${BASE}/make.sh TAG=${TAG} PLDISTRO=${PLDISTRO}
+
+    # Install to boot server
+    make TAG=${TAG} PLDISTRO=${PLDISTRO} -C ${BASE} install BASE=$BASE BUILDS=$BUILDS
+fi
 
 exit 0