#! /bin/sh
# script to make a patch release, based on Release/patches/HOWTO
unset PARA
while getopts p: OPT; do
case $OPT in
p)
PARA="$OPTARG" # number of parallel library builds
;;
esac
done
shift `expr $OPTIND - 1`
if [ $# -lt 2 ]
then
echo " "
echo " OOPS : ERROR - usage: relpatch ."
echo " You must have a local file named .patches "
echo " containing the patches for your release "
echo " "
exit 1
fi
# Summary of parameters :
#
# For cdfsoftb0 and cdfpatch releases, you need only 1 thru 3
# ================================================
#
# -j - number of libraries to build in parallel
# this must come before the following parameters
#
# $1 : base release that the test release is based on (e.g. 3.11.0)
#
# $2 : defines the patch file
# (e.g. if $2 is "a", the patch file is 3.11.0a.patches)
#
# $3 : patch name.
# For local builds (see $5) this is the area under which the test release
# will be created, relative to the area in which relpatch is running.
# Local builds of 'cdfsoftb0' or 'cdfpatch' will be built under `pwd`
#
# $4 : test release extension.
# An optional extension to the name of the test release.
#
# $5 : flag to determine if the test release is local or not :
# $5 = "local" : build under current if cdfpatch or cdfsoftb0
# build under ${PATCHNAME} otherwise
# $5 = "notlocal" : build under ${SRT_DIST}/${PATCHNAME}
#
# EXTREMELY IMPORTANT FOR LEVEL-3 DEVELOPERS : the behaviour of this script
# should always remain unchanged if it is run in "notlocal" mode, which is
# the default if this and subsequent arguments are omitted.
# It is in this mode that consumer test releases are built.
#
# $6 : flag to determine if dependencies should be checked
# and relevant additions made to the test release :
# $6 = "depend" : do the dependency checking, add packages as necessary.
# $6 = "nodepend" : skip the dependency checking.
#
# $7 : flag to determine which version of Apply_patches to run :
# $7 = "local" : look for Apply_patches script in current directory.
# $7 = "frozen" : look for Apply_patches script in release $1 (default).
#
# $8 : Flag to allow the path to be shortened removing the patch name.
# $8 = "truncate" : truncate the path
# $8 = "" : normal behaviour
#
BASERELEASE=$1
BASEMOD=$2
PATCHNAME=$3
TESTRELEASEEXTENSION=$4
LOCAL=$5
DEPEND=$6
APPLY_PATCHES_VERSION=$7
TRUNCATE_PATH=$8
[ -z "${PATCHNAME}" ] && PATCHNAME=cdfsoftb0
# Default to not local (for reasons of backwards compatibility) :
[ -z "${LOCAL}" ] && LOCAL=notlocal
# Default to depend (for reasons of backwards compatibility) :
[ -z "${DEPEND}" ] && DEPEND=depend
# Default to frozen (for reasons of backwards compatibility) :
[ -z "${APPLY_PATCHES_VERSION}" ] && APPLY_PATCHES_VERSION=frozen
PATCHRELEASE=${BASERELEASE}${BASEMOD}
PATCHFILE=${PATCHRELEASE}.patches
INCLUSIONFILE=${PATCHRELEASE}.needed_packages
if [ "${TRUNCATE_PATH}" = "truncate" ]
then
TESTRELEASENAME=${TESTRELEASEEXTENSION}
else
TESTRELEASENAME=${PATCHRELEASE}${TESTRELEASEEXTENSION}
fi
CDFSOFT_HOME=`csh -f -c "echo ~cdfsoft"`
MAIN()
{
#########
# setup #
#########
echo " OK - running relpatch 2005 08 31 on `date`"
if [ -d ${TESTRELEASENAME} ]
then
echo " "
echo " OOPS - ERROR - already have ${TESTRELEASENAME} "
echo " bailing out"
echo " "
exit 1
fi
echo " OK - creating new release ${TESTRELEASENAME}"
SrtQual="${SRT_QUAL}"
. ${CDFSOFT_HOME}/cdf2.shrc
setup cdfsoft2 ${BASERELEASE}
[ -n "${SrtQual}" ] && srt_setup "SRT_QUAL=${SrtQual}"
# If running in local mode, don't yet cd to the base directory.
# This takes place after running Apply_patches :
DOBUILD=""
if [ "${LOCAL}" = "local" ]; then
if [ "${PATCHNAME}" = "cdfsoftb0" -o "${PATCHNAME}" = "cdfpatch" ]
then
BASEDIR=`pwd`
DOBUILD=yes
echo " OK - will build local ${PATCHNAME}"
else
BASEDIR=${PATCHNAME}
fi
echo " OK - Setting BASEDIR = ${BASEDIR}"
else
BASEDIR=${SRT_DIST}/${PATCHNAME}
cd ${BASEDIR}
DOBUILD=yes
fi
###########
# patches #
###########
if [ -r "${PATCHRELEASE}.patches" ]
then
echo " OK - have patch file ${PATCHRELEASE}.patches "
else
echo " OK - fetching ${PATCHRELEASE}.patches from CVS "
mkdir -p cvstmp
cvs export -D now -d cvstmp Release/patches/${PATCHRELEASE}.patches
mv cvstmp/${PATCHRELEASE}.patches ${PATCHRELEASE}.patches
rm -r cvstmp
if [ -r "${PATCHRELEASE}.patches" ]
then
echo " OK - have patch file ${PATCHRELEASE}.patches "
else
echo " OOPS - do not have patch file ${PATCHRELEASE}.patches "
echo " BAILING OUT "
exit 1
fi
fi
###################
# needed packages #
###################
if [ -r "${INCLUSIONFILE}" ]
then
echo " OK - reading ${INCLUSIONFILE} "
while read pack
do
if [ "$pack" = "" ]
then
continue
fi
if [ `echo ${pack}|cut -c1` = '#' ]
then
continue
fi
NEEDEDPACKAGES="${NEEDEDPACKAGES} $pack"
done < ${INCLUSIONFILE}
else
echo " OK - including standard packages "
[ "${PATCHNAME}" = "cdfsoftb0" ] && \
NEEDEDPACKAGES="\
Consumer \
DBANA \
FrameMods \
RootMods \
SvxDaqMods \
"
[ "${PATCHNAME}" = "cdfpatch" ] && \
NEEDEDPACKAGES="\
Production \
"
echo "${NEEDEDPACKAGES}"
fi
#########
# apply #
#########
echo " OK - applying patches "
Apply_patches_argument=""
if [ ${DEPEND} = "nodepend" ]
then
Apply_patches_argument="-n"
fi
Apply_patches_path=""
if [ ${APPLY_PATCHES_VERSION} = "local" ]
then
Apply_patches_path="."
else
Apply_patches_path="${SRT_DIST}/releases/development/Release/Scripts"
fi
${Apply_patches_path}/Apply_patches ${Apply_patches_argument} \
${BASERELEASE} \
${BASEDIR} \
${TESTRELEASENAME} \
${PATCHRELEASE}.patches \
${PATCHRELEASE}.excluded_packages \
> ${TESTRELEASENAME}.app.log 2>&1
if [ `grep -c '\[' ${TESTRELEASENAME}.app.log` -gt 0 ]
then
echo " OOPS - ERROR - found error in ${TESTRELEASENAME}.app.log"
echo ""
grep '\[' ${TESTRELEASENAME}.app.log
echo ""
exit 1
else
echo " OK - applied patches cleanly "
fi
#############
# libraries #
#############
# If running in Local mode, we haven't yet cd'd to the base directory :
if [ ${LOCAL} = "local" ]; then
cd ${BASEDIR}
fi
cd ${TESTRELEASENAME}
if [ -n "${DOBUILD}" ]
then
echo " OK - building libraries for ${TESTRELEASENAME}..."
if [ -z "${PARA}" ]
then
(time gmake nobin) > gmake.log 2>&1
else
export PREVIOUS_STAGES ; PREVIOUS_STAGES=
export LOG_DIR
LOG_DIR=build-logs
[ -d "${LOG_DIR}" ] && rm -r ${LOG_DIR}
mkdir ${LOG_DIR}
echo " "
echo " REFRESH `date`"
/usr/bin/time -p gmake -j ${PARA} PARALLEL_TOP=t PREVIOUS_STAGES= refresh \
> rebuild.prog 2>&1
echo " CODEGEN `date`"
/usr/bin/time -p gmake -j ${PARA} PARALLEL_TOP=t PREVIOUS_STAGES= codegen \
>> rebuild.prog 2>&1
echo " INCLUDE `date`"
/usr/bin/time -p gmake -j ${PARA} PARALLEL_TOP=t PREVIOUS_STAGES= include \
>> rebuild.prog 2>&1
echo " LIB `date`"
/usr/bin/time -p gmake -j ${PARA} PARALLEL_TOP=t PREVIOUS_STAGES= lib \
>> rebuild.prog 2>&1
echo " SHAREDLIB `date`"
/usr/bin/time -p gmake -j ${PARA} PARALLEL_TOP=t PREVIOUS_STAGES= sharedlib \
>> rebuild.prog 2>&1
echo " CATLOGS `date`"
echo " "
${PROJECT_DIR}/Distribution/catlogs \
`pwd`/build-logs \
`pwd`/gmake.log
echo " "
fi
if [ `grep -c 'gmake\[1' gmake.log` -gt 0 ]
then
echo " OOPS - ERROR - found errors in gmake.log "
echo " "
grep 'gmake\[1' gmake.log
echo " "
exit 1
else
echo " OK - gmake.nobin looks clean"
fi
fi
echo " OK - adding additional packages as needed "
for PKG in ${NEEDEDPACKAGES}
do
if [ -d "${PKG}" ]
then
echo " OK - have package ${PKG}."
else
echo " OK - adding package ${PKG}."
addpkg -Q ${PKG} > additionalpackages.log 2>&1
fi
done
########
# bins #
########
if [ -n "${DOBUILD}" ]
then
if [ -x "${PROJECT_DIR}/Release/patches/${PATCHNAME}.bins" ]
then
echo " OK - found ${PATCHNAME}.bins in Release package "
cp ${PROJECT_DIR}/Release/patches/${PATCHNAME}.bins bins
elif [ -x "${BASEDIR}/${PATCHNAME}.bins" ]
then
echo " OK - taking ${PATCHNAME}.bins from ${PATCHNAME} area "
cp ${BASEDIR}/${PATCHNAME}.bins bins
else
echo " OOPS - did not find ${PATCHNAME}.bins "
fi
if [ -r "bins" ]
then
echo " OK - building binaries with ${PATCHNAME}.bins "
(time ./bins) > bins.log 2>&1
if [ `grep -c 'gmake\[1' bins.log` -gt 0 ]
then
echo " OOPS - ERROR - found errors in bins.log "
echo " "
grep 'gmake\[1' bins.log
echo " "
exit 1
else
echo " OK - bins.log looks clean"
fi
fi
fi
#############
# ups table #
#############
if [ -r "${PROJECT_DIR}/Release/patches/${PATCHNAME}.table" ]
then
echo " OK - found ${PATCHNAME}.table in Release package "
cp ${PROJECT_DIR}/Release/patches/${PATCHNAME}.table ups/
elif [ -r "../${PATCHNAME}.table" ]
then
echo " OK - taking ${PATCHNAME}.table from patch area "
cp ../${PATCHNAME}.table ups/
else
echo " INFO - did not find ${PATCHNAME}.table "
echo " OK if patch release is not to be ups declared "
exit
fi
printf ",s:BASERELEASE:${BASERELEASE}:g\nw\nq" | \
ed -s ups/${PATCHNAME}.table
if [ ${LOCAL} = "local" ]
then
echo 'ups declare '${PATCHNAME} ${PATCHRELEASE} -r ${BASEDIR}/${PATCHRELEASE} -m ${PATCHNAME}.table' -z ${HOME}/upsdb -2' \
> declare.csh
else
echo 'ups declare '${PATCHNAME} ${PATCHRELEASE}' -r ${SRT_DIST}/'${PATCHNAME}/${PATCHRELEASE} -m ${PATCHNAME}.table' -z ${HOME}/upsdb -2' \
> declare.csh
fi
echo 'ups declare -c '${PATCHNAME} ${PATCHRELEASE}' -z ${HOME}/upsdb -2' \
> current.csh
echo " OK - finished relpatch on `date`"
echo " "
echo " OK - created new patch release successfully."
echo " source ${PATCHRELEASE}/declare.csh to declare it to cvs"
echo " source ${PATCHRELEASE}/current.csh to make it current"
exit
}
MAIN 2>&1 | tee ${TESTRELEASENAME}.log
exit
2004 12 15 kreymer
Added -p to allow parallel library build
This option must proceed all parameters