#!/bin/bash -e
usage='
  kentGetNBuild buildRoot

Night build script for kent tree.  This does two builds, one with an existing
CVS working directory and one with a freshly checked out working directory.

Arguments:
   o buildRoot - should exist, the directory
         $buildRoot/update/kent
     should contain a checked out kent tree and a fresh check will be done in
         $buildRoot/checkout/kent
'

# begin here
if [ $# -ne 1 ]  ; then
    echo "Error: wrong number of arguments" >&2
    echo "$usage" >&2
    exit 1
fi
buildRoot="$1"
updDir=$buildRoot/update
coDir=$buildRoot/checkout
kentBuild=$updDir/kent/build/kentBuild
cvsRoot=/projects/compbio/cvsroot

# update build
rm -rf $updDir/output
$kentBuild -update $updDir/kent $updDir/output

# checkout build
rm -rf $coDir
mkdir -p $coDir
cd $coDir
(cvs -d ${cvsRoot} co kent >checkout.log 2>&1) || {
    echo "Error: kent/src cvs checkout failed failed" >&2
    echo "full log file is on `hostname`: $coDir/checkout.log" >&2
    exit 2
}
$kentBuild $coDir/kent $coDir/output
