#!/bin/sh

# Setting PKGUTIL_OPTS to something like:
# '-t http://mirror.opencsw.org/opencsw/testing'
# will allow you to run this against the testing/ repository.

PATH=/opt/csw/bin:$PATH
export PATH

#this is the stack of packages that need to be removed if found
REM="CSWasciidoc CSWxmlto CSWdocbookxsldoc CSWdocbookdsssl CSWopenjade CSWdocbookxsl CSWdocbookdtds CSWxmlcommon CSWsgmlcommon CSWpylibxslt CSWlibxsltdevel CSWlibxslt CSWpylibxml2 CSWlibxml2devel CSWlibxml2"
# build up a list of packages to reinstall.  reinstallation will
# happen in reverse order of removal to ensure dependencies are
# handled in the same order we take them out
INST=

if [ ! -f /opt/csw/bin/pkgutil ]; then
    echo "This script requires pkgutil."
    exit 1
fi

for p in $REM; do
    if [ -d /var/sadm/pkg/$p ]; then
	$DEBUG pkgrm $p;
	INST="$p $INST"
    fi
done

for p in $INST; do
    pkgutil $PKGUTIL_OPTS -U -i $p
done
