VERSION=20010101
BUILD=1
ARCH=i386

PKGNAME=ksh93-$VERSION-$ARCH-$BUILD

PROGNAME="Korn Shell 93"

DESC="\
AT&T Korn Shell 93                                                   \n\
                                                                     \n\
The KornShell language and interactive shell were designed by        \n\
David G. Korn at AT&T Bell Laboratories.  Besides offering a very    \n\
powerful interactive shell, it also offers a very robust programming \n\
language with such features as associative arrays and built in       \n\
integer math operations.  ksh is an excellent choice for system      \n\
administration scripts and for everyday interactive use."

MAINTAINER="Logan Johnson <logan@slackware.com>"
SOURCE=http://www.kornshell.com

IGNOREPATH=/home:/var:/dev:/root:/tmp:/usr/local:/mnt:/cdrom
STRIPLIB=y
STRIPBIN=y

TAG=OPT

compile() {
   mkdir -p ast-base/lib/package/tgz
   cp $CWD/*.tgz ast-base/lib/package/tgz
   cd ast-base/

   tar -xvzf lib/package/tgz/INIT.2001-01-01.0000.tgz
   bin/package read
   bin/package make SHELL=/bin/bash1
}

install() {
   cp arch/linux.$ARCH/bin/ksh /bin/ksh.new
   cp arch/linux.$ARCH/lib/libshell.so.1.1 /usr/lib
   cp arch/linux.$ARCH/lib/libshell.a /usr/lib
   cp arch/linux.$ARCH/lib/libast.so.5.4 /usr/lib
   cp arch/linux.$ARCH/lib/libast.a /usr/lib

   sed -e "s#\.nr Z 0#\.nr Z 1#g" src/cmd/ksh93/sh.1 > \
          /usr/man/man1/ksh.1
   cp src/cmd/ksh93/shell.3 /usr/man/man3
   cp src/cmd/ksh93/nval.3 /usr/man/man3
   cp src/cmd/ksh93/include/shell.h /usr/include

   ( cd /bin ; ln -sf ksh rksh )
   ( cd /usr/lib ; ln -sf libshell.so.1.1 libshell.so )
   ( cd /usr/lib rm -rf libast.so ; ln -sf libast.so.5.4 libast.so )
   ( cd /usr/man/man1 ; ln -sf ksh.1.gz rksh.1.gz )

   mkdir -p /usr/doc/ksh93
   ( cd src/cmd/ksh93
     cp COMPATIBILITY DESIGN OBSOLETE OPTIONS README RELEASE* \
        /usr/doc/ksh93
   )
}

attributes() {
   chmod 755 usr/lib/libshell.so.1.1
}

special() {
   cat <<EOF >> $CTL/doinst.sh
# Backup the old copy if we find one, move the new one in place
if [ -f bin/ksh ]; then
   mv bin/ksh bin/ksh.old
fi
mv bin/ksh.new bin/ksh
# Add entries to /etc/shells if we need them
if [ ! -r etc/shells ] ; then
   touch etc/shells
   chmod 644 etc/shells
fi
 
if fgrep "/bin/ksh" etc/shells 1> /dev/null 2> /dev/null ; then
   GOOD=y
else
   echo "/bin/ksh" >> etc/shells
fi
EOF
}