#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-ispell
VERSION=3.2.06
ARCH=alpha
BUILD=2

( cd $TMP
tar xzf $CWD/ispell-$VERSION.tar.gz
cd ispell-$VERSION
zcat $CWD/ispell.diff.gz | patch -p1 --verbose
zcat $CWD/Makefile.diff.gz | patch -p1 --verbose
make
mkdir -p $PKG/usr/bin $PKG/usr/lib/ispell $PKG/usr/man/man1 $PKG/usr/man/man4
cat buildhash > $PKG/usr/bin/buildhash
cat findaffix > $PKG/usr/bin/findaffix
cat icombine > $PKG/usr/bin/icombine
cat ijoin > $PKG/usr/bin/ijoin
cat ispell > $PKG/usr/bin/ispell
cat munchlist > $PKG/usr/bin/munchlist
cat tryaffix > $PKG/usr/bin/tryaffix
cat zapdups > $PKG/usr/bin/zapdups
cat deformatters/deformat-c > $PKG/usr/bin/deformat-c
cat deformatters/deformat-sh > $PKG/usr/bin/deformat-sh
strip --strip-unneeded $PKG/usr/bin/*
chmod 755 $PKG/usr/bin/*
cat languages/american/americanmed.hash > $PKG/usr/lib/ispell/americanmed.hash
cat languages/english/english.aff > $PKG/usr/lib/ispell/english.aff
cat languages/english/english.4l |gzip -9c  > $PKG/usr/man/man4/english.4.gz
cat ispell.1 |gzip -9c > $PKG/usr/man/man1/ispell.1.gz
cat ispell.4 |gzip -9c > $PKG/usr/man/man4/ispell.4.gz
echo '.so man1/ispell.1' | gzip -9c > $PKG/usr/man/man1/buildhash.1.gz
echo '.so man1/ispell.1' | gzip -9c > $PKG/usr/man/man1/findaffix.1.gz
echo '.so man1/ispell.1' | gzip -9c > $PKG/usr/man/man1/munchlist.1.gz
echo '.so man1/ispell.1' | gzip -9c > $PKG/usr/man/man1/tryaffix.1.gz
( cd $PKG
  cd usr/lib/ispell
  ln -sf americanmed.hash american.hash
  ln -sf americanmed.hash english.hash
)
mkdir -p $PKG/usr/doc/ispell-$VERSION
cp -a Contributors Magiclines README WISHES $PKG/usr/doc/ispell-$VERSION
chown -R root.root $PKG/usr/doc/ispell-$VERSION
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/ispell-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/ispell.build.log
