#!/bin/sh
# Set initial variables:
CWD=`pwd`
if [ "$TMP" = "" ]; then
  TMP=/tmp
fi
PKG=$TMP/package-tcpip
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
explodepkg $CWD/_tcpip.tar.gz
# This is for the "blue underscore" effect, already patched in.
#( cd $PKG ; zcat $CWD/termcap.diff.gz | patch )
#( cd $PKG ; rm etc/termcap.orig )

# 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 "| nfs-server-2.2beta29 |"
echo "+======================+"
cd $TMP
tar xzvf $CWD/nfs-server-2.2beta29.tar.gz
cd nfs-server-2.2beta29
mkdir -p $PKG/usr/doc/nfs-server-2.2beta29
cp -a README NEWS $PKG/usr/doc/nfs-server-2.2beta29
chmod 644 $PKG/usr/doc/nfs-server-2.2beta29/*
chown root.root $PKG/usr/doc/nfs-server-2.2beta29/*
./BUILD
make
strip rpc.mountd rpc.nfsd showmount
cat rpc.mountd > $PKG/usr/sbin/rpc.mountd
cat rpc.nfsd > $PKG/usr/sbin/rpc.nfsd
cat showmount > $PKG/usr/sbin/showmount
cat exports.man | gzip -9c > $PKG/usr/man/man5/exports.5.gz
for page in mountd.man nfsd.man showmount.man ; do
  cat $page | gzip -9c > $PKG/usr/man/man8/`basename $page .man`.8.gz
done

echo "+==================+"
echo "| tcp_wrappers_7.4 |"
echo "+==================+"
cd $TMP
tar xzvf $CWD/tcp_wrappers_7.4.tar.gz
cd tcp_wrappers_7.4
zcat $CWD/tcp_wrappers_7.4.diff.gz | patch
zcat $CWD/tcp_wrappers_7.4.diff2.gz | patch
make REAL_DAEMON_DIR=/usr/sbin linux
strip tcpd
cat tcpd > $PKG/usr/sbin/tcpd
make clean
make REAL_DAEMON_DIR=/usr/sbin/real-daemon-dir linux
strip tcpd safe_finger tcpdchk tcpdmatch try-from
cat tcpd > $PKG/usr/sbin/real-daemon-dir/tcpd
cat safe_finger > $PKG/usr/sbin/real-daemon-dir/safe_finger
cat tcpdchk > $PKG/usr/sbin/real-daemon-dir/tcpdchk
cat tcpdmatch > $PKG/usr/sbin/real-daemon-dir/tcpdmatch
cat try-from > $PKG/usr/sbin/real-daemon-dir/try-from
cat hosts_access.3 | gzip -9c > $PKG/usr/man/man3/hosts_access.3.gz
cat hosts_access.5 | gzip -9c > $PKG/usr/man/man5/hosts_access.5.gz
cat hosts_options.5 | gzip -9c > $PKG/usr/man/man5/hosts_options.5.gz
cat tcpd.8 | gzip -9c > $PKG/usr/man/man8/tcpd.8.gz
cat tcpdchk.8 | gzip -9c > $PKG/usr/man/man8/tcpdchk.8.gz
cat tcpdmatch.8 | gzip -9c > $PKG/usr/man/man8/tcpdmatch.8.gz

echo "+===============+"
echo "| bootp-DD2.4.3 |"
echo "+===============+"
cd $TMP
tar xzvf $CWD/bootp-DD2.4.3.tar.gz
cd bootp-DD2.4.3
zcat $CWD/bootp-DD2.4.3.diff.gz | patch
make
strip bootpd bootpef bootpgw bootptest
for file in bootpd bootpef bootpgw bootptest ; do
  cat $file > $PKG/usr/sbin/$file
done
gzip -9c bootptab.5 > $PKG/usr/man/man5/bootptab.5.gz
for file in bootpd.8 bootpef.8 bootptest.8 ; do
  gzip -9c $file > $PKG/usr/man/man8/$file.gz
done

echo "+===============+"
echo "| icmpinfo-1.10 |"
echo "+===============+"
cd $TMP
tar xzvf $CWD/icmpinfo-1.10.tar.gz
cd icmpinfo-1.10
zcat $CWD/icmpinfo-1.10.diff.gz | patch
make
strip icmpinfo
cat icmpinfo > $PKG/usr/sbin/icmpinfo
gzip -9c icmpinfo.man > $PKG/usr/man/man1/icmpinfo.1.gz

echo "+===============+"
echo "| pidentd-2.7b3 |"
echo "+===============+"
cd $TMP
tar xzvf $CWD/pidentd-2.7b3.tar.gz
cd pidentd-2.7b3
zcat $CWD/pidentd-2.7b3.diff.gz | patch
mkdir -p $PKG/usr/doc/pidentd-2.7b3
(cd doc ; cp -a * $PKG/usr/doc/pidentd-2.7b3 )
make linux
strip in.identd
cat in.identd > $PKG/usr/sbin/in.identd
cat identd.man | gzip -9c > $PKG/usr/man/man8/in.identd.8.gz

echo "+===================+"
echo "| traceroute-4.4BSD |"
echo "+===================+"
cd $TMP
tar xzvf $CWD/traceroute-4.4BSD.tar.gz
cd traceroute-4.4BSD
zcat $CWD/traceroute-4.4BSD.diff.gz | patch
make
strip traceroute
cat traceroute > $PKG/usr/bin/traceroute
gzip -9c traceroute.8 > $PKG/usr/man/man8/traceroute.8.gz

echo "+=================+"
echo "| net-tools-1.421 |"
echo "+=================+"
cd $TMP
tar xzvf $CWD/net-tools-1.421.tar.gz
cd net-tools
zcat $CWD/net-tools-1.421.diff.gz | patch -p1
mkdir -p $PKG/usr/doc/net-tools-1.421
cp -a README $PKG/usr/doc/net-tools-1.421
chmod 644 $PKG/usr/doc/net-tools-1.421/*
chown root.root $PKG/usr/doc/net-tools-1.421/*
make
strip arp ifconfig rarp route netstat 
cat arp > $PKG/sbin/arp
cat ifconfig > $PKG/sbin/ifconfig
cat rarp > $PKG/sbin/rarp
cat route > $PKG/sbin/route
cat hostname > $PKG/bin/hostname
cat netstat > $PKG/bin/netstat
cd man/en_US.88591
for page in dnsdomainname.1 domainname.1 hostname.1 nisdomainname.1 \
  ypdomainname.1 ; do
  cat $page | gzip -9c > $PKG/usr/man/man1/$page.gz
done
for page in arp.8 ifconfig.8 netstat.8 rarp.8 route.8 ; do
  cat $page | gzip -9c > $PKG/usr/man/man8/$page.gz
done

echo "+=============+"
echo "| ruptime-570 |"
echo "+=============+"
cd $TMP
tar xzvf $CWD/ruptime-570.tar.gz
cd ruptime
make
strip ruptime
cat ruptime > $PKG/usr/bin/ruptime
cat ruptime.1 | gzip -9c > $PKG/usr/man/man1/ruptime.1.gz

echo "+==========+"
echo "| slattach |"
echo "+==========+"
cd $TMP
tar xzvf $CWD/slattach.tar.gz
cd slattach
make
strip slattach
cat slattach > $PKG/usr/sbin/slattach
cat slattach.8 | gzip -9c > $PKG/usr/man/man8/slattach.8.gz

echo "+==================+"
echo "| ytalk-3.0.2-8bit |"
echo "+==================+"
cd $TMP
tar xzvf $CWD/ytalk-3.0.2-8bit.tar.gz
cd ytalk-3.0.2-8bit
zcat $CWD/ytalk-3.0.2-8bit.diff.gz | patch
make
strip ytalk
cat ytalk > $PKG/usr/bin/ytalk
cat ytalk.1 | gzip -9c > $PKG/usr/man/man1/ytalk.1.gz

echo "+=========+"
echo "| netdate |"
echo "+=========+"
cd $TMP
tar xzvf $CWD/netdate.tar.gz
cd netdate
zcat $CWD/netdate.diff.gz | patch
make
strip netdate
cat netdate > $PKG/usr/sbin/netdate
cat netdate.8 | gzip -9c > $PKG/usr/man/man8/netdate.8.gz

echo "+==================+"
echo "| netkit-base-0.10 |"
echo "+==================+"
cd $TMP
tar xzvf $CWD/netkit-base-0.10.tar.gz
cd netkit-base-0.10
configure --prefix=/usr
make
cd inetd
strip inetd
cat inetd > $PKG/usr/sbin/inetd
cat inetd.8 | gzip -9c > $PKG/usr/man/man8/inetd.8.gz
cd ../ping
strip ping
cat ping > $PKG/bin/ping
cat ping.8 | gzip -9c > $PKG/usr/man/man8/ping.8.gz
cd ../rpcgen
strip rpcgen
cat rpcgen > $PKG/usr/bin/rpcgen
cat rpcgen.1 | gzip -9c > $PKG/usr/man/man1/rpcgen.1.gz
cd ../rpcinfo
strip rpcinfo
cat rpcinfo > $PKG/usr/sbin/rpcinfo
cat rpcinfo.8 | gzip -9c > $PKG/usr/man/man8/rpcinfo.8.gz

echo "+==================+"
echo "| biff+comsat-0.10 |"
echo "+==================+"
cd $TMP
tar xzvf $CWD/biff+comsat-0.10.tar.gz
cd biff+comsat-0.10
configure --prefix=/usr
make
cd biff
strip biff
cat biff > $PKG/usr/bin/biff
cat biff.1 | gzip -9c > $PKG/usr/man/man1/biff.1.gz
cd ../comsat
strip comsat
cat comsat > $PKG/usr/sbin/in.comsat
cat comsat.8 | gzip -9c > $PKG/usr/man/man8/in.comsat.8.gz

echo "+=================+"
echo "| bsd-finger-0.10 |"
echo "+=================+"
cd $TMP
tar xzvf $CWD/bsd-finger-0.10.tar.gz
cd bsd-finger-0.10
configure --prefix=/usr
make
cd finger
strip finger
cat finger > $PKG/usr/bin/finger
cat finger.1 | gzip -9c > $PKG/usr/man/man1/finger.1.gz
cd ../fingerd
strip fingerd
cat fingerd > $PKG/usr/sbin/in.fingerd
cat fingerd.8 | gzip -9c > $PKG/usr/man/man8/in.fingerd.8.gz

echo "+========================+"
echo "| netkit-bootparamd-0.10 |"
echo "+========================+"
cd $TMP
tar xzvf $CWD/netkit-bootparamd-0.10.tar.gz
cd netkit-bootparamd-0.10
configure --prefix=/usr
make
cd rpc.bootparamd
cat bootparamd > $PKG/usr/sbin/rpc.bootparamd
cat callbootd > $PKG/usr/bin/callbootd
gzip -9c bootparamd.8 > $PKG/usr/man/man8/rpc.bootparamd.8.gz

echo "+=================+"
echo "| netkit-ftp-0.10 |"
echo "+=================+"
cd $TMP
tar xzvf $CWD/netkit-ftp-0.10.tar.gz
cd netkit-ftp-0.10
configure --prefix=/usr
make
cd ftp
strip ftp
cat ftp > $PKG/bin/ftp
cat ftp.1 | gzip -9c > $PKG/usr/man/man1/ftp.1.gz

echo "+===================+"
echo "| netkit-ntalk-0.10 |"
echo "+===================+"
cd $TMP
tar xzvf $CWD/netkit-ntalk-0.10.tar.gz
cd netkit-ntalk-0.10
zcat $CWD/netkit-ntalk-0.10.diff.gz | patch
configure --prefix=/usr
make
cd talk
strip talk
cat talk > $PKG/usr/bin/talk
cat talk.1 | gzip -9c > $PKG/usr/man/man1/talk.1.gz
cd ../talkd
strip talkd
cat talkd > $PKG/usr/sbin/in.talkd
cat talkd.8 | gzip -9c > $PKG/usr/man/man8/in.talkd.8.gz

echo "+====================+"
echo "| netkit-routed-0.10 |"
echo "+====================+"
cd $TMP
tar xzvf $CWD/netkit-routed-0.10.tar.gz
cd netkit-routed-0.10
configure --prefix=/usr
make
cd routed
strip routed
cat routed > $PKG/usr/sbin/routed
cat routed.8 | gzip -9c > $PKG/usr/man/man8/routed.8.gz

echo "+=================+"
echo "| netkit-rsh-0.10 |"
echo "+=================+"
cd $TMP
tar xzvf $CWD/netkit-rsh-0.10.tar.gz
cd netkit-rsh-0.10
zcat $CWD/netkit-rsh-0.10.diff.gz | patch
configure --prefix=/usr
make
cd rsh
strip rsh
cat rsh > $PKG/usr/bin/rsh
cat rsh.1 | gzip -9c > $PKG/usr/man/man1/rsh.1.gz
cd ../rshd
strip rshd
cat rshd > $PKG/usr/sbin/in.rshd
cat rshd.8 | gzip -9c > $PKG/usr/man/man8/in.rshd.8.gz
cd ../rcp
cat rcp > $PKG/usr/bin/rcp
cat rcp.1 | gzip -9c > $PKG/usr/man/man1/rcp.1.gz
cd ../rexecd
strip rexecd
cat rexecd > $PKG/usr/sbin/in.rexecd
cat rexecd.8 | gzip -9c > $PKG/usr/man/man8/rexecd.8.gz
cd ../rlogin
strip rlogin
cat rlogin > $PKG/usr/bin/rlogin
cat rlogin.1 | gzip -9c > $PKG/usr/man/man1/rlogin.1.gz
cd ../rlogind
strip rlogind
cat rlogind > $PKG/usr/sbin/in.rlogind
cat rlogind.8 | gzip -9c > $PKG/usr/man/man8/in.rlogind.8.gz

echo "+====================+"
echo "| netkit-rusers-0.10 |"
echo "+====================+"
cd $TMP
tar xzvf $CWD/netkit-rusers-0.10.tar.gz
cd netkit-rusers-0.10
configure --prefix=/usr
make
cd rpc.rusersd
strip rusersd
cat rusersd > $PKG/usr/sbin/rpc.rusersd
cat rpc.rusersd.8 | gzip -9c > $PKG/usr/man/man8/rpc.rusersd.8.gz
cd ../rusers
strip rusers
cat rusers > $PKG/usr/bin/rusers
cat rusers.1 | gzip -9c > $PKG/usr/man/man1/rusers.1.gz
cd ../rup
strip rup
cat rup > $PKG/usr/bin/rup
cat rup.1 | gzip -9c > $PKG/usr/man/man1/rup.1.gz

echo "+===================+"
echo "| netkit-rwall-0.10 |"
echo "+===================+"
cd $TMP
tar xzvf $CWD/netkit-rwall-0.10.tar.gz
cd netkit-rwall-0.10
configure --prefix=/usr
make
cd rpc.rwalld
strip rwalld
cat rwalld > $PKG/usr/sbin/rpc.rwalld
cat rpc.rwalld.8 | gzip -9c > $PKG/usr/man/man8/rpc.rwalld.8.gz
cd ../rwall
strip rwall
cat rwall > $PKG/usr/bin/rwall
cat rwall.1 | gzip -9c > $PKG/usr/man/man1/rwall.1.gz

echo "+==================+"
echo "| netkit-rwho-0.10 |"
echo "+==================+"
cd $TMP
tar xzvf $CWD/netkit-rwho-0.10.tar.gz
cd netkit-rwho-0.10
configure --prefix=/usr
make
cd rwho
strip rwho
cat rwho > $PKG/usr/bin/rwho
cat rwho.1 | gzip -9c > $PKG/usr/man/man1/rwho.1.gz
cd ../rwhod
strip rwhod
cat rwhod > $PKG/usr/sbin/rwhod
cat rwhod.8 | gzip -9c > $PKG/usr/man/man8/rwhod.8.gz

echo "+====================+"
echo "| netkit-telnet-0.10 |"
echo "+====================+"
cd $TMP
tar xzvf $CWD/netkit-telnet-0.10.tar.gz
cd netkit-telnet-0.10
zcat $CWD/netkit-telnet-0.10.diff.gz | patch
configure --prefix=/usr
make
cd telnet
strip telnet
cat telnet > $PKG/bin/telnet
cat telnet.1 | gzip -9c > $PKG/usr/man/man1/telnet.1.gz
cd ../telnetd
strip telnetd
cat telnetd > $PKG/usr/sbin/in.telnetd
cat telnetd.8 | gzip -9c > $PKG/usr/man/man8/in.telnetd.8.gz

echo "+==================+"
echo "| netkit-tftp-0.10 |"
echo "+==================+"
cd $TMP
tar xzvf $CWD/netkit-tftp-0.10.tar.gz
cd netkit-tftp-0.10
configure --prefix=/usr
make
cd tftp
strip tftp
cat tftp > $PKG/usr/bin/tftp
cat tftp.1 | gzip -9c > $PKG/usr/man/man1/tftp.1.gz
cd ../tftpd
strip tftpd
cat tftpd > $PKG/usr/sbin/in.tftpd
cat tftpd.8 | gzip -9c > $PKG/usr/man/man8/in.tftpd.8.gz

echo "+===================+"
echo "| netkit-timed-0.10 |"
echo "+===================+"
cd $TMP
tar xzvf $CWD/netkit-timed-0.10.tar.gz
cd netkit-timed-0.10
configure --prefix=/usr
make
cd timed/timed
strip timed
cat timed > $PKG/usr/sbin/in.timed
cat timed.8 | gzip -9c > $PKG/usr/man/man8/timed.8.gz
cd ../timedc
strip timedc
cat timedc > $PKG/usr/sbin/timedc
cat timedc.8 | gzip -9c > $PKG/usr/man/man8/timedc.8.gz

echo "+===============+"
echo "| netwrite-0.10 |"
echo "+===============+"
cd $TMP
tar xzvf $CWD/netwrite-0.10.tar.gz
cd netwrite-0.10
configure --prefix=/usr
make
cd write
cat write > $PKG/usr/bin/write
cat write.1 | gzip -9c > $PKG/usr/man/man1/write.1.gz
cat writed > $PKG/usr/sbin/in.writed
cat writed.8 | gzip -9c > $PKG/usr/man/man8/in.writed.8.gz

echo "+=================+"
echo "| sliplogin-2.1.0 |"
echo "+=================+"
cd $TMP
tar xzvf $CWD/sliplogin-2.1.0.tar.gz
cd sliplogin-2.1.0
zcat $CWD/sliplogin-2.1.0.diff.gz | patch
make
strip sliplogin
cat sliplogin > $PKG/usr/sbin/sliplogin
cat sliplogin.8 | gzip -9c > $PKG/usr/man/man8/sliplogin.8.gz
mkdir -p $PKG/etc/slip
cp -a slip.login slip.hosts slip.route slip.passwd $PKG/etc/slip

echo "+===============+"
echo "| portmap_5beta |"
echo "+===============+"
cd $TMP
tar xzvf $CWD/portmap_5beta.tar.gz
cd portmap_5beta
zcat $CWD/portmap_5beta.diff.gz | patch
zcat $CWD/portmap_5beta.diff2.gz | patch
mkdir $PKG/usr/doc/portmap_5beta
cp -a BLURB CHANGES README $PKG/usr/doc/portmap_5beta
chmod 644 $PKG/usr/doc/portmap_5beta/*
chown root.root $PKG/usr/doc/portmap_5beta/*
make
strip portmap pmap_dump pmap_set
cat portmap > $PKG/usr/sbin/rpc.portmap
cat pmap_dump > $PKG/usr/sbin/pmap_dump
cat pmap_set > $PKG/usr/sbin/pmap_set
cat portmap.8 | gzip -9c > $PKG/usr/man/man8/portmap.8.gz

echo "+=============+"
echo "| fwhois-1.00 |"
echo "+=============+"
cd $TMP
tar xzvf $CWD/fwhois-1.00.tar.gz
cd fwhois-1.00
make
cat fwhois > $PKG/usr/bin/fwhois

echo "+======================+"
echo "| ipfwadm-2.3.0.tar.gz |"
echo "+======================+"
cd $TMP
tar xzvf $CWD/ipfwadm-2.3.0.tar.gz
cd ipfwadm-2.3.0
mkdir -p $PKG/usr/doc/ipfwadm-2.3.0
cp -a COPYING ChangeLog README ipfwadm.lsm $PKG/usr/doc/ipfwadm-2.3.0
chmod 644 $PKG/usr/doc/ipfwadm-2.3.0/*
chown root.root $PKG/usr/doc/ipfwadm-2.3.0/*
make
strip ipfwadm
cat ipfwadm > $PKG/sbin/ipfwadm
cat ipfwadm.8 | gzip -9c > $PKG/usr/man/man8/ipfwadm.8.gz
cat ipfw.4 | gzip -9c > $PKG/usr/man/man4/ipfw.4.gz

echo "+=================+"
echo "| fetchmail-4.1.1 |"
echo "+=================+"
cd $TMP
tar xzvf $CWD/fetchmail-4.1.1.tar.gz
cd fetchmail-4.1.1
configure --prefix=/usr
make CFLAGS=-O2 LDFLAGS=-s
strip fetchmail
cat fetchmail > $PKG/usr/bin/fetchmail
cat fetchmail.man | gzip -9c > $PKG/usr/man/man1/fetchmail.1.gz
mkdir $PKG/usr/doc/fetchmail
cp -a README NEWS NOTES FAQ $PKG/usr/doc/fetchmail

echo "+=============+"
echo "| wu-ftpd-2.4 |"
echo "+=============+"
cd $TMP
tar xzvf $CWD/wu-ftpd-2.4.tar.gz
cd wu-ftpd-2.4
zcat $CWD/wu-ftpd-2.4-fixed.patch.gz | patch -p1
zcat $CWD/wu-ftpd-2.4-fixed.patch2.gz | patch -p1
( cd src ; zcat $CWD/wu-ftpd-2.4-security.diff.gz | patch )
zcat $CWD/wu-ftpd-2.4-md5shadow.diff.gz | patch
build lnx
cd bin
strip *
cat ckconfig > $PKG/usr/sbin/ckconfig
cat ftpcount > $PKG/usr/bin/ftpcount
cat ftpd > $PKG/usr/sbin/wu.ftpd
cat ftpshut > $PKG/usr/bin/ftpshut
cat ftpwho > $PKG/usr/bin/ftpwho
cd ../doc
for page in ftpcount.1 ftpwho.1 ; do
  cat $page | gzip -9c > $PKG/usr/man/man1/$page.gz
done
cat realpath.3 | gzip -9c > $PKG/usr/man/man3/realpath.3.gz
for page in ftpaccess.5 xferlog.5 ftpconversions.5 ftphosts.5 ; do
  cat $page | gzip -9c > $PKG/usr/man/man5/$page.gz
done
for page in ftpd.8 ftpshut.8 ; do
  cat $page | gzip -9c > $PKG/usr/man/man8/$page.gz
done

echo "+================+"
echo "| yp-clients-2.2 |"
echo "+================+"
cd $TMP
tar xzvf $CWD/ypclients-2.2-970318.tar.gz
cd ypclients-2.2-970318
mkdir -p $PKG/usr/doc/yp-clients-2.2
cp -a yp-clients.lsm README yp.conf.example $PKG/usr/doc/yp-clients-2.2
( cd $PKG/usr/doc/yp-clients-2.2 ; chmod 644 * )
( cd $PKG/usr/doc/yp-clients-2.2 ; chown root.root * )
make
( cd ypbind ; make )
strip ypbind/ypbind ypcat/ypcat ypmatch/ypmatch \
  yppasswd/yppasswd yppoll/yppoll ypset/ypset ypwhich/ypwhich
cat ypbind/ypbind > $PKG/usr/sbin/ypbind
cat ypcat/ypcat > $PKG/usr/bin/ypcat
cat ypmatch/ypmatch > $PKG/usr/bin/ypmatch
cat yppasswd/yppasswd > $PKG/usr/bin/yppasswd
cat yppoll/yppoll > $PKG/usr/bin/yppoll
cat ypset/ypset > $PKG/usr/bin/ypset
cat ypwhich/ypwhich > $PKG/usr/bin/ypwhich

echo "+==============+"
echo "| ypserv-1.1.5 |"
echo "+==============+"
cd $TMP
tar xzvf $CWD/ypserv-1.1.5.tar.gz
cd ypserv
mkdir -p $PKG/usr/doc/ypserv-1.1.5
cp -a COPYING ChangeLog README README.secure TODO $PKG/usr/doc/ypserv-1.1.5
( cd $PKG/usr/doc/ypserv-1.1.5 ; chmod 644 * )
( cd $PKG/usr/doc/ypserv-1.1.5 ; chown root.root * )
configure
make
strip makedbm mknetid revnetgroup ypxfr ypserv rpc.ypxfrd yppush
for file in makedbm mknetid revnetgroup ypinit ypxfr ypxfr_1perday \
ypxfr_1perhour ypxfr_2perday ; do
 cat $file > $PKG/usr/libexec/yp/$file
done
for file in ypserv rpc.ypxfrd yppush ; do
 cat $file > $PKG/usr/sbin/$file
done
cat ypMakefile > $PKG/var/yp/Makefile
for file in netgroup.5 ypserv.conf.5 ; do
 gzip -9c $file > $PKG/usr/man/man5/$file.gz
done
for file in ypserv.8 rpc.ypxfrd.8 ypxfrd.8 yppush.8 ypxfr.8 \
ypinit.8 revnetgroup.8 mknetid.8 ; do
 gzip -9c $file > $PKG/usr/man/man8/$file.gz
done

echo "+==============+"
echo "| telnetsnoopd |"
echo "+==============+"
cd $TMP
mkdir telnetsnoopd
cd telnetsnoopd
tar xzvf $CWD/telnetsnoopd-fixed.tar.gz
make
strip telnetsnoopd/telnetd
cat telnetsnoopd/telnetd > $PKG/usr/sbin/in.telnetsnoopd

echo "+================+"
echo "| ttysnoop-0.12c |"
echo "+================+"
cd $TMP
tar xzvf $CWD/ttysnoop-0.12c.tar.gz
cd ttysnoop-0.12c
zcat $CWD/ttysnoop-0.12c.diff.gz | patch
mkdir -p $PKG/usr/doc/ttysnoop-0.12c
cp -a README* $PKG/usr/doc/ttysnoop-0.12c
chmod 644 $PKG/usr/doc/ttysnoop-0.12c/*
chown root.root $PKG/usr/doc/ttysnoop-0.12c/*
make
strip ttysnoop ttysnoops
cat ttysnoops > $PKG/bin/ttysnoops
cat ttysnoop > $PKG/usr/sbin/ttysnoop
cat ttysnoop.8 | gzip -9c > $PKG/usr/man/man8/ttysnoop.8.gz

echo "+===============+"
echo "| linux_pcnfsd2 |"
echo "+===============+"
cd $TMP
tar xzvf $CWD/linux_pcnfsd2.tar.gz
cd linux_pcnfsd2
zcat $CWD/linux_pcnfsd2.diff.gz | patch
make -f Makefile.linux
cd linux
strip clnt.pcnfsd rpc.pcnfsd
cat clnt.pcnfsd > $PKG/usr/sbin/clnt.pcnfsd
cat rpc.pcnfsd > $PKG/usr/sbin/rpc.pcnfsd

echo "+========+"
echo "| bwnfsd |"
echo "+========+"
cd $TMP
tar xzvf $CWD/bwnfsd.tar.gz
cd bwnfsd
zcat $CWD/bwnfsd.diff.gz | patch
make linux
strip bwnfsd
cat bwnfsd > $PKG/usr/sbin/rpc.bwnfsd

echo "+===============+"
echo "| nntp-1.5.12.1 |"
echo "+===============+"
cd $TMP
tar xzvf $CWD/nntp-1.5.12.1.tar.gz
cd nntp-1.5.12.1
zcat $CWD/nntp-1.5.12.1.diff.gz | patch
cp conf.h.dist conf.h
make server
cd server
strip nntpd
cat nntpd > $PKG/usr/sbin/in.nntpd
cat ../doc/nntpd.8c | gzip -9c > $PKG/usr/man/man8/in.nntpd.8.gz

echo "+============+"
echo "| mini-inews |"
echo "+============+"
cd $TMP
tar xzvf $CWD/mini-inews.tar.gz
cd inews
make
strip inews
cat inews > $PKG/usr/bin/inews-nntp

echo "+==============+"
echo "| pop3d-1.005h |"
echo "+==============+"
cd $TMP
tar xzvf $CWD/pop3d-1.005h.tar.gz
cd pop3d-1.005h
zcat $CWD/pop3d-1.005h.diff.gz | patch
make
strip in.pop3d
cat in.pop3d > $PKG/usr/sbin/in.pop3d
gzip -9c pop3d.1 > $PKG/usr/man/man8/in.pop3d.8.gz

echo "+=============+"
echo "| ncftp-2.4.2 |"
echo "+=============+"
cd $TMP
tar xzvf $CWD/ncftp-2.4.2.tar.gz
cd ncftp-2.4.2
zcat $CWD/ncftp-2.4.2.diff.gz | patch
configure --prefix=/usr --enable-readline
make CFLAGS=-O2 LDFLAGS=-s
strip ncftp
cat ncftp > $PKG/usr/bin/ncftp
cat ncftp.1 | gzip -9c > $PKG/usr/man/man1/ncftp.1.gz

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

# Clean up the extra stuff:
if [ "$1" = "--cleanup" ]; then
 for dir in biff+comsat-0.10 bootp-DD2.4.3 bsd-finger-0.10 bwnfsd \
  fetchmail-3.9.8 fwhois-1.00 icmpinfo-1.10 inews ipfwadm-2.3.0 \
  linux_pcnfsd2 ncftp-2.4.2 net-tools netdate netkit-base-0.10 \
  netkit-bootparamd-0.10 netkit-ntalk-0.10 netkit-routed-0.10 \
  netkit-rsh-0.10 netkit-rusers-0.10 netkit-rwall-0.10 netkit-rwho-0.10 \
  netkit-telnet-0.10 netkit-tftp-0.10 netkit-timed-0.10 netwrite-0.10 \
  nfs-server-2.2beta29 nntp-1.5.12.1 package-tcpip pidentd-2.7b3 \
  pop3d-1.005h portmap_5beta ruptime slattach sliplogin-2.1.0 \
  tcp_wrappers_7.4 telnetsnoopd traceroute-4.4BSD ttysnoop-0.12c \
  wu-ftpd-2.4 ypclients-2.2-970318 ypserv ytalk-3.0.2-8bit ; do
  rm -rf $TMP/$dir
 done
 rm -rf $PKG
fi
