#!/bin/sh
# Heavily based on the Slackware 12.1 SlackBuild
# http://ftp.pluto.it/pub/pluto/ildp/man/
# Packager Loris - slacky@slacky.it

CWD=`pwd`
TMP=${TMP:-/tmp/tgz}
PKG=$TMP/package-man-pages-it
NAME=man-pages-it
VERSION=2.65
EXTRA=extra-0.5.0
ARCH=${ARCH:-noarch}
BUILD=2sl

if [ ! -d $TMP ]; then
 mkdir -p $TMP
fi
if [ ! -d $PKG ]; then
 mkdir -p $PKG
fi

cd $TMP
tar xzvf $CWD/$NAME-$VERSION.tar.gz
cd $NAME-$VERSION
chown -R root:root .
mkdir -p $PKG/usr/doc/$NAME-$VERSION
cp -a CHANGELOG HOWTOHELP POSIX-COPYRIGHT readme $PKG/usr/doc/$NAME-$VERSION
rm CHANGELOG HOWTOHELP POSIX-COPYRIGHT readme* Makefile
mkdir -p $PKG/usr/man/it
cp -a * $PKG/usr/man/it
rm -rf $PKG/usr/man/it/man*p
cd $TMP
tar xzvf $CWD/$NAME-$EXTRA.tar.gz
cd $NAME-$EXTRA
chown -R root:root .
rm changelog readme* Makefile
mkdir -p $PKG/usr/man/it
cp -a * $PKG/usr/man/it
find $PKG/usr/man/it -type f -exec gzip -9 {} \;
chmod 644 $PKG/usr/man/it/man*/*.gz
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/slack-desc > $PKG/usr/doc/$NAME-$VERSION/slack-desc
cat $CWD/$NAME.SlackBuild > $PKG/usr/doc/$NAME-$VERSION/$NAME.SlackBuild
cd $PKG
makepkg -l y -c n $CWD/$NAME-$VERSION-$ARCH-$BUILD.tgz

if [ "$1" = "--cleanup" ]; then
 rm -rf $TMP
fi
