#! /bin/sh
#
# $Id: calpont-build 421 2007-14-15 15:46:55Z dhill $
#
# build calpont rpm and install on call6500
# $1 - release number or 'Latest'
# $2 - svn branch
#
if [ "$2" = "" ] ; then
	echo "enter release and svn-branch arguments"
	exit 0
fi
# !!! set for OS type 32 or 64 bit !!!

OS=x86_64

#
REL=$1
DIR=$2

HOME=/home/nightly/$DIR
rm -fr /home/nightly/rpm/*
#
su - nightly -c "cd $HOME;./build/build_rpms -g > ~/$DIR/build_datdup_rpm.log 2>&1"
#
test -d /home/nightly/rpm/RPMS || echo "no rpm, Build Failed"
test -d /home/nightly/rpm/RPMS || exit 1
cd /home/nightly/rpm/RPMS/$OS/
test -f calpont-datdup-$version*.rpm || echo "no rpm, Build Failed"
test -f  calpont-datdup-$version*.rpm || exit 1
{
if [ $REL != "Latest" ] ; then
	# copy rpms to calweb
	cd /home/nightly/rpm/RPMS/$OS/
        smbclient //calweb/shared -Wcalpont -Uoamuser%Calpont1 -c "cd Iterations/$REL/packages;rm calpont-datdup*.$OS.rpm;prompt OFF;mput calpont-datdup*"
else
	# copy nightly on calweb
	cd /home/nightly/rpm/RPMS/$OS/
	smbclient //calweb/shared -Wcalpont -Uoamuser%Calpont1 -c "cd Iterations/Latest/packages;rm calpont-datdup*.$OS.rpm;prompt OFF;mput calpont-datdup*"
fi
} 2> /root/datdup-build-$REL-$DIR.log
#
echo "Build Successfully Completed"
exit 0
