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/doc/ \
            /package-ksh/usr/man/man1

   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 | gzip -9 > \
          /package-ksh/usr/man/man1/ksh.1.gz

#  ( cd /package-ksh/usr/man
#    for dir in 1 3; 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
   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
}

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

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

   # This is being put here instead of in the install section since the file name causes
   # some serious problems with the protopkg script.
   # AT&T says I have to include this empty file:
   cp -a $TMP/ast-base/'./------------ NOTICE -- LICENSED SOFTWARE -- SEE README FOR DETAILS ------------' \
      usr/doc/ksh93-$VERSION/LICENSE/
   chown root.root usr/doc/ksh93-$VERSION/LICENSE/*

   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
}

