#!/bin/sh
#
# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# pragma ident "@(#)postinstall	1.3	04/06/03 Sun Microsystems"
#
# Backported from Tiger (1.5) postinstall	1.1 03/11/25
#
# The JRE package installs links outside of its BASEDIR from "utilities"
# in /usr/bin, up to the /usr/java link which (in turn) points to the
# default jvm. This script installs those links which are independent
# of basedir.
#

#
# Useful shell variables which include packaging command names to handle
# the "relocatable root" senario.
#
if [ "$PKG_INSTALL_ROOT" != "" ]; then
    INSTALLF="installf -R $PKG_INSTALL_ROOT"
else
    INSTALLF="installf"
fi
BIN_PATH="${BASEDIR}/bin"

#
# Shell routine to install the /usr/bin links. Note that we want to register
# these as part of each package which uses them, so that they won't be
# removed until the last Java is removed from the system (or the last Java
# which has that particular component.
#
InstallLinks() {
    BIN_FILES="javac javah jarsigner jar javap appletviewer \
	       native2ascii rmic serialver jdb javadoc extcheck \
	       idlj HtmlConverter"
    $INSTALLF -c none $PKGINST $BIN_PATH d 0755 root bin
    for file in $BIN_FILES; do
	$INSTALLF -c none $PKGINST "$BIN_PATH/${file}=../java/bin/${file}" s
    done
}

#
# Main Processing
#
if [ -d ${BIN_PATH} ]; then
    InstallLinks
fi
$INSTALLF -f $PKGINST
exit 0
