#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-cpio
VERSION=2.11
ARCH=alpha
BUILD=1
TARGET=$ARCH-alphaslack-linux

rm -rf $PKG
mkdir -p $PKG
( cd $TMP
rm -rf cpio-$VERSION
tar xf $CWD/cpio-$VERSION.tar.bz2
cd cpio-$VERSION
./configure \
 --prefix=/usr \
 --infodir=/usr/info \
 --mandir=/usr/man \
 --build=$TARGET
make || exit 1
make DESTDIR=$PKG install
chown -R root:bin $PKG/usr/bin
mkdir -p $PKG/usr/info
gzip -9 $PKG/usr/man/man?/*.?
gzip -9 $PKG/usr/info/*.info
rm -rf $PKG/usr/info/dir
mkdir -p $PKG/usr/doc/cpio-$VERSION
cp -a COPYING ChangeLog INSTALL NEWS README $PKG/usr/doc/cpio-$VERSION
chmod 644 $PKG/usr/doc/cpio-$VERSION/*
chown -R root.root $PKG/usr/doc/cpio-$VERSION
( 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/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/cpio-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/cpio.build.log
