#! /bin/sh

# ${RHOME}/etc/LIBINDEX for updating library index
# Usage:
#      R LIBINDEX [lib]
#

lib=${1:-${RHOME}/library}
test -d ${lib} || {
	echo "ERROR:" ${lib} "does not exist or is not a directory"
	exit 1
}
lib=`cd ${lib}; pwd`

rm -f ${lib}/LibIndex

echo "updating LibIndex for library " ${lib} "..."
for pkg in `ls -d ${lib}/*`; do
    if test -f ${pkg}/TITLE; then
#      echo " adding entry for library" ${pkg##*/}
       cat ${pkg}/TITLE >> ${lib}/LibIndex 2> /dev/null
    fi
done

echo "updating HTML index ..."

${RHOME}/bin/build-help --htmllists
