#! /bin/sh -e

prio=@java_priority@

update-alternatives --quiet \
    --install /usr/bin/java java /usr/bin/gij-@BV@ $prio \
    @GFDL@--slave /usr/share/man/man1/java.1.gz java.1.gz /usr/share/man/man1/gij-@BV@.1.gz

update-alternatives --quiet \
    --install /usr/bin/rmiregistry rmiregistry /usr/bin/grmiregistry-@BV@ $prio \
    --slave /usr/share/man/man1/rmiregistry.1.gz rmiregistry.1.gz /usr/share/man/man1/grmiregistry-@BV@.1.gz

update-alternatives --quiet \
    --install /usr/bin/keytool keytool /usr/bin/gkeytool-@BV@ $prio \
    --slave /usr/share/man/man1/keytool.1.gz keytool.1.gz /usr/share/man/man1/gkeytool-@BV@.1.gz

update-alternatives --quiet \
    --install /usr/bin/orbd orbd /usr/bin/gorbd-@BV@ $prio \
    --slave /usr/share/man/man1/orbd.1.gz orbd.1.gz /usr/share/man/man1/gorbd-@BV@.1.gz

update-alternatives --quiet \
    --install /usr/bin/rmid rmid /usr/bin/grmid-@BV@ $prio \
    --slave /usr/share/man/man1/rmid.1.gz rmid.1.gz /usr/share/man/man1/grmid-@BV@.1.gz

case "$1" in
configure)
    if [ ! -f /var/lib/gcj-@BV@/classmap.db ]; then
	uname=$(uname -m)
	mkdir -p /var/lib/gcj-@BV@
	if gcj-dbtool-@BV@ -n /var/lib/gcj-@BV@/classmap.db; then
	    case "$uname" in arm*|m68k|parisc*)
	        echo >&2 "gcj-dbtool succeeded unexpectedly"
	    esac
	else
	    case "$uname" in
	    arm*|m68k|parisc*)
	        echo >&2 "ERROR: gcj-dbtool did fail; known problem on $uname";;
	    *)
		exit 2
	    esac
	    touch /var/lib/gcj-@BV@/classmap.db
	fi
    fi
esac

#DEBHELPER#

exit 0
