#!/bin/sh
CWD=`pwd`
TMP=${TMP:-/tmp}
PKG=$TMP/package-rp-pppoe

VERSION=3.6
ARCH=${ARCH:-i486}
BUILD=1

if [ ! -d $TMP ]; then
  mkdir -p $TMP
fi
rm -rf $PKG
mkdir -p $PKG
cd $TMP
rm -rf rp-pppoe-$VERSION
tar xzvf $CWD/rp-pppoe-$VERSION.tar.gz
cd rp-pppoe-$VERSION/src
CFLAGS=-O2 \
./configure --prefix=/usr
make
make install docdir=/usr/doc/rp-pppoe-$VERSION RPM_INSTALL_ROOT=$PKG install
chown -R root.bin $PKG/usr/sbin
( cd $PKG
  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
  find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
)
( cd $PKG/etc/ppp
  for config in firewall-masq firewall-standalone pppoe-server-options pppoe.conf ; do
    mv $config ${config}.new
  done
)
gzip -9 $PKG/usr/man/man?/*.?
mkdir -p $PKG/install
zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
makepkg -l y -c n $TMP/rp-pppoe-$VERSION-$ARCH-$BUILD.tgz