hdf5/bin/snapshot
Albert Cheng 68bf4cc74b [svn-r1983] Added two new options.
srcdirname <dir>:
	  Use <dir> as the srcdir testing directory if srcdir is choosen.
	  If <dir> starts with '-', it is append to the default name
	  E.g., "snapshot srcdir srcdirname -xx" uses hostname-xx
	  [Default is hostname]
op-configure <option>:
	  Pass <option> to the configure command
2000-02-22 12:27:48 -05:00

257 lines
6.6 KiB
Bash
Executable File

#!/bin/sh
set -x
date
uname -a
#
# This script should be run nightly from cron. It checks out hdf5
# from the CVS source tree and compares it against the previous
# snapshot. If anything significant changed then a new snapshot is
# created, the minor version number is incremented, and the change is
# checked back into the CVS repository.
#
# The path isn't properly initialized on hawkwind -- /usr/local/bin is
# either missing or is after /usr/bin when it should be before.
PATH="/usr/local/bin:$PATH"
# Where are the snapshots stored?
ARCHIVES_default=/afs/ncsa/ftp/HDF/pub/outgoing/hdf5/snapshots
ARCHIVES=$ARCHIVES_default
# Where are the HDF4 library?
# At NCSA, the standard place to find HDF4 software is in /usr/ncsa/.
HDF4LIB_default="/usr/ncsa/include,/usr/ncsa/lib"
HDF4LIB=$HDF4LIB_default
# What compression methods to use?
METHODS="gzip bzip2"
# Use User's MAKE if set. Else use generic make.
MAKE=${MAKE:-make}
# Make sure cvs would work
if [ -z "$CVSROOT" ]; then
echo "Where is the CVS repository?" 1>&2
exit 1
fi
#
# Command options
cmd="all"
test_opt=""
errcode=0
echo '$#=' $# '$*="' $* '"'
while [ $# -gt 0 ] ; do
case "$1" in
all)
cmd="all"
;;
checkout)
cmdcheckout="checkout"
cmd=""
;;
test)
cmdtest="test"
cmd=""
;;
srcdir)
#use srcdir option for test
srcdir="yes"
;;
srcdirname)
shift
if [ $# -lt 1 ]; then
echo "srcdirname <dir> missing"
errcode=1
cmd="help"
break
fi
SRCDIRNAME="$1"
;;
release)
cmdrel="release"
cmd=""
;;
help)
cmd="help"
break
;;
hdf4)
shift
if [ $# -lt 1 ]; then
echo "HDF4LIB information missing"
errcode=1
cmd="help"
break
fi
HDF4LIB="$1"
;;
archive)
shift
if [ $# -lt 1 ]; then
echo "Archive pathname missing"
errcode=1
cmd="help"
break
fi
ARCHIVES="$1"
;;
op-configure)
shift
if [ $# -lt 1 ]; then
echo "op-configure option missing"
errcode=1
cmd="help"
break
fi
OP_CONFIGURE="$OP_CONFIGURE $1"
;;
*)
echo "Unkown option $1"
errcode=1
cmd="help"
break
;;
esac
shift
done
if [ "$cmd" = help ]; then
set -
echo "Usage: $0 [all] [checkout] [test] [srcdir] [release] [help] [hdf4 <hdf4lib_path>] [archive <arch_path>] [dir <dir>] [op-configure <option>]"
echo " all: Run all commands (checkout, test & release)"
echo " [Default is all]"
echo " checkout: Run cvs checkout"
echo " test: Run test"
echo " release: Run release"
echo " srcdir: Use srcdir option (does not imply other commands)"
echo ' "snapshot srcdir" is equivalent to "snapshot srcdir all"'
echo ' "snapshot srcdir checkout" is equivalent to "snapshot checkout"'
echo " srcdirname <dir>:"
echo " Use <dir> as the srcdir testing directory if srcdir is choosen."
echo " If <dir> starts with '-', it is append to the default name"
echo ' E.g., "snapshot srcdir srcdirname -xx" uses hostname-xx'
echo " [Default is hostname]"
echo " help: Print this message"
echo " hdf4 <hdf4lib_path>:"
echo " Use <hdf4lib_path> as the HDF4LIB locations"
echo " [Default is $HDF4LIB_default]"
echo " archive <arch_path>:"
echo " Use <arch_path> as the release ARCHIVE area"
echo " [Default is $ARCHIVES_default]"
echo " op-configure <option>:"
echo " Pass <option> to the configure command"
exit $errcode
fi
# Setup the proper configure option (--with-hdf4) to use hdf4 library
# provide HDF4LIB is non-empty.
HDF4LIB=${HDF4LIB:+"--with-hdf4="$HDF4LIB}
CONFIGURE="./configure $HDF4LIB $OP_CONFIGURE"
# Execute the requests
snapshot=yes
BASEDIR=${HOME}/hdf5-snapshots
CURRENT=${BASEDIR}/current
PREVIOUS=${BASEDIR}/previous
#=============================
# Run CVS checkout
#=============================
if [ "$cmd" = "all" -o -n "$cmdcheckout" ]; then
# Create a working directory. Hopefully one is left over from last
# time that still has the contents of the previous release. But if
# not, just create one and assume that a snapshot is necessary.
test -d ${BASEDIR} || mkdir -p ${BASEDIR} || exit 1
# Check out the current version from CVS
cvs -Q co -d ${CURRENT} hdf5 || exit 1
fi # Do CVS checkout
#=============================
# Run Test the HDF5 library
#=============================
if [ "$cmd" = "all" -o -n "$cmdtest" ]; then
# setup if srcdir is used.
if [ -z "$srcdir" ]; then
TESTDIR=${CURRENT}
else
#create TESTDIR if not exist yet
case "$SRCDIRNAME" in
"")
SRCDIRNAME=`hostname`
;;
-*)
SRCDIRNAME="`hostname`$SRCDIRNAME"
;;
esac
TESTDIR=${BASEDIR}/TestDir/${SRCDIRNAME}
test -d ${TESTDIR} || mkdir ${TESTDIR}
fi
# Make sure current version exists and is clean
if [ -d ${TESTDIR} ]; then
(cd ${TESTDIR} && ${MAKE} distclean)
else
errcode=$?
snapshot=no
exit $errcode
fi
# Compare it with the previous version. Compare only files listed in
# the MANIFEST plus the MANIFEST itself.
if [ -d ${PREVIOUS} ]; then
if (diff -c ${PREVIOUS}/MANIFEST ${CURRENT}/MANIFEST); then
snapshot=no
for src in `grep '^\.' ${CURRENT}/MANIFEST|expand|cut -f1 -d' '`; do
diff -I H5_VERS_RELEASE -I " released on " \
-I " currently under development" \
${PREVIOUS}/$src ${CURRENT}/$src || \
snapshot=yes
# Don't break because we want to see all the diffs.
done
fi
fi
# Make sure all the serial tests work.
if [ "$snapshot" = "yes" ]; then
if (cd ${TESTDIR}; \
${srcdir:+${CURRENT}/}${CONFIGURE}; \
${MAKE} check); then
:
else
errcode=$?
snapshot=no
exit $errcode
fi
fi
fi # Test the HDF5 library
#=============================
# Run Release snapshot, update version, and commit to cvs and tag
#=============================
if [ "$cmd" = "all" -o -n "$cmdrel" ]; then
if [ "$snapshot" = "yes" ]; then
(cd ${CURRENT}; ${MAKE} distclean)
(
# Turn on exit on error in the sub-shell so that it does not
# cvs commit if errors encounter here.
set -e
cd ${CURRENT}
bin/release -d $ARCHIVES $METHODS
RELEASE_VERSION="`perl bin/h5vers -v`"
perl bin/h5vers -i
cvs -Q commit -m "Snapshot $RELEASE_VERSION"
)
errcode=$?
fi
# Replace the previous version with the current version.
rm -rf ${PREVIOUS}
mv ${CURRENT} ${PREVIOUS}
fi #Release snapshot
exit $errcode