#!/bin/sh
# Set initial variables:
CWD=`pwd`
if [ "$TMP" = "" ]; then
  TMP=/tmp
fi
PKG=$TMP/package-ethtool

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

if [ ! -d $TMP ]; then
  mkdir -p $TMP # location to build the source
fi
rm -rf $PKG
mkdir -p $PKG

cd $TMP
rm -rf ethtool-$VERSION
tar xzf $CWD/ethtool-$VERSION.tar.gz
cd ethtool-$VERSION
chown -R root:root .
./configure --prefix=/usr
make || exit 1
make install DESTDIR=$PKG
strip $PKG/usr/sbin/ethtool
gzip -9 $PKG/usr/man/man8/ethtool.8
mkdir -p $PKG/usr/doc/ethtool-$VERSION
cp -a \
  AUTHORS COPYING ChangeLog NEWS README \
  $PKG/usr/doc/ethtool-$VERSION
chmod 644 $PKG/usr/doc/ethtool-$VERSION/*

# Finish up the package:
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

# Build the package:
cd $PKG
makepkg -l y -c n $TMP/ethtool-$VERSION-$ARCH-$BUILD.tgz