#!/bin/bash

# network-scripts.SlackBuild
# Heavily based on the original Slackware build scripts,
# Modified by Stuart Winter <mozes@slackware.com>

# 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

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

mkdir -p $PKG/etc/rc.d
( cd $PKG/etc/rc.d
  for file in rc.inet1.conf rc.inet1 rc.inet2 rc.ip_forward ; do
    install -pm644 -oroot -groot $CWD/scripts/$file ${file}.new
  done 
  chmod 755 rc.inet1.new rc.inet2.new 
  chmod 600 rc.inet1.conf.new )
( cd $PKG/etc
  for file in HOSTNAME host.conf hosts.allow hosts.deny hosts.equiv hosts networks nntpserver protocols resolv.conf ; do
    install -pm644 -oroot -groot $CWD/scripts/$file ${file}.new
  done )
mkdir -p $PKG/sbin
install -pm755 -oroot -groot $CWD/scripts/netconfig $PKG/sbin/netconfig
mkdir -p $PKG/var/log/setup
install -pm755 -oroot -groot $CWD/scripts/setup.netconfig $PKG/var/log/setup

# Add manpages:
mkdir -p $PKG/usr/man/man{5,8}
install -vpm644 $CWD/manpages/rc.inet1.conf.5 $PKG/usr/man/man5/
install -vpm644 $CWD/manpages/rc.inet1.8 $PKG/usr/man/man8/

# 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
