#! /bin/bash
WEBDIR="/web/rkeene/devel/kitcreator/kitbuild"
export WEBDIR
if [ ! -d "kits" ]; then
echo 'Could not find kits/ directory, aborting.' >&2
exit 1
fi
rm -rf "${WEBDIR}"
mkdir -p "${WEBDIR}" || exit 1
cp -r kits/* "${WEBDIR}"
ln -s ../index.ttml "${WEBDIR}/" >/dev/null 2>/dev/null
totaltests_count="$(ls -1 tests/*.tcl | wc -l)"
for file in "${WEBDIR}"/*; do
if [ -d "${file}" ]; then
continue
fi
if echo "${file}" | egrep '\.(log|desc|ttml)$' >/dev/null; then
continue
fi
# Find out which tests failed
failedtests_count="0"
failedtests=""
for faillog in "${file}"-[0-9][0-9]-*.log; do
if [ ! -f "${faillog}" ]; then
continue
fi
failedtests_count=$[${failedtests} + 1]
failedtests="${failedtests} $(basename "${faillog}")"
done
# Generate description
descfile="${file}.desc"
shortfile="$(basename "${file}")"
desc=""
tclversion="$(echo "${shortfile}" | cut -f 2 -d -)"
parts="$(echo "${shortfile}" | cut -f 3- -d -)"
while [ "${parts}" != "" ]; do
case "${parts}-" in
normal-*)
true
;;
arm-*)
desc="${desc} on the CPU architecture MIPSEL/uClibc"
;;
win32-*)
desc="${desc} for Microsoft Windows"
;;
threaded-*)
desc="${desc} with threads support"
;;
min-*)
desc="${desc} compiled minimally"
;;
static-*)
desc="${desc} and statically"
;;
notk-*)
if echo "${desc}" | grep -i support >/dev/null; then
desc="${desc} and"
fi
desc="${desc} without Tk"
;;
statictk-*)
if echo "${desc}" | grep -i support >/dev/null; then
desc="${desc} and"
fi
desc="${desc} with Tk linked directly to the kit"
;;
zip-*)
desc="${desc} using ZIP for Kit storage"
;;
*)
echo "Unknown part (\"${parts}\"), skipping \"${shortfile}\"" >&2
break
;;
esac
newparts="$(echo "${parts}" | cut -f 2- -d -)"
if [ "${newparts}" = "${parts}" ]; then
parts=""
else
parts="${newparts}"
fi
done
if [ -z "${desc}" ]; then
continue
fi
# Generate better Tcl version
case "${tclversion}" in
cvs_HEAD)
tclversion="from CVS HEAD"
;;
cvs_*)
tclversion="from CVS tag $(echo "${tclversion}" | cut -f 2 -d _)"
;;
esac
# Update description with count of failed tests
if [ "${failedtests_count}" != "0" ]; then
desc="${desc} (FAILED ${failedtests_count} of ${totaltests_count} tests)"
fi
desc="is a Tclkit for Tcl ${tclversion}${desc}"
done
rmdir "${WEBDIR}/failed" >/dev/null 2>/dev/null
ln -s ../index.ttml "${WEBDIR}/failed/" >/dev/null 2>/dev/null
exit 0