#!/bin/sh
#
# implementation: build_all redcell22 RC.2.2.0.43
# to think about: Interactive run.
# Reruns.
# Run from earlier label.
# inputs:
# Parameters : -l <label>
# -no_update - if set then build from label. Else build from tip and
# create label.
# Codeline
# Files : build.env
#
# assumptions:
#
# - There are two clients. The source client used to build the product and the
# release client used to build the installer and populate build and release depots.
# - We only check jar files into the build depot.
# - The release client will be set up to pull only those files needed by installer.
# - The release client will pull the jar files by name. We need this to create jar.bom.
# - The build depot branch structure will mimic the source depot.
#
# todo - Reruns of the build.
# - Support odd runs such as - test run, create no label, sub builds.
#
# Note: all perforce operations are done relative to the perforce depot
# mapping except those involving the source depot. Operations on the
# source depot use the client spec mapping. The reason is that in
# some cases the source depot branch is different then the build and
# release branches. Specifically for a mainlne build. The source
# branch will not cotain the version whereas the other depots will.
# echo settings
prog=build_all
the_args="$@"
echo Executing $prog $the_args
# Subroutines
rec_signal () {
echo $prog received signal... Shuting down
exit 33
}
check_error()
{
if [ $1 != 0 ]
then
echo "BUILD_ERROR: $prog, " $2 " failed."
build_err=$true
# Turn off update of release depot.
no_release=$true
# Turn off update of label
no_update=$true
fi
}
get_root()
{
# Parameters:
# $1 = client spec.
client_root=`p4 -c $1 info | grep "Client root" | awk '{print $3}' \
| sed 's/\\\/\//g'`
if [ x$client_root = x ]
then
check_error 1 "get_root $*"
fi
}
P4_LABEL()
{
# Parameters:
# $1 -new for new label; -old for existing label.
# $2 Label
# $3 Files to add to label
# $4 Client Spec
opt=""
p4lab_stat=0
if [ $# -lt 1 -o $# -gt 4 ]
then
echo
echo ERROR: Incorrect number of parameters passed to P4_LABEL
echo The parameters received were "$@"
exit 1
fi
if [ $# -eq 4 ]
then
# set command to use client $4
opt="-c $4"
fi
if [ $1 = "-new" ]
then
echo Creating label $2.
# The template allows the view to overide the defaults.
# The danger here is if the view changes, we will use the old view.
# It should be OK if the initial view contains the top level of each depot.
# //redcell/redcell21/... not //redcell/redcell21/bin/...
if [ x$label_template = x ]
then
label_template=$OLD_LABEL
fi
p4 labels | awk '{print $2}' | grep $label_template
if [ $? -ne 0 ]
then
echo "$prog, BUILD_WARNING: Label template does not exist."
echo "Label created without template."
temp_opt=""
else
echo Using $label_template as template
temp_opt="-t $label_template"
fi
p4 label -o $temp_opt $2 | \
sed s/"Created by .*"/"$CODELINE build $BUILD_NUMBER @ change $change"/ \
| p4 label -i
p4lab_stat=$?
fi
echo Output being sent to $LOG_DIR/label.log
echo "********** Build date `date` **********" >> $LOG_DIR/label.log
echo Adding $3 to label $2 | tee -a $LOG_DIR/label.log
p4 $opt -s labelsync $p4opt -a -l $2 $3 >> $LOG_DIR/label.log 2>&1
p4lab_stat=`expr $? + $p4lab_stat`
check_error $p4lab_stat "P4_LABEL $*"
}
###################### MAIN ##########################
echo "********** Build date `date` **********"
trap rec_signal 2 15
# Set defaults
# Flags
false=1
true=0
build_err=$false
P4REVISION=#head
TEST=$false
debug=$false
usage_flag=$false
create_label=$true
no_update=$false
no_javadocs=$false
no_metadocs=$false
no_release=$false
no_build=$false
no_install=$false
no_docs=$false
no_cd=$false
no_tools=$false
no_sync=$false
extraEnvVars="extraDone=1"
VER=""
p4opt=""
CODELINE=""
environment_client=build-environment
# Get parameters
while [ $# -gt 0 ]
do
if [ "$1" = "" ]
then
# Some versions of sh won't let me have commands here,
# so we set dummyArg.
dummyArg=1
elif [ $1 = "-revision" ]
then
shift
P4REVISION="$1"
extraEnvVars="$extraEnvVars ; P43RDPARTY_LABEL=$1 ; export P43RDPARTY_LABEL"
elif [ $1 = "-old_label" ]
then
shift
OLD_LABEL=$1
arg_err="Bad Label argument"
echo $OLD_LABEL | grep ^- && usage_flag=$true
create_label=$false # don't create label if label defined.
no_update=$true
P4REVISION="@$OLD_LABEL"
extraEnvVars="$extraEnvVars ; P43RDPARTY_LABEL=$1 ; export P43RDPARTY_LABEL"
elif [ $1 = "-new_label" ]
then
shift
NEW_LABEL=$1
arg_err="Bad Label argument"
echo $NEW_LABEL | grep ^- && usage_flag=$true
create_label=$true
elif [ $1 = "-no_update" ]
then
no_update=$true
create_label=$false
elif [ $1 = "-no_tools" ]
then
no_tools=$true
elif [ $1 = "-no_javadocs" ]
then
no_javadocs=$true
elif [ $1 = "-no_metadocs" ]
then
no_metadocs=$true
elif [ $1 = "-no_sync" ]
then
no_sync=$true
elif [ $1 = "-no_release" ]
then
no_release=$true
no_javadocs=$true
no_metadocs=$true
elif [ $1 = "-no_build" ]
then
no_build=$true
elif [ $1 = "-no_install" ]
then
no_install=$true
elif [ $1 = "-no_docs" ]
then
no_docs=$true
elif [ $1 = "-no_cd" ]
then
no_cd=$true
elif [ $1 = "-h" -o $1 = "-help" ]
then
arg_err=""
usage_flag=$true
no_cd=$true
elif [ $1 = "-test" ]
then
TEST=$true
export TEST
elif [ $1 = "-debug" ]
then
debug=$true
p4opt="-n"
set -vx
else
if [ x$CODELINE = x ]
then
#
#Codeline to build
#
CODELINE=$1
else
usage_flag=$true
arg_err="Too many arguments."
fi
fi
shift
done
if [ x$CODELINE = x ]
then
arg_err="Codeline undefined"
usage_flag=$true
else
# Check for leading -. Indicates a parameter was misstyped.
echo $CODELINE | grep ^- && \
(usage_flag=$true; arg_err="Bad Codeline argument")
fi
#
# Must have at least one argument
#
if [ $usage_flag != $false ]
then
echo "$arg_err"
echo "Usage: $prog [parameters] codeline"
echo
echo "Parameters:"
echo " -h|-help - Show usage help"
echo " -no_update - Do not update the label"
echo " -no_javadocs - Do not update release with javadocs"
echo " -no_metadocs - Do not update release with metadoc"
echo " -no_docs - Do not update release with tech docs"
echo " -no_release - Do not update the release depot"
echo " -no_build - Do not build"
echo " -no_install - Do not run install script"
echo " -no_cd - Do not create a CD"
echo " -new_label <label> - Create label"
echo " -old_label <label> - Build from label. Do not create label"
echo " -revision - Build from revision other than label"
echo " note: if using revision you will need to include"
echo " the p4 qualifier of # or @."
echo " -debug - Echo commands, no commit"
echo " -test - Do evertyhing, except submit"
echo
echo "Default for all no options is false. ie. cd image will be created"
echo "unless -no_cd is passed."
exit 1
fi
# Make sure codeline is lower case.
CODELINE=`echo $CODELINE | tr '[A-Z]' '[a-z]'`
# Capitalize CODELINE
UPCODELINE=`echo $CODELINE | tr '[a-z]' '[A-Z]'`
UPPRODUCT=`echo $UPCODELINE | tr -d [0-9]`
if [ "$CODELINE" = "" -o "$UPCODELINE" = "" -o "$UPPRODUCT" = "" ]
then
echo "$prog, BUILD_ERROR: Codeline not defined"
exit 1
fi
# Set up environment.
# Get build info from build depot.
# - client specs, build label, environment settings
# Default client spec should point to location of build.env.
get_root $environment_client
ENVIRONMENT_ROOT="$client_root/tmp"
TOOLS_DIR=$client_root/tools
export TOOLS_DIR
WORK_DIR="$ENVIRONMENT_ROOT/work"
export WORK_DIR
BUILDENV_DIR="$WORK_DIR/$CODELINE/buildenv"
if [ ! -d "$WORK_DIR" ]
then
mkdir -p $WORK_DIR
else
rm -fr $WORK_DIR/*
fi
#PATH="$PATH:$TOOLS_DIR/scm:$TOOLS_DIR/perl/bin:$ENVIRONMENT_ROOT/bin:."
setenv $CODELINE > /tmp/env.$$
if [ $? != 0 ]
then
echo setenv failed
exit 1
fi
. /tmp/env.$$
rm /tmp/env.$$
# Any extra env vars that are suppose to override or be in addition to
# setenv are set in extraEnvVars.
eval $extraEnvVars
# Optimize path variable.
# not working in bash
#opt=`perl $TOOLS_DIR/scm/optpath`
#if [ $? -eq 0 ]; then
# PATH=$opt
#else
# echo path not optimized
#fi
echo Environment set for $CODELINE
# Now that we have the environment defined, define the dependant variables.
# JAVADOC_ROOT=$OWARE_USER_ROOT/owareapps/javadocs
#export JAVADOC_ROOT
#METADOC_ROOT=$OWARE_USER_ROOT/owareapps/metadata
#export METADOC_ROOT
if [ x$OLD_LABEL = x ]
then
OLD_LABEL=$LABEL
fi
if [ $create_label = $false ]
then
# This would be the case of a rebuild.
echo "BUILD_WARNING: $prog, Not building from tip"
if [ x$NEW_LABEL = x ]
then
NEW_LABEL=$OLD_LABEL
fi
fi
if [ $create_label = $true ]
then
if [ x$NEW_LABEL = x ]
then
# if no label defined then get last label and increment.
NEW_LABEL=`echo $OLD_LABEL | awk -F"." \
'{ v=$1; OFS="."; for ( i=2; i<NF; i++ ) v=v"."$i } \
END { print v, $NF+1 }'`
if [ x$NEW_LABEL = x ]
then
echo BUILD_WARNING: using DUMMY$$ for label
NEW_LABEL=DUMMY$$
fi
elif [ "$NEW_LABEL" = "$OLD_LABEL" ]
then
echo BUILD_WARNING: $prog, $NEW_LABEL already exists in build.env.
create_label=$false
fi
fi
# Must revisit this.
if [ x$NEW_LABEL = x ]
then
echo "BUILD_ERROR: Label undefined"
exit 1
# echo "BUILD_WARNING: $prog, Label not set. Will sync to head"
# set NEW_LABEL to OLD_LABEL so that VER can be set correctly.
# NEW_LABEL=${OLD_LABEL}_NOCLUE
# echo "Using label $NEW_LABEL for mystery run"
# P4REVISION=#head
fi
if [ $TEST = $true ]
then
NEW_LABEL=$NEW_LABEL.TEST$$
echo "Using label $NEW_LABEL for test run"
fi
# Label is changed here so that other scripts called from this point on
# will use the new label and not that defined by setenv.
LABEL=$NEW_LABEL
export LABEL
# In the case of a mainline build, the Product and Codeline will be the same.
# However the build and release depots always use Version in the path.
# You may see //oware/oware but never //build/oware.
SOURCE_CODELINE=$CODELINE
# CODELINE is changing from that defined by setenv here. Be sure that any
# future reference to CODELINE is agreeable to this.
if [ "$PRODUCT" = "$CODELINE" ]
then
VER=`echo $LABEL | awk -F. '{ print $2$3}'`
if [ "$VER" = "" ]
then
echo "$prog, BUILD_ERROR: Could not determine version from label $LABEL"
build_err=$true
fi
CODELINE=$CODELINE$VER
export CODELINE
fi
# Version is = to the label without the product prefix.
VERSION=`echo $LABEL | awk -F. \
'BEGIN {ORS=""} {for (i=2; i<=NF-1; i++) print $i"."; print $NF}'`
export VERSION
if [ "$VERSION" = "" ]
then
echo "$prog, BUILD_ERROR: Could not determine version from label $LABEL"
build_err=$true
fi
BUILDENV_DIR="$WORK_DIR/$CODELINE/buildenv"
# Clients
source_client=scm-${CODELINE}-source
build_client=scm-${CODELINE}-build
release_client=scm-${CODELINE}-release
integrate_client=scm-${CODELINE}-integrate
# Get files to define build.
# Cannot sync using client path. Must use depot path.
p4 -s -c $environment_client sync -f //build/$CODELINE/buildenv/...
check_error $? \
"p4 -s -c $environment_client sync -f //build/$CODELINE/buildenv/..."
hold=""
for spec in $CLIENT_SPEC
do
if [ x$spec != x ]
then
hold="$hold scm-${CODELINE}-$spec"
if [ -f $BUILDENV_DIR/${spec}.client ]
then
p4 -s -c scm-${CODELINE}-$spec client -i < $BUILDENV_DIR/${spec}.client
check_error $? \
"p4 -s -c scm-${CODELINE}-$spec client -i < $BUILDENV_DIR/${spec}.client"
else
echo "BUILD_ERROR: $BUILDENV_DIR/${spec}.client missing."
echo "Could not create client spec ${CODELINE}-$spec"
build_err=$true
fi
fi
done
CLIENT_SPEC=$hold
get_root $source_client
BASE_ROOT=$client_root
SOURCE_ROOT=$client_root/$SOURCE_CODELINE ; export SOURCE_ROOT
echo "SOURCE_ROOT set to $SOURCE_ROOT"
OWARE3RD_ROOT=$client_root/oware3rd
JAVADOC_ROOT=$client_root/javadocs
METADOC_ROOT=$client_root/metadata
get_root $build_client
BUILD_ROOT=$client_root/$PRODUCT
echo "BUILD_ROOT set to $BUILD_ROOT"
get_root $release_client
RELEASE_ROOT=$client_root/$CODELINE
echo "RELEASE_ROOT set to $RELEASE_ROOT"
# Modify build client using release.bom.
release_bom=$BUILDENV_DIR/release.bom
raw_bom=$WORK_DIR/raw.bom
jar_bom=$WORK_DIR/jar.bom
if [ -f "$release_bom" ]
then
if [ "$PRODUCT" = "oware" ]
then
jar_list='\.jar|owlicense.properties'
# source.bom contains files under //oware/<codeline/
# strip off the codeline.
grep ^$SOURCE_CODELINE\/ $release_bom | \
awk -F/ 'BEGIN {ORS=""} \
{for ( i=2; i<NF; i++) print $i"/"; print $NF"\n"}' \
> $WORK_DIR/source.bom
check_error $? \
"awk -F/ 'BEGIN {ORS=""} {for ( i=2; i<NF; i++) print $i"/"; print $NF"\n"}'"
# raw.bom contains oware3rd and files directly under //oware
grep -v $SOURCE_CODELINE\/ $release_bom > $WORK_DIR/raw.bom
check_error $? "grep -v $SOURCE_CODELINE\/ $release_bom"
egrep "$jar_list" $WORK_DIR/source.bom > $WORK_DIR/jar.bom
check_error $? \
"egrep '$jar_list' $WORK_DIR/source.bom > $WORK_DIR/jar.bom"
egrep -v "$jar_list" $WORK_DIR/source.bom > $WORK_DIR/temp.bom
check_error $? \
"egrep -v '$jar_list' $WORK_DIR/source.bom > $WORK_DIR/temp.bom"
mv -f $WORK_DIR/temp.bom $WORK_DIR/source.bom
check_error $? "mv -f $WORK_DIR/temp.bom $WORK_DIR/source.bom"
make_client //$PRODUCT/$SOURCE_CODELINE //$build_client/$PRODUCT \
$WORK_DIR/source.bom
check_error $? "make_client //$PRODUCT/$SOURCE_CODELINE //$build_client/$PRODUCT $WORK_DIR/source.bom"
make_client //$PRODUCT //$build_client $raw_bom
check_error $? "make_client //$PRODUCT //$build_client $raw_bom"
make_client //build/$CODELINE //$build_client/$PRODUCT $jar_bom
check_error $? "make_client //build/$CODELINE //$build_client/$PRODUCT"
else
grep -v "\.jar" $release_bom > $WORK_DIR/raw.bom
if [ $? -ne 0 ]
then
echo "$0, BUILD_WARNING: $release_bom does not contain any raw files"
fi
grep "\.jar" $release_bom > $WORK_DIR/jar.bom
check_error $? "grep "\.jar" $release_bom > $WORK_DIR/jar.bom"
make_client //$PRODUCT/$SOURCE_CODELINE //$build_client/$PRODUCT \
$raw_bom
check_error $? \
"make_client //$PRODUCT/$SOURCE_CODELINE //$build_client/$PRODUCT $raw_bom"
make_client //build/$CODELINE //$build_client/$PRODUCT $jar_bom
check_error $? \
"make_client //build/$CODELINE //$build_client/$PRODUCT $jar_bom"
fi
else
echo "$0, WARNING: $release_bom does not exist. $build_client not updated."
fi
# Verify that there are no open files
opened=false
for client in $CLIENT_SPEC $environment_client
do
p4 -c $client -s opened | grep ^error: > /dev/null
if [ $? -ne 0 ]
then
opened=true
echo "$0, BUILD_WARNING: files opened on client $client"
fi
done
if [ "$opened" = "true" ]
then
echo "Build aborted."
exit 1
fi
#LOG_DIR=$RELEASE_ROOT/logs
if [ ! -d "$LOG_DIR" ]
then
mkdir -p $LOG_DIR
else
# Move so rebuilds don't overwrite.
dt="-`date +%m%d`-1"
i=1
while [ -d "${LOG_DIR}$dt" ]
do
i=`expr $i + 1`
dt="-`date +%m%d`-$i"
done
mv $LOG_DIR ${LOG_DIR}$dt
mkdir -p $LOG_DIR
fi
# Do build
if [ $no_build = $false ] # start build
then
echo Building $CODELINE
# Clean up from old builds.
echo "Cleaning up from previous builds"
if [ -$no_synv = $false ]
then
if [ -d "$SOURCE_ROOT" ]
then
rm -fr $SOURCE_ROOT/*
fi
if [ -d "$OWARE3RD_ROOT" ]
then
rm -fr $OWARE3RD_ROOT/*
fi
fi
if [ -d "$BUILD_ROOT" ]
then
rm -fr $BUILD_ROOT/*
fi
if [ -d "$JAVADOC_ROOT" ]
then
rm -fr $JAVADOC_ROOT/*
fi
if [ -d "$METADOC_ROOT" ]
then
rm -fr $METADOC_ROOT/*
fi
# Validate environment
#
# check for changes in environment variables.
#
ignore_patterns='PROJECT_ENV|SRCDATE|DATE|BUILDTIME_LOG|LOG_DIR'
env_out="$WORK_DIR/$CODELINE/env.out"
env_dif="$WORK_DIR/$CODELINE/env.dif"
env_ref="$WORK_DIR/$CODELINE/buildenv/env.ref"
env | egrep -v "$ignore_patterns" | sort > $env_out 2>&1
if [ -f "$env_ref" ]; then
diff $env_out $env_ref > $env_dif 2>&1
if [ -f "$env_dif" ]; then
if [ `cat $env_dif |wc -w` -eq 0 ]; then
echo "No change in environment variables."
else
echo "BUILD_WARNING: ${prog}. $env_dif is not empty"
fi
else
echo "BUILD_WARNING: ${prog}. $env_dif does not exist."
fi
else
echo "BUILD_ERROR: ${prog}. $env_ref does not exist."
build_err=$true
fi
if [ "$PRODUCT" = oware ]
then
eval OWARE_ROOT=$OWARE_ROOT ; export OWARE_ROOT
if [ x$OWARE_3RDPARTY_LABEL = x -a x$P43RDPARTY_LABEL = x ]
then
echo "BUILD_WARNING: $prog, Label not set. Will sync 3rd Party from head"
P43RDPARTY_REVISION="#head"
else
P43RDPARTY_REVISION="@$OWARE_3RDPARTY_LABEL"
fi
if [ $no_sync != $true ]
then
echo "Getting Oware3rd: //oware/oware3rd/...$P43RDPARTY_REVISION"
p4 -s -c $source_client sync -f \
//oware/oware3rd/...$P43RDPARTY_REVISION > $LOG_DIR/oware3rd.out
check_error $? \
"p4 -c $source_client sync -f //oware/oware3rd/...$P43RDPARTY_REVISION"
echo "Getting files from root if they exist"
p4 -s -c $source_client sync -f //$PRODUCT/*
check_error $? "p4 -s -c $source_client sync -f //$PRODUCT/*"
fi
fi
# Not checking for p4 errors because the edit code here will actually be from
# the grep command. Perforce will actually return an error message with an
# exit code of 0. This is one reason I use the -s parameter. With -s, p4
# will display "error:" in the message even though it exits with 0.
if [ $no_tools = $false -a $no_sync = $false ]
then
#Get tools
echo "Getting tools: //oware/tools/..."
p4 -s -c $source_client sync -f //oware/tools/... > $LOG_DIR/tools.out
if [ $? -ne 0 ]
then
echo "$0, BUILD_WARNING: Error in syncing tools"
fi
fi
# Get latest change list prior to syncing source.
change=`p4 -c $source_client -s changes -m1 -s submitted \
$SOURCE_ROOT/...$P4REVISION | awk '{ print $3 }'`
if [ $? -ne 0 ]
then
echo $change
build_err=1
fi
if [ "$P4REVISION" = "#head" -o "x$P4REVISION" = x ]
then
P4REVISION="@$change"
fi
if [ $no_sync != $true ]
then
# Get source
echo "Getting source: $SOURCE_ROOT/...$P4REVISION"
p4 -s -c $source_client sync -f \
$SOURCE_ROOT/...$P4REVISION > $LOG_DIR/source.out
check_error $? \
"p4 -s -c $source_client sync -f $SOURCE_ROOT/...$P4REVISION"
fi
echo "Executing bom_operator 'rm -f' $SOURCE_ROOT $jar_bom"
bom_operator "rm -f" $SOURCE_ROOT $jar_bom
# Build source
cd $SOURCE_ROOT
echo "Running $BUILD_SCRIPT"
## LOG_OUT=${LOG_DIR}/${PRODUCT}_build.log
eval $BUILD_SCRIPT
check_error $? "$BUILD_SCRIPT"
# run release
# Release builds the jars and copies the files packaged by nt installer.
# Problem is that oware does not do this.
# Should probably fold this into the build script.
# Should also use a client spec or a file containg file listing to move files.
if [ x$RELEASE_SCRIPT != x ]
then
echo Running $RELEASE_SCRIPT
LOG_OUT=$LOG_DIR`echo $RELEASE_SCRIPT | awk '{print $1".log"}'`
$RELEASE_SCRIPT >> $LOG_OUT 2>$1
check_error $? "$RELEASE_SCRIPT >> $LOG_OUT 2>$1"
fi
# Add jars to build depot.
mkdir -p `bom_operator dirname $BUILD_ROOT $jar_bom`
check_error $? "mkdir -p `bom_operator dirname $BUILD_ROOT $jar_bom`"
echo "Executing bom_operator 'cp -p' $SOURCE_ROOT $BUILD_ROOT $jar_bom"
bom_operator "cp -p" $SOURCE_ROOT $BUILD_ROOT $jar_bom
check_error $? " bom_operator "cp -p" $SOURCE_ROOT $BUILD_ROOT $jar_bom"
for jar in `cat $jar_bom`
do
if [ "x$jar" != "x" ]
then
update_depot -c $build_client $BUILD_ROOT/$jar
check_error $? "update_depot -c $build_client $BUILD_ROOT/$jar"
else
echo "$prog, BUILD_WARNING: empty line in $BUILD_ROOT/$jar_bom"
fi
done
doc=""
if [ $no_javadocs = $false -a $no_release = $false ]
then
echo Adding Javadocs
update_depot -c $release_client $JAVADOC_ROOT/...
check_error $? "update_depot -c $release_client $JAVADOC_ROOT/..."
doc=", javadocs"
fi
if [ $no_metadocs = $false -a $no_release = $false ]
then
echo Adding Metadocs
update_depot -c $release_client $METADOC_ROOT/...
check_error $? "update_depot -c $release_client $METADOC_ROOT/..."
doc="$doc and metadocs"
fi
if [ $build_err -ne $true ]
then
p4_submit "Jar files$doc for $LABEL" $build_client
check_error $? "p4_submit "Jar files$doc for $LABEL" $build_client"
else
echo "BUILD_WARNING: Jar files$doc not submitted due to build errors"
fi
if [ $no_update = $false ]
then
#Apply label
P4_LABEL -new $LABEL $SOURCE_ROOT/... $source_client
echo "Executing bom_operator 'p4 -c $build_client labelsync -a -l $LABELs' $BUILD_ROOT $jar_bom"
bom_operator "p4 -c $build_client labelsync -a -l $LABEL" $BUILD_ROOT $jar_bom >> $LOG_DIR/label.log
check_error $? "bom_operator 'p4 -c $build_client labelsync -a -l $LABEL' $BUILD_ROOT $jar_bom"
fi
fi # End build
if [ $no_install = "$false" ]
then
# switch to install_client if make_release doesn't.
if [ $no_release = "$false" -a $build_err = "$false" ]
then
if [ "$PRODUCT" != "oware" ]
then
BASE_VER=`echo $BASE_LABEL | awk -F. '{print $2$3}'`
eval BASE_CODELINE=$`echo $BASE_LABEL | awk -F. '{print $1}'`
BASE_CODELINE=$BASE_CODELINE$BASE_VER
if [ "$BASE_VER" = "" -o "$BASE_CODELINE" = "" ]
then
echo "$prog, BUILD_ERROR: Could not determine base codeline usinglabel $BASE_LABEL"
build_err=$true
fi
fi
make_release $CODELINE $LABEL $BASE_CODELINE $BASE_LABEL
check_error $? \
"make_release $CODELINE $LABEL $BASE_CODELINE $BASE_LABEL"
elif [ $build_err != $false ]
then
echo BUILD_WARNING: make_release not run due to build errors
fi
fi
if [ $no_docs = "$false" -a $no_release = "$false" ]
then
echo Copying Tech Docs
# Integrate Techdocs
p4 -s -c $release_client integrate $p4opt -v -d -b $RELEASE_BRANCH
check_error $? "p4 -s -c $release_client integrate -v -d -b $RELEASE_BRANCH"
fi
if [ $no_cd = "$false" ]
then
echo Creating CD image
echo Sending output to $LOG_DIR/cdimage.log
# Create CD image
cdimage $LABEL $RELEASE_ROOT/CDLayout > $LOG_DIR/cdimage.log 2>&1
check_error $? \
"cdimage $LABEL $RELEASE_ROOT/CDLayout > $LOG_DIR/cdimage.log"
if [ $no_release = $false ]
then
# Check image into Release Depot.
dummy=1
fi
fi
if [ $no_release = $false ]
then
# Check install into Release Depot.
# Release client is done. Apply label.
P4_LABEL -old $LABEL $RELEASE_ROOT/... $release_client
fi
if [ $create_label = $true -a $no_update = $false ]
then
# Build finished.
# Update build.env with new label.
p4 -c $environment_client -s edit //build/build.env
check_error $? "p4 -c $environment_client -s edit //build/build.env"
eval sed '/$UPCODELINE/,/LABEL/s/$OLD_LABEL/$LABEL/' \
$ENVIRONMENT_ROOT/build.env > $WORK_DIR/build.env
check_error $? "eval sed '/$UPCODELINE/,/LABEL/s/$OLD_LABEL/$LABEL/'\
$ENVIRONMENT_ROOT/build.env"
if [ $build_err -ne $true ]
then
mv -f $WORK_DIR/build.env $ENVIRONMENT_ROOT/build.env
check_error $? "mv -f $WORK_DIR/build.env $ENVIRONMENT_ROOT/build.env"
p4_submit "Label changed to $LABEL" $environment_client
check_error $? "p4_submit "Label changed to $LABEL" $environment_client"
else
echo "BUILD_WARNING: Label not updated in build.env due to build errors"
fi
fi
if [ $no_build = $false ]
then
if [ $no_update = $false ]
then
# add to label
P4_LABEL -old $LABEL $BUILD_ROOT $build_client
fi
# Double check changes.
# rechange=`p4 -s -c $source_client changes -m1 //$PRODUCT/$CODELINE/... \
rechange=`p4 -s -c $source_client changes -m1 -s submitted $SOURCE_ROOT/... \
| awk '{ print $3 }'`
if [ $? -ne 0 ]
then
echo $rechange
fi
if [ "$change" != "$rechange" ]
then
echo BUILD_WARNING: Changelist $rechange was submitted during build.
fi
fi
update_depot -c $release_client $LOG_DIR
check_error $? "update_depot -c $release_client $LOG_DIR"
# submit changes
if [ $build_err -eq $false ]
then
echo "Submitting log files"
p4_submit "Log files for $LABEL" $release_client
check_error $? "p4_submit "Log files for $LABEL" $release_client"
echo "Adding files to label $to_label"
p4 -s -c $release_client labelsync -a -l $LABEL $LOG_DIR/*
check_error $? "p4 -s -c $release_client labelsync -a -l $LABEL $LOG_DIR/*"
else
echo "BUILD_WARNING: Log files not submitted due to errors"
fi
# Verify that there are no open files
for client in $CLIENT_SPEC $environment_client
do
p4 -c $client -s opened | grep ^error: > /dev/null
if [ $? -ne 0 ]
then
echo "$0, BUILD_WARNING: files opened on client $client"
fi
done
if [ x$change != x ]
then
echo Build finished thru changelist $change
else
echo Build finished
fi
if [ $build_err -eq $false ]
then
echo "no errors detected"
else
echo "with errors"
fi
exit $build_err