#
# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# ident	"@(#)postinstall	1.5	07/05/14 SMI"
#

KEYLOCALE='ja'
LIBFILES='libmle.so.1.4 libc.so.101.9 libc.so.102.9'

PKGCOND=/usr/bin/pkgcond
is_srngz=99

if [ -x $PKGCOND ]; then
     $PKGCOND -v is_sparse_root_nonglobal_zone > /dev/null 2>&1
     is_srngz=$?
fi

test_writable() {
	if [ $is_srngz -ne 99 ]; then
		$PKGCOND is_path_writable $1 && return $?
	else
		/usr/bin/touch $1/.test.$$ > /dev/null 2>&1
		if [ $? !=  0 ]; then
			return 1
		else
			rm -f  $1/.test.$$ > /dev/null 2>&1
			return 0
		fi
	fi
} 

grep "^LANG=$KEYLOCALE" /etc/default/init >/dev/null 2>&1
if [ $? = 0 ]; then
    if [ -d $BASEDIR/usr/4lib ]; then
        test_writable $BASEDIR/usr/4lib > /dev/null 2>&1
        if [ $? = 0 ]; then
	    cd $BASEDIR/usr/4lib

	    rm -f libmle.so.1.* libc.so.101.* libc.so.102.*
	    for file in $LIBFILES
	    do
		ln -s locale/$KEYLOCALE/$file .
	    done
	fi
    fi
fi

exit 0
