#!/bin/bash

ORIGPATH=$PWD
PACKAGE=xinetd
VERSION=${1}

cd ${SLACKTRACKSCRATCHDIR}
tar zxf ${ORIGPATH}/source/xinetd*gz
cd xinetd*

CFLAGS="-O2 -march=i686 -Wall" \
   ./configure \
     --prefix=/usr \
     --with-libwrap \
     && make \
     && make install || { echo "Failed to build" ; exit 1; }

# Remove the inetd.conf > xinetd.conf converter programs cos they're
# not much use really since this xinetd package is meant to be installed
# on to a inetd-less Slackware 8.1 box (as you can not opt to not install inetd
# in the installer)
( cd ${SLACKTRACKFAKEROOT}
  rm -f usr/sbin/itox usr/sbin/xconv.pl usr/man/man8/itox* usr/man/man8/xconv* )

# Copy the rc.xinetd file into the build path
install -m700 ${ORIGPATH}/rc.xinetd /etc/rc.d/
chmod 700 /etc/rc.d

# Copy the docs into our 'local' build dir
mkdir -p /usr/doc/${PACKAGE}-${VERSION}
cp -a AUDIT INSTALL README TODO CHANGELOG COPYRIGHT \
      /usr/doc/${PACKAGE}-${VERSION}/

# Copy our default xinetd.conf into the package base dir
# For UKShells, the auto shell-build scripts will automatically
# build a UKShells-eque xinetd.conf, so this file won't be required
install -m600 ${ORIGPATH}/xinetd.conf-distrib /etc/xinetd.conf.new

mkdir /install
install -m644 ${ORIGPATH}/slack-desc /install/
install -m644 ${ORIGPATH}/doinst.sh  /install/
