#!/bin/sh
# Set initial variables:
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-procmail
VERSION=3.22
ARCH=alpha
BUILD=1

mkdir -p $PKG
cd $PKG
explodepkg $CWD/_procmail.tar.gz
( cd $TMP
tar xzf $CWD/procmail-$VERSION.tar.gz
cd procmail-$VERSION
chown -R root.root .
find . -perm 777 -exec chmod 755 {} \;
find . -perm 664 -exec chmod 644 {} \;
zcat $CWD/diff.gz |patch -p0
make
cd src
strip formail lockfile procmail
cat formail > $PKG/usr/bin/formail
cat lockfile > $PKG/usr/bin/lockfile
cat mailstat > $PKG/usr/bin/mailstat
cat procmail > $PKG/usr/bin/procmail
cd ../man
for file in formail.1 lockfile.1 procmail.1 ; do
  gzip -9c $file > $PKG/usr/man/man1/$file.gz
done
for file in procmailex.5 procmailrc.5 procmailsc.5 ; do
  gzip -9c $file > $PKG/usr/man/man5/$file.gz
done
mkdir -p $PKG/usr/doc/procmail-$VERSION
cd ..
cp -a Artistic COPYING FAQ FEATURES HISTORY INSTALL KNOWN_BUGS README examples $PKG/usr/doc/procmail-$VERSION
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/procmail-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/procmail.build.log
