#!/bin/bash

# autofs.SlackBuild
# Heavily based on the original Slackware build script,
# Modified by Stuart Winter <stuart@armedslack.org> for the Slackware porting Project.
# 08-Jul-2004

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

# Paths to skeleton port's source & real Slackware source tree:
export CWD=$SLACKSOURCE/$PKGSERIES/$PKGNAM
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

# Extract source:
tar jxvvf $CWD/$PKGNAM-$VERSION.tar.bz2
cd $PKGNAM-$VERSION
slackhousekeeping

# Apply patches:
zcat $CWD/autofs-$VERSION.diff.gz | patch -p1 --verbose --backup --suffix=.orig -E || failpatch

# Create package framework:
mkdir -pm755 $PKG/usr/{sbin,doc/$PKGNAM-$VERSION,lib/autofs,man/man{5,8}}

# Install docs:
cp -fav COPYING COPYRIGHT NEWS README README.options TODO \
        multiserver_mount.patch samples $PKG/usr/doc/$PKGNAM-$VERSION

# Configure:
./configure \
   --prefix=/usr \
   --build=$ARCH-slackware-linux || failconfig

# Build:
make $NUMJOBS || failmake

# Install:
cd daemon
install -vpm755 automount $PKG/usr/sbin
cd ../modules
install -vpm755 *.so $PKG/usr/lib/autofs

# Install man pages:
cd ../man
install -vpm644 *.5 $PKG/usr/man/man5
install -vpm644 *.8 $PKG/usr/man/man8

# If necessary, start the fakeroot server so we can set file/dir ownerships:
start_fakeroot

# Apply generic Slackware packaging policies:
cd $PKG
slackstripall   # strip all .a archives and all ELFs
slackgzpages -i # compress man & info pages and delete usr/info/dir
slackslack      # chown -R root:root, chmod -R og-w, slackchown, slack644docs
slackdesc       # install slack-desc and doinst.sh
slackmp         # run makepkg -l y -c n

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