#!/bin/sh
CWD=`pwd`
TMP=/tmp
PKG=$TMP/package-netpbm
VERSION=10.49.02
ARCH=alpha
BUILD=1

rm -rf $PKG
( cd $TMP
rm -rf netpbm-$VERSION
tar xf $CWD/netpbm-$VERSION.tar.bz2
cd netpbm-$VERSION
chown -R root.root .
find . -perm 777 -exec chmod 755 {} \;
find . -perm 664 -exec chmod 644 {} \;
find . -perm 660 -exec chmod 644 {} \;
zcat $CWD/Makefile.config.gz > Makefile.config
make || exit 1
make package pkgdir=$PKG
( cd $PKG
 mkdir -p usr/lib
 chown -R root.bin bin
 mv bin usr
 mv include usr
 #mv lib usr
 mv link/* usr/lib
 rm -rf link
 # Here we have another dummy who thinks man pages are obsolete.
 # Start by ditching the bogus empty man pages:
 rm -rf man
 # Then add the extensive man pages that existed in the source
 # tarball until the current maintainer decided to remove them:
 # Finally, remove the perl script man replacement that truly *is* useless:
 rm -rf usr/bin/doc.url usr/bin/manweb
 # This stuff is also pretty useless:
 rm -rf misc README VERSION pkginfo config_template
)
mkdir -p $PKG/usr/doc/netpbm-$VERSION 
cp -a README doc/COPYRIGHT.PATENT doc/GPL_LICENSE.txt doc/HISTORY doc/copyright_summary $PKG/usr/doc/netpbm-$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
)
#strip -g $PKG/usr/lib/*.a
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
makepkg -l y -c n $TMP/netpbm-$VERSION-$ARCH-$BUILD.tgz
) 2>&1 | tee $TMP/netpbm.build.log
