IGNOREPATH=/etc:/home:/var:/dev:/boot:/root:/tmp:/usr/local:/sbin:/mnt:/usr/src
STRIPLIB=y
STRIPBIN=y

VERSION=20030724
PROGNAME="Korn Shell 93 $VERSION"
DESC="\
ksh (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 powerful  \n\
interactive shell, it also offers a robust programming language with   \n\
such features as associative arrays and built in integer math          \n\
operations.  ksh is an excellent choice for system administration      \n\
scripts and for everyday interactive use.                              \n\
                                                                       \n\
The official site for the Korn Shell is http://www.kornshell.com/"

BUILD=1
MAINTAINER="Mark Post <mark.post@eds.com>"
SOURCE=http://www.kornshell.com/
SOURCE1=http://www.research.att.com/sw/download/
PKGNAME=ksh93-$VERSION-s390-$BUILD
TAG=OPT

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

   tar -xvzf lib/package/tgz/INIT.2003-07-24.tgz

   bin/package read
   bin/package make SHELL=/bin/bash
}

install() {
   mkdir -p /package-ksh/bin /package-ksh/usr/lib /package-ksh/usr/doc/
   mkdir -p /package-ksh/usr/man/man1
   mkdir -p /package-ksh/usr/include

   cp arch/linux.s390/bin/ksh /package-ksh/bin/ksh.new

   sed -e "s#\.nr Z 0#\.nr Z 1#g" src/cmd/ksh93/sh.1 > \
          /package-ksh/usr/man/man1/ksh.1

   ( cd /package-ksh/usr/man
     for dir in 1 ; do
       ( cd man$dir
         rm -f *.gz
         gzip -9 *.$dir
       )
     done
   )

   ( cd /package-ksh/bin ; ln -sf ksh rksh )
   ( cd /package-ksh/usr/man/man1 ; ln -sf ksh.1.gz rksh.1.gz )

   mkdir -p /package-ksh/usr/doc/ksh93-$VERSION
   ( cd src/cmd/ksh93
     cp -p COMPATIBILITY DESIGN OBSOLETE README RELEASE* \
        /package-ksh/usr/doc/ksh93-$VERSION
   )
   mkdir -p /package-ksh/usr/doc/ksh93-$VERSION/LICENSE
   # AT&T says I have to include this empty file:
   cp -a README /package-ksh/usr/doc/ksh93-$VERSION/LICENSE
   cp -a lib/package/LICENSES/ast /package-ksh/usr/doc/ksh93-$VERSION/LICENSE/LICENSE.ast

   rmdir /package-ksh/usr/include \
         /package-ksh/usr/lib
}

attributes() {
   chown -R root.bin $PKG/package-ksh/bin
}

special() {
   cd $PKG
   mv package-ksh/* ./
   rmdir package-ksh/

   # Because of the weird name this file has, it causes the automation some problems
   # So, I'm copying it here instead of the install section in to avoid those problems.
   cp -a -- $TMP/ast-base/*LICENSED* usr/doc/ksh93-$VERSION/LICENSE/
   chown root.root usr/doc/ksh93-$VERSION/LICENSE/*LICENSED*
   cd $CTL
   cat $CWD/slack-desc > slack-desc

   cat <<EOF >> 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
if [ -f bin/ksh.old ]; then
  rm -f bin/ksh.old
fi
# 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

   sed -e 's%package-ksh/%%g' doinst.sh > doinst.sh.new
   cat doinst.sh.new > doinst.sh
   rm doinst.sh.new
}

