#!/bin/sh
#
# ident "@(#)postinstall.src	1.2    05/03/23 SMI"
#
# Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#

# This script is to be run on linux only. It creates
# /opt/SUNWut/lib/xkb by creating a shadow directory
# of /usr/X11R6/lib/X11/xkb (ie., symlinks). It then
# overlays sun-specific xkb files and recreates the
# .dir files.

PATH=/bin:/usr/bin:/sbin:/usr/sbin
XKBDIR=/usr/share/X11/xkb
if [ -z "$BASEDIR" ]; then BASEDIR="/opt"; fi

cd $XKBDIR

DIRS=`find . -type d`
FILES=`find . -type f`
LINKS=`find . -type l`

cd $BASEDIR/SUNWut/lib
mkdir xkb
cd xkb

for d in $DIRS
do
	if [ "$d" != "." ] ;
    then
        mkdir $d
    fi
done

for f in $FILES
do
    ln -s $XKBDIR/$f $f
done

for l in $LINKS
do
    ln -s $XKBDIR/$l $l
done

SUNSTUFF=`find . -name 'sun*'`
for s in $SUNSTUFF
do
    rm -rf $s
done

cd ../xkbfiles
tar -cf - . | (cd ../xkb ; tar -xf -)

cd ../xkb

rm geometry.dir keycodes.dir keymap.dir symbols.dir

cd geometry ; /usr/bin/xkbcomp -lfhlpR -o geometry.dir '*' ; mv geometry.dir ..
cd ../keycodes ; /usr/bin/xkbcomp -lfhlpR -o keycodes.dir '*' ; mv keycodes.dir ..
cd ../keymap ; /usr/bin/xkbcomp -lfhlpR -o keymap.dir '*' ; mv keymap.dir ..
cd ../symbols ; /usr/bin/xkbcomp -lfhlpR -o symbols.dir '*' ; mv symbols.dir ..

exit 0
