#!/bin/sh
# Set initial variables:
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-hdparm
VERSION=9.28
ARCH=alpha
BUILD=1

rm -rf $PKG
mkdir -p $PKG
( cd $TMP
rm -rf hdparm-$VERSION
tar xf $CWD/hdparm-$VERSION.tar.gz
cd hdparm-$VERSION
chown -R root.root .
make || exit 1
strip hdparm
mkdir -p $PKG/usr/sbin $PKG/sbin
cat hdparm > $PKG/sbin/hdparm
chmod 755 $PKG/sbin/hdparm
chown -R root.bin $PKG/usr/sbin $PKG/sbin
( cd $PKG/usr/sbin
 ln -sf ../../sbin/hdparm .
)
( 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
)
mkdir -p $PKG/usr/man/man8
cat hdparm.8 | gzip -9c > $PKG/usr/man/man8/hdparm.8.gz
mkdir -p $PKG/usr/doc/hdparm-$VERSION
cp -a README.acoustic hdparm.lsm contrib $PKG/usr/doc/hdparm-$VERSION
rm -f $PKG/usr/doc/hdparm-$VERSION/contrib/fix_standby.c
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/hdparm-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/hdparm.build.log
