#!/bin/bash

# sendmail-cf.SlackBuild
# by Stuart Winter <stuart@armedslack.org> for the Slackware porting Project.
# Almost entirely based on the original Slackware build script by Patrick Volkerding.
# 19-Jun-2004

# Record toolchain & other info for the build log:
slackbuildinfo

# Paths to skeleton port's source & real Slackware source tree:
export CWD=$SLACKSOURCE/$PKGSERIES/sendmail
export PORTCWD=$PWD

# Temporary build locations:
export TMPBUILD=$TMP/build-$PKGNAM
export PKG=$TMP/package-$PKGNAM
mkpkgdirs # Delete & re-create temporary directories then cd into $TMPBUILD

# Path to sendmail source (built by sendmail.SlackBuild)
SMS=$TMP/build-sendmail

( cd $SMS/sendmail-$VERSION ; find . -name "*~" -print -exec rm {} \; )
cd $PKG
mkdir -p usr/share/sendmail/cf
cd usr/share/sendmail/cf
cp -a $SMS/sendmail-$VERSION/cf/README .
cp -a $TMP/package-sendmail/usr/share/sendmail/README.linux .
for dir in cf domain feature hack m4 mailer ostype sh siteconfig ; do
  cp -a $SMS/sendmail-$VERSION/cf/$dir .
done

# Replace the sendmail Build script with a simple (working) one:
cp -a $PKG/usr/share/sendmail/cf/cf/Build $PKG/usr/share/sendmail/cf/cf/Build.orig
zcat $CWD/Build.gz > $PKG/usr/share/sendmail/cf/cf/Build
chown -R root:root *

# Install package description:
mkdir -p $PKG/install
install -m644 $CWD/slack-desc.sendmail-cf $PKG/install/slack-desc

# Slackware policies:
cd $PKG
slackgzpages -i # compress man & info pages and delete usr/info/dir
slack644docs    # ensure /usr/doc has the correct ownerships & permissions
slackmp         # run makepkg -l y -c n

# Perform any final checks on the package:
cd $PKG
slackhlinks     # search for any hard links
