#! /bin/sh

# ${RHOME}/etc/REMOVE for removing add-on packages
# Usage:
#	R REMOVE pkg [lib]

if [ "$1" ]
then
    pkg=$1
else
    echo "usage:  R REMOVE pkg [lib]"
    exit 1
fi

lib=${2:-${RHOME}/library}
if test -d ${lib}
then
    lib=`cd ${lib}; pwd`
else    
    echo "Cannot find directory \`${lib}'"
    exit 1
fi    

cd ${lib}
if test -d ${pkg};
then
    rm -rf ${pkg}
    cat */TITLE > LibIndex 2> /dev/null
else
    echo "There is no pkg \`${pkg}' in lib \`${lib}'"
    exit 1
fi

NO_PERL5=""

if [ "$NO_PERL5" ]
then
    echo "*** Cannot update the file"
    echo "***    ${RHOME}/library/index.html"
    echo "*** without perl, version 5. Please remove the entry for"
    echo "*** package \`${pkg}' manually."

    exit 0
fi

$RHOME/etc/build-htmlpkglist

