#!/bin/sh
############################################################################################
# Name : /public/scripts/WinBuild
# Purpose : A script to run a full Windows/MFC/VC++ Globecom software build,
# Based on perforce system
# By : Yariv Sheizaf
# Date : 02-Sep-2001
# Argumnets :
# 1 - configuration name
# 2 - Build number
#
if [ "$USER" != "cmadm" -a "$USER" != "yariv" ]
then
echo ""
echo "$0 should be run with user cmadm or yariv. Exit..."
echo ""
exit 1
fi
HOSTN=`hostname`
if [ "$HOSTN" != "PRO2K-SEPHI" ]
then
echo ""
echo "$0 should be run from host PRO2K-SEPHI. Exit..."
echo ""
exit 1
fi
## Define servers
WINSRVR="PRO2K-SEPHI"
if [ $# -lt 2 ]
then
echo "Usage: $0 configuration-name Build-number"
echo "Example: $0 prd_2.0 1.8.6"
exit 1
fi
CNFNAME=$1
## Check configuration existing in P4 DB
ISCNF="n"
for i in `p4 dirs //Globecom/\* | awk -F/ '{print $NF}'`
do
if [ "$i" = "$CNFNAME" ]
then
ISCNF="y"
fi
done
if [ "$ISCNF" = "n" ]
then
echo ""
echo $CNFNAME" is not a valid configuration. Exit..."
echo ""
exit 1
fi
## If version 2.x - Z2H_epop exist. else - not.
echo $CNFNAME | grep "_2."
if [ "$?" = "0" ]
then
ISZ2HEPOP="y"
else
ISZ2HEPOP="n"
fi
UNIXDRIVE=/cygdrive/f
WINDRIVE=/cygdrive/o
UNIXHOME=$UNIXDRIVE"/home/cmadm"
WRKROOTDIR=$WINDRIVE"/Globecom/"$CNFNAME"/Globecom"
INSDIR=$UNIXDRIVE"/"$CNFNAME"/ins"
if [ ! -d $INSDIR ]
then
echo ""
echo $INSDIR" is not exist. Exit..."
echo ""
exit 1
fi
BUILDNUM=$2
## Prevent write into P4 DB
echo "Set P4 protect to open-only mode"
p4 protect -o > /tmp/$$.p4protect
p4 protect -o | sed 's/write/open/' | p4 protect -i
## Clean working directorties, then put head revision's source files
for i in Z2H epop
do
echo "Remove old "$i" source files"
p4 sync //Globecom/$CNFNAME/Globecom/$i/...#none > /dev/null
echo "Remove old "$i" directories"
rm -rf $WRKROOTDIR/$i
echo "Synchronize head revision of "$i
p4 sync //Globecom/$CNFNAME/Globecom/$i/... > /dev/null
echo ""
done
if [ "$ISZ2HEPOP" = "y" ]
then
echo "Remove old Z2H_epop source files"
p4 sync //Globecom/$CNFNAME/Globecom/Z2H_epop/...#none > /dev/null
echo "Remove old Z2H_epop directories"
rm -rf $WRKROOTDIR/Z2H_epop
echo "Synchronize head revision of Z2H_epop"
p4 sync //Globecom/$CNFNAME/Globecom/Z2H_epop/... > /dev/null
echo ""
fi
## Z2H Build
for i in `ls -l $WRKROOTDIR | grep Z2H | awk '{print $NF}'`
do
echo ""
Z2HDIR=$WRKROOTDIR"/"$i
echo "Start "$i" Build..."
echo "Build "$i" Template Convertor"
cd $Z2HDIR/templateConvertor
msdev templateConvertor.dsp /MAKE "templateConvertor - RELEASE" /REBUILD
# msdev templateConvertor.dsp /MAKE ALL /REBUILD
echo "Run TemplateConvertor - create *.h files"
cd $Z2HDIR/templateConvertor/Release
./templateConvertor.exe ../../Templates ../../XmlConvertor/templates
echo "Build XmlConvertor"
cd $Z2HDIR/XmlConvertor
msdev XmlConvertor.dsp /MAKE "XmlConvertor - RELEASE" /REBUILD
# msdev XmlConvertor.dsp /MAKE ALL /REBUILD
done
## Copy Z2H files from WIN environment to Unix environment
Z2HTMPDIR=$UNIXHOME/Z2H_templates/$CNFNAME
echo "Copy product *.h files to "$Z2HTMPDIR
if [ -d $Z2HTMPDIR ]
then
rm -f $Z2HTMPDIR/*.h
else
mkdir $Z2HTMPDIR
chmod 777 $Z2HTMPDIR
fi
Z2HMAINDIR=$WRKROOTDIR"/Z2H"
cp $Z2HMAINDIR/XmlConvertor/templates/*.h $Z2HTMPDIR
chmod 666 $Z2HTMPDIR/*.h
echo "Copy Xmlconvertor to "$INSDIR
rm -f $INSDIR/XmlConvertor.exe
cp $Z2HMAINDIR/XmlConvertor/Release/XmlConvertor.exe $INSDIR
echo "Copy images and JS files to "$INSDIR"/misc"
if [ -d $INSDIR/misc ]
then
rm -rf $INSDIR/misc/*
else
mkdir $INSDIR/misc
fi
mkdir $INSDIR/misc/Windows
mkdir $INSDIR/misc/Unix
chmod -R 777 $INSDIR/misc/*
### *************** cp images and resources to $INSDIR/misc ??? ******************
cp $Z2HMAINDIR/ConvertorRes/Images/* $INSDIR/misc
cp $Z2HMAINDIR/ConvertorRes/Js/Windows/* $INSDIR/misc/Windows
cp $Z2HMAINDIR/ConvertorRes/Js/Unix/* $INSDIR/misc/Unix
### *************** cp images and resources to $INSDIR/CI ??? ******************
cp $Z2HMAINDIR/ConvertorRes/Images/* $INSDIR/CI/ConvertorRes/Images
cp $Z2HMAINDIR/ConvertorRes/Js/Windows/* $INSDIR/CI/ConvertorRes/Js
for i in EPOP-Source
do
echo "Copy files for "$i
## Copy Z2H_epop files from WIN environment to Unix environment
echo "Copy Xerces DLLs to installation directory"
if [ -d $INSDIR/$i ]
then
rm -f $INSDIR/$i/*
else
mkdir $INSDIR/$i
chmod 777 $INSDIR/$i
fi
cp $Z2HMAINDIR/XmlConvertor/Release/xerces*.dll $INSDIR/$i
if [ "$ISZ2HEPOP" = "y" ]
then
Z2HEPOPDIR=$WRKROOTDIR"/Z2H_epop"
cp $Z2HEPOPDIR/XmlConvertor/Release/xerces*.dll $INSDIR/$i
cp $Z2HEPOPDIR/XmlConvertor/Release/EpopConvertor.exe $INSDIR/$i
cp $Z2HEPOPDIR/ConvertorRes/Images/* $INSDIR/$i
cp $Z2HEPOPDIR/ConvertorRes/Js/* $INSDIR/$i
fi
done
## EPOP build
echo "Start EPOP build..."
EPOPDIR=$WRKROOTDIR"/epop"
CURPWD=`pwd`
cd $EPOPDIR
for i in `ls -l | awk '{print $NF}' | tail +2 | grep -v InstallShield `
do
echo "Build "$i
cd $i
msdev $i.dsp /MAKE "$i - RELEASE" /REBUILD
# msdev $i.dsp /MAKE ALL /REBUILD
echo "Copy "$i".exe to installation directory"
cp Release/$i.exe $INSDIR/EPOP-Source
cd $EPOPDIR
done
cd $CURPWD
## Reopen P4 protect for write to programmers
echo "Reconstruct P4 protect to write-mode"
p4 protect -i < /tmp/$$.p4protect
rm -f /tmp/$$.p4protect
echo ""
exit 0