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

if [ ! -d $TMP ]; then
  mkdir -p $TMP # location to build the source
fi
if [ ! -d $PKG ]; then
  mkdir -p $PKG # place for the package to be built
fi

echo "+===============+"
echo "| manpages      |"
echo "+===============+"

rm -rf $PKG/usr/man
tar xvfz $CWD/man-pages-1.38.tar.gz
cd man-pages-1.38
mkdir -p $PKG/usr/man
cp -aP * $PKG/usr/man

# Slackware likes to gzip all the man pages
( cd $PKG/usr/man
  gzip man[1-9]/*.[1-9]
)

# Build the package:
cd $PKG
tar czvf $TMP/manpages.tgz .

# Warn of zero-length files:
for file in `find . -type f -print` ; do
 if [ "`filesize $file`" = "0" ]; then
  echo "WARNING: zero length file $file"
 fi
 if [ "`filesize $file`" = "20" ]; then
  echo "WARNING: possible empty gzipped file $file"
 fi
done

