ME=xbuild.sh
#echo - Check for updates ......
if [ /home/sh13256/$ME -nt $0 ]; then
# echo - New version found. Update ...
cp /home/sh13256/$ME $0
echo - $0 Updated. Relaunching ...
echo
echo "$0 $*"
$0 $*
exit
fi
#echo - $0 is up to date
#set -x
Usage(){
echo
echo " Usage:"
echo
echo " - 1 - Compilation Jobs - "
echo
echo " $0 lqtfront : build LQT front end (CVS Update, Compile)"
echo " $0 lqtback : build LQT back end (CVS Update, Compile)"
echo " $0 lqt : build LQT front & back (CVS Update, Compile)"
echo
echo " $0 lqtfront [N] : build LQT front end lazily"
echo " $0 lqtback [N] : build LQT back end lazily"
echo " $0 lqt [N] : build LQT front & back lazily"
echo
echo " $0 lqtfrontC : build LQT front end (Compile Only)"
echo " $0 lqtbackC : build LQT back end (Compile Only)"
echo
echo " $0 loanwl : build Loan WL"
echo " $0 loanwl [N] : build Loan WL lazily"
echo
echo " [N] : number of updated files, will skip compile if there are not enough updates."
echo
echo " Create a file 'To' at the same dir. Enter email addresses in it, one email each line."
echo " Logs will be send to these emails."
echo
echo " - 2 - Hermes Jobs - "
echo
echo " $0 lqtfrontH releasetype [config file] : send LQT front end to Hermes "
echo " $0 lqtbackH releasetype [config file] : send LQT back end to Hermes "
echo " $0 loanwlH releasetype [config file] : send LoanWL to Hermes "
echo " $0 lqtDBH releasetype [config file] : send LoansQTDB to Hermes "
echo
echo " releasetype = integration | major | minor | bugfix | resubmission"
echo " in [config file]: AdditionalEmailList=[comma separated list of email addresses to CC.]"
echo
exit
}
if [ $# -lt 1 ]; then
Usage
fi
CMD=$1
CMD_LQT='lqt'
CMD_FRONT='lqtfront'
CMD_BACK='lqtback'
CMD_LWL='loanwl'
CMD_LQTDBH='lqtDBH'
xROOT=`pwd`
LOGFRONT=$xROOT/.$CMD_FRONT.log
LOGBACK=$xROOT/.$CMD_BACK.log
LOGLWL=$xROOT/.$CMD_LWL.log
LOGCVS=$xROOT/.cvs.log
LOG_DB=$xROOT/.$CMD_LQTDBH.log
TO=$xROOT/To
LWL_COMPILE=lwlCompile
BRANCH_FILE=$xROOT/.branch
LQT_BRANCH=`cat ${BRANCH_FILE} | grep '^LQT:' | sed 's/^LQT://'`
LWL_BRANCH=`cat ${BRANCH_FILE} | grep '^LWL:' | sed 's/^LWL://'`
sendMail(){
# #set -x
TOLIST=`echo
[email protected]`
MY_MAIL=$TOLIST
if [ -f $TO ]; then
TOLIST=`cat $TO | tr '\n' ' '`
elif [ -f /home/sh13256/To ]; then
TOLIST=`cat /home/sh13256/To | tr '\n' ' '`
fi
echo "---------------- Send Mail Start ------------------"
mailx -b $MY_MAIL -t <<EOF
To: $TOLIST
Subject: $1
Mime-Version: 1.0;
Content-Type: text/html; charset="ISO-8859-1";
Content-Transfer-Encoding: 7bit;
<html><body><pre style='font-size:12px; color:003366'>
`cat $2`
</pre></body></html>
EOF
echo " Subject : $1"
echo " Attach : $2"
echo " Sent to : ${TOLIST}"
echo "---------------- Send Mail Finish ------------------"
# mailx -s $1 -b
[email protected] "$TOLIST" < $2
# for to in $TOLIST
# do
# mailx -s $1 ${to}< $2
# echo " - Mail sent to ${to}"
# done
}
updateCode(){
# set -x
echo
echo "========== Updating Code from CVS STARTED: `date` =========="
echo "========== Updating Code from CVS STARTED: `date` ==========" >> $1
rm -f ./checkout
cp /home/sh13256/checkout.sh checkout
chmod +x ./checkout
if [ $1 = $LOGLWL ]; then
if [ -d $xROOT/zTRSBackEnd ]; then
echo " - Source code found, start update. (zTRSBackEnd) "
./checkout updateLWL $1
else
echo " - No source code found, please do checkout first. "
exit
fi
else
# if [ $1 = $LOGBACK ] or [ $1 = $LOGFRONT ]; then
if [ -d $xROOT/LoansQuickTicket/LQT ]; then
echo " - Source code found, start update. (LoansQuickTicket/LQT) "
./checkout updateLQT $1
else
echo " - No source code found, please do checkout first. "
exit
fi
fi
rm -f ./checkout
}
lazyPrepare(){
# set -x
rm $LOGCVS
cat $1 | grep "^[UPARMC]" | sed '/LQT\/libBack\/CBIdl\/idl\/CBTicket\.idl/d' >> $LOGCVS
COUNT=`wc -l $LOGCVS | sed 's/ \/.*$//' | sed 's/ //g'`
echo "" >> $LOGCVS
echo "$COUNT file(s) updated" >> $LOGCVS
echo " - $COUNT file(s) updated"
BRANCH='Trunk'
if [ $LQT_BRANCH ]; then
BRANCH=$LQT_BRANCH
fi
if [ $1 = $LOGLWL ]; then
if [ $LWL_BRANCH ]; then
BRANCH=$LWL_BRANCH
fi
fi
if [ $# -gt 1 ]; then
if [ $COUNT -le $2 ]; then
echo " - Required changes for compile: [$2] - Skip !"
echo "Not Enough Changes. [$2] - Skip Compile" >> $LOGCVS
if [ $COUNT -gt 0 ]; then
sendMail "CVS_${BRANCH}_${xROOT}" $LOGCVS
fi
exit
fi
fi
if [ $COUNT -gt 0 ]; then
sendMail "CVS_${BRANCH}_${xROOT}" $LOGCVS
fi
echo
echo "========== Prepare Code STARTED: `date` =========="
rm -f ./checkout
cp /home/sh13256/checkout.sh checkout
chmod +x ./checkout
if [ $1 = $LOGLWL ]; then
if [ -d $xROOT/zTRSBackEnd ]; then
echo " - Source code found, start prepare. (zTRSBackEnd) "
./checkout prepareLWL $1
else
echo " - No source code found, please do checkout first. "
exit
fi
else
# if [ $1 = $LOGFRONT ] or [ $1 = $LOGBACK ]; then
if [ -d $xROOT/LoansQuickTicket/LQT ]; then
echo " - Source code found, start prepare. (LoansQuickTicket/LQT) "
./checkout prepareLQT $1
else
echo " - No source code found, please do checkout first. "
exit
fi
fi
rm -f ./checkout
}
doCompile(){
# #set -x
echo
echo "========== Compile STARTED: `date` Logging to $1 =========="
echo
echo " Please wait ....... "
echo
echo "========== Compile STARTED: `date` Logging to $1 ==========" >> $1
if [ $1 = $LOGFRONT ]; then
cd $xROOT/LoansQuickTicket/compile
cp /home/sh13256/build.sh build
chmod +x ./build
./build build_front $1
rm -f ./build
elif [ $1 = $LOGBACK ]; then
cd $xROOT/LoansQuickTicket/compile
cp /home/sh13256/build.sh build
chmod +x ./build
./build build_back $1
rm -f ./build
elif [ $1 = $LOGLWL ]; then
cp /home/sh13256/build.sh build
chmod +x ./build
./build build_loanWL $1 "${xROOT}/$LWL_COMPILE/"
rm -f ./build
else
echo Unknown Log file for do compile: $1
fi
echo "========== Compile ENDED: `date` Logged to $1 =========="
echo "========== Compile ENDED: `date` Logged to $1 ==========" >> $1
}
achive(){
currdate=`date '+%m%d%H%M%S'`
cd $xROOT
archivePath=$xROOT/archive
find $archivePath -mtime +10 -exec rm -rf {} \;
if [ ! -d $archivePath ]; then
mkdir $archivePath
fi
msg=". - Archive failed"
if [ $1 = $LOGFRONT ]; then
cp $xROOT/LoansQuickTicket/compile/front/LQTFront.dstream $archivePath/LQTFront.dstream.$currdate
if [ -f $archivePath/LQTFront.dstream.$currdate ]; then
msg=". - Archived to $archivePath/LQTFront.dstream.$currdate"
fi
elif [ $1 = $LOGBACK ]; then
cp $xROOT/LoansQuickTicket/compile/back/LoansQT.dstream $archivePath/LoansQT.dstream.$currdate
if [ -f $archivePath/LoansQT.dstream.$currdate ]; then
msg=". - Archived to $archivePath/LoansQT.dstream.$currdate"
fi
elif [ $1 = $LOGLWL ]; then
cp $xROOT/$LWL_COMPILE/LoanWL.dstream $archivePath/LoanWL.dstream.$currdate
if [ -f $archivePath/LoanWL.dstream.$currdate ]; then
msg=". - Archived to $archivePath/LoanWL.dstream.$currdate"
fi
fi
chmod 777 $archivePath/*
echo $msg
echo $msg >> $1
}
sendToHermes(){
cp /home/sh13256/build.sh build
chmod +x ./build
if [ $# -lt 2 ]; then
./build hermes
rm ./build
exit
fi
if [ $1 = $LOGFRONT ]; then
./build hermes $2 lqtfront $3
elif [ $1 = $LOGBACK ]; then
./build hermes $2 lqtback $3
elif [ $1 = $LOGLWL ]; then
./build hermes $2 loanwl $3
elif [ $1 = $LOG_DB ]; then
./build hermes $2 lqtdb $3
fi
rm ./build
}
doPrepareProcess(){
rm -f $1
updateCode $1
lazyPrepare $1 $2
}
doPostPreparePorcess(){
doCompile $1
achive $1
BRANCH='Trunk'
RESULT='FAILED'
PROJ_NAME=''
if [ $1 = $LOGFRONT ]; then
if [ ${LQT_BRANCH} ]; then
BRANCH=${LQT_BRANCH}
fi
DSTREAM=$xROOT/LoansQuickTicket/compile/front/LQTFront.dstream
if [ -f $DSTREAM ] and [ $DSTREAM -nt $1 ]; then
RESULT='SUCCESS'
fi
PROJ_NAME='LQTFront'
elif [ $1 = $LOGBACK ]; then
if [ ${LQT_BRANCH} ]; then
BRANCH=${LQT_BRANCH}
fi
DSTREAM=$xROOT/LoansQuickTicket/compile/back/LoansQT.dstream
if [ -f $DSTREAM ] and [ $DSTREAM -nt $1 ]; then
RESULT='SUCCESS'
fi
PROJ_NAME='LoansQT'
elif [ $1 = $LOGLWL ]; then
if [ ${LWL_BRANCH} ]; then
BRANCH=${LWL_BRANCH}
fi
DSTREAM=$xROOT/$LWL_COMPILE/LoanWL.dstream
if [ -f $DSTREAM ] and [ $DSTREAM -nt $1 ]; then
RESULT='SUCCESS'
fi
PROJ_NAME='LoanWL'
fi
sendMail "${RESULT}_${PROJ_NAME}_${BRANCH}_${xROOT}" $1
}
#====================== LQT Update - Compile ======================
if [ $CMD = $CMD_BACK ]; then
if [ -d $xROOT/LoansQuickTicket/LQT ]; then
doPrepareProcess $LOGBACK $2
doPostPreparePorcess $LOGBACK
else
echo
echo "Build folder not fund."
echo "Required $xROOT/LoansQuickTicket/LQT"
fi
elif [ $CMD = $CMD_FRONT ]; then
if [ -d $xROOT/LoansQuickTicket/LQT ]; then
doPrepareProcess $LOGFRONT $2
doPostPreparePorcess $LOGFRONT
else
echo
echo "Build folder not fund."
echo "Required $xROOT/LoansQuickTicket/LQT"
fi
#====================== LQT Compile Only ======================
elif [ $CMD = ${CMD_BACK}C ]; then
if [ -d $xROOT/LoansQuickTicket/LQT ]; then
rm -f $LOGBACK
doPostPreparePorcess $LOGBACK
else
echo
echo "Build folder not fund."
echo "Required $xROOT/LoansQuickTicket/LQT"
fi
elif [ $CMD = ${CMD_FRONT}C ]; then
if [ -d $xROOT/LoansQuickTicket/LQT ]; then
rm -f $LOGFRONT
doPostPreparePorcess $LOGFRONT
else
echo
echo "Build folder not fund."
echo "Required $xROOT/LoansQuickTicket/LQT"
fi
#====================== LQT Update - Compile Together ======================
elif [ $CMD = ${CMD_LQT} ]; then
rm -f ${LOGFRONT}
updateCode ${LOGFRONT}
lazyPrepare ${LOGFRONT} $2
doPostPreparePorcess $LOGFRONT &
rm -f $LOGBACK
doPostPreparePorcess $LOGBACK
#====================== LQT Hermes ======================
elif [ $CMD = ${CMD_BACK}H ]; then
if [ $# -lt 2 ]; then
Usage
fi
if [ -d $xROOT/LoansQuickTicket/LQT ]; then
doPrepareProcess $LOGBACK
sendToHermes $LOGBACK $2 $3
else
echo
echo "Build folder not fund."
echo "Required $xROOT/LoansQuickTicket/LQT"
fi
elif [ $CMD = ${CMD_FRONT}H ]; then
if [ $# -lt 2 ]; then
Usage
fi
if [ -d $xROOT/LoansQuickTicket/LQT ]; then
doPrepareProcess $LOGFRONT
sendToHermes $LOGFRONT $2 $3
else
echo
echo "Build folder not fund."
echo "Required $xROOT/LoansQuickTicket/LQT"
fi
#====================== LWL Update - Compile Together ======================
elif [ $CMD = $CMD_LWL ]; then
if [ -d $xROOT/zTRSBackEnd ]; then
doPrepareProcess $LOGLWL $2
doPostPreparePorcess $LOGLWL
else
echo
echo "Build folder not fund."
echo "Required $xROOT/zTRSBackEnd"
fi
#====================== LWL Hermes ======================
elif [ $CMD = ${CMD_LWL}H ]; then
if [ $# -lt 2 ]; then
Usage
fi
if [ -d $xROOT/zTRSBackEnd ]; then
doPrepareProcess $LOGLWL
sendToHermes $LOGLWL $2 $3
else
echo
echo "Build folder not fund."
echo "Required $xROOT/LoansQuickTicket/LQT"
fi
#====================== LQT DB Hermes ======================
elif [ $CMD = ${CMD_LQTDBH} ]; then
if [ $# -lt 2 ]; then
Usage
fi
echo " -- checking out -- "
cp /home/sh13256/checkout.sh checkout
chmod +x ./checkout
./checkout DB >> $LOG_DB 2>&1
rm ./checkout
echo " -- sending to Hermes -- "
sendToHermes $LOG_DB $2 $3 >> $LOG_DB 2>&1
sendMail "LoansQTDB_Send_To_Hermes_${xROOT}" $LOG_DB
else
Usage
fi