#!/bin/sh
# Set initial variables:
CWD=`pwd`
if [ "$TMP" = "" ]; then
TMP=/tmp
fi
PKG=$TMP/package-txtutils
SRC=/devel/manpagesrc
INFO=/devel/info-pages/usr/info
TEX=/devel/texinfo-docs
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
# Explode the package framework:
cd $PKG
tar xzvf $CWD/_txtutils.tar.gz
# Function to handle manpage source:
man2gz () { # $1 is source page name, $2 is target name for preformatted
# output (full path && name) and $3 is the same, but for the
# source.
mkdir -p `dirname $2`
groff -Tascii -mandoc $1 | gzip -9c > $2
if [ ! "$3" = "" ]; then
mkdir -p `dirname $3`
cat $1 > $3
fi
}
echo "+===============+"
echo "| textutils-1.9 |"
echo "+===============+"
cd $TMP
tar xzvf $CWD/textutils-1.9.tar.gz
cd textutils-1.9
/configure --prefix=/usr
make CFLAGS=-O2 LDFLAGS=-s
cd src
cat cat > $PKG/bin/cat
cat cut > $PKG/bin/cut
cat head > $PKG/bin/head
cat cksum > $PKG/usr/bin/cksum
cat comm > $PKG/usr/bin/comm
cat csplit > $PKG/usr/bin/csplit
cat expand > $PKG/usr/bin/expand
cat fold > $PKG/usr/bin/fold
cat join > $PKG/usr/bin/join
cat nl > $PKG/usr/bin/nl
cat od > $PKG/usr/bin/od
cat paste > $PKG/usr/bin/paste
cat pr > $PKG/usr/bin/pr
cat sort > $PKG/usr/bin/sort
cat split > $PKG/usr/bin/split
cat sum > $PKG/usr/bin/sum
cat tac > $PKG/usr/bin/tac
cat tail > $PKG/usr/bin/tail
cat tr > $PKG/usr/bin/tr
cat unexpand > $PKG/usr/bin/unexpand
cat uniq > $PKG/usr/bin/uniq
cat wc > $PKG/usr/bin/wc
cd ../man
man2gz cat.1 $PKG/usr/man/preformat/cat1/cat.1.gz $SRC/usr/man/man1/cat.1
man2gz cksum.1 $PKG/usr/man/preformat/cat1/cksum.1.gz $SRC/usr/man/man1/cksum.1
man2gz comm.1 $PKG/usr/man/preformat/cat1/comm.1.gz $SRC/usr/man/man1/comm.1
man2gz csplit.1 $PKG/usr/man/preformat/cat1/csplit.1.gz $SRC/usr/man/man1/csplit.1
man2gz cut.1 $PKG/usr/man/preformat/cat1/cut.1.gz $SRC/usr/man/man1/cut.1
man2gz expand.1 $PKG/usr/man/preformat/cat1/expand.1.gz $SRC/usr/man/man1/expand.1
man2gz fold.1 $PKG/usr/man/preformat/cat1/fold.1.gz $SRC/usr/man/man1/fold.1
man2gz head.1 $PKG/usr/man/preformat/cat1/head.1.gz $SRC/usr/man/man1/head.1
man2gz join.1 $PKG/usr/man/preformat/cat1/join.1.gz $SRC/usr/man/man1/join.1
man2gz nl.1 $PKG/usr/man/preformat/cat1/nl.1.gz $SRC/usr/man/man1/nl.1
man2gz od.1 $PKG/usr/man/preformat/cat1/od.1.gz $SRC/usr/man/man1/od.1
man2gz paste.1 $PKG/usr/man/preformat/cat1/paste.1.gz $SRC/usr/man/man1/paste.1
man2gz pr.1 $PKG/usr/man/preformat/cat1/pr.1.gz $SRC/usr/man/man1/pr.1
man2gz sort.1 $PKG/usr/man/preformat/cat1/sort.1.gz $SRC/usr/man/man1/sort.1
man2gz split.1 $PKG/usr/man/preformat/cat1/split.1.gz $SRC/usr/man/man1/split.1
man2gz sum.1 $PKG/usr/man/preformat/cat1/sum.1.gz $SRC/usr/man/man1/sum.1
man2gz tac.1 $PKG/usr/man/preformat/cat1/tac.1.gz $SRC/usr/man/man1/tac.1
man2gz tail.1 $PKG/usr/man/preformat/cat1/tail.1.gz $SRC/usr/man/man1/tail.1
man2gz tr.1 $PKG/usr/man/preformat/cat1/tr.1.gz $SRC/usr/man/man1/tr.1
man2gz unexpand.1 $PKG/usr/man/preformat/cat1/unexpand.1.gz $SRC/usr/man/man1/unexpand.1
man2gz uniq.1 $PKG/usr/man/preformat/cat1/uniq.1.gz $SRC/usr/man/man1/uniq.1
man2gz wc.1 $PKG/usr/man/preformat/cat1/wc.1.gz $SRC/usr/man/man1/wc.1
# Build the package:
cd $PKG
tar czvf $TMP/txtutils.tgz .
# Clean up the extra stuff:
if [ "$1" = "--cleanup" ]; then
rm -rf $TMP/textutils-1.9
rm -rf $PKG
fi