#!/bin/bash

# etc.SlackBuild
# by Stuart Winter <stuart@armedslack.org> for the Slackware porting Project.
# Heavily based on the original Slackware build script.
# 30-May-2004

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

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

# Temporary build locations:
export TMPBUILD=$TMP/build-$PACKAGE
export PKG=$TMP/package-$PACKAGE
mkpkgdirs # Delete and re-create temporary directories

# Start fakeroot server:
start_fakeroot

# Explode the package framework:
cd $PKG
explodepkg $CWD/_etc.tar.gz
mkdir -p $PKG/usr/etc # there is a printcap symlink in here

cp -a $CWD/termcap-BSD.gz etc/termcap-BSD.gz
gzip -d --force etc/termcap-BSD.gz
chown root:root etc/termcap-BSD
chmod 644 etc/termcap-BSD
zcat $CWD/nsswitch.conf.gz > $PKG/etc/nsswitch.conf.new

# Apply some of the generic Slackware packaging policies:
slackgzpages -i # compress man & info pages and delete usr/info/dir
slackdesc       # install slack-desc and doinst.sh

# Build the package:
if [ $PORTARCH = arm ]; then
   slackmp # run makepkg
  else
   makepkg -l y -c n $PKGSTORE/$PKGSERIES/$PACKAGE-$VERSION-$ARCH-$BUILD.tgz
fi

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