#!/bin/sh

export cvsbranch="null"
export cvstag="";
export builduser=""
# Parse arguments
while getopts "c:b:u:" option
do
 case $option in
  c ) export cvstag="$OPTARG";;
  b ) export cvsbranch="$OPTARG";;
  u ) export builduser="$OPTARG";;
 esac
done

export CVS_RSH=/usr/bin/ssh 
export CVSREAD="" 

echo "CVS release tag: "$cvstag

#Create build directory
mkdir -p ng_release

#XXX Tag GBA tree and build
# Currently, use latest hourly build corresponding to the time
# reflected by TAG

#cd gba_tmp
#export CVSROOT=":ext:$builduser@source:/home/routefree/gba/depot"
#cvs -q checkout -D now sw
#cvs tag $cvstag sw
#cd ..
#rm -rf gba_tmp

cd ng_release
export CVSROOT=":ext:$builduser@source:/home/routefree/ng/depot"
if [ "null" != $cvsbranch ]; then
    cvs -q checkout -r $cvsbranch sw
    cd sw
    cvs tag -r $cvsbranch $cvstag .
    cvs update -r $cvstag .
else
    cvs -q checkout -D now sw
    cvs tag $cvstag sw
    cvs -q update -r $cvstag sw
fi
