#!/bin/bash

# tcpip.SlackBuild
# by Stuart Winter <stuart@armedslack.org> for the Slackware porting Project.
# Heavily based on the original Slackware build script.
# 20-Jun-2004

# Record toolchain & other info for the build log:
slackbuildinfo

# Paths to skeleton port's source & real Slackware source tree:
export CWD=$SLACKSOURCE/$PKGSERIES/$PACKAGE
export PORTCWD=$PWD

# Temporary build locations:
export TMPBUILD=$TMP/build-$PACKAGE
export PKG=$TMP/package-$PACKAGE
mkpkgdirs # Delete & re-create temporary directories then cd into $TMPBUILD

# Determine the CFLAGS for the known architectures:
case $PORTARCH in
   arm)     export SLKCFLAGS="-O2 -march=armv3 -mtune=xscale" ;;
   powerpc) export SLKCFLAGS="-O2" ;;
   sparc)   export SLKCFLAGS="-O2" ;;
   alpha)   export SLKCFLAGS="-O2" ;;
   x86_64)  export SLKCFLAGS="-O2" ;;
   i486)    export SLKCFLAGS="-O2" ;;
   mips)    export SLKCFLAGS="-O2" ;;
   *)       export SLKCFLAGS="-O2" ;;
esac

# When I'd build this inside scratchbox I'd have to start fakeroot about now.
# However, I think that fakeroot contributed to some of the very strange problems
# I was having (I *know* it fails under numerous configure scripts), so we'll always
# build this particular package natively.
# start_fakeroot

# Explode the package framework:
( cd $PKG
  explodepkg $CWD/_tcpip.tar.gz )

########## tcp_wrappers ##########################################

cd $TMPBUILD
tar zxvvf $CWD/tcp_wrappers_7.6.tar.gz
cd tcp_wrappers-7.6
sh extract-and-patch.sh
cd tcp_wrappers_7.6
slackhousekeeping
make REAL_DAEMON_DIR=/usr/sbin linux || failmake
cat libwrap.a > $PKG/usr/lib/libwrap.a
cat tcpd.h > $PKG/usr/include/tcpd.h
cat safe_finger > $PKG/usr/sbin/safe_finger
cat tcpd > $PKG/usr/sbin/tcpd
cat tcpdchk > $PKG/usr/sbin/tcpdchk
cat tcpdmatch > $PKG/usr/sbin/tcpdmatch
cat try-from > $PKG/usr/sbin/try-from
install -m644 hosts_access.3 $PKG/usr/man/man3
install -m644 hosts_{options,access}.5 $PKG/usr/man/man5
install -m644 tcpd{chk,match}.8 $PKG/usr/man/man8
install -m644 tcpd.8 $PKG/usr/man/man8

# Install docs:
mkdir -p $PKG/usr/doc/tcp_wrappers_7.6
cp -a BLURB CHANGES DISCLAIMER README README.NIS \
      $PKG/usr/doc/tcp_wrappers_7.6

# And if we want to build the rest of this stuff without having this package
# pre-installed (see the chicken-egg problem?):
install -m644 tcpd.h /usr/include
install -m644 libwrap.a /usr/lib

########## icmpinfo ##########################################

cd $TMPBUILD
tar zxvvf $CWD/icmpinfo-1.11.tar.gz
cd icmpinfo-1.11
slackhousekeeping
zcat $CWD/icmpinfo-1.11.diff.gz | patch -p1 --backup || failpatch
zcat $CWD/icmpinfo-1.11.diff2.gz | patch -p1 --backup || failpatch
make || failmake
install -m755 icmpinfo $PKG/usr/sbin
gzip -9c icmpinfo.man > $PKG/usr/man/man1/icmpinfo.1.gz
mkdir -p $PKG/usr/doc/icmpinfo-1.11
cp -a CHANGES CHECKSUMS.asc README TODO \
      $PKG/usr/doc/icmpinfo-1.11


########## net-tools ##########################################

cd $TMPBUILD
tar jxvvf $CWD/net-tools-1.60.tar.bz2
cd net-tools-1.60
slackhousekeeping
zcat $CWD/net-tools_1.60-17.diff.gz | patch -p1 --backup || failpatch
zcat $CWD/net-tools.diff.gz | patch -p1 --backup || failpatch
# Ignore the error from the gcc3.4 patch because it contains mii-tool patches too:
#zcat $PORTCWD/../../a/util-linux/patches/net-tools-1.60-gcc34-2.patch.gz | patch -p1 
#zcat $PORTCWD/../../a/util-linux/patches/net-tools-1.60-kernel-headers-1.patch.gz | patch -p1 || failpatch
mkdir -p $PKG/usr/doc/net-tools-1.60
cp -a README README.ipv6 $PKG/usr/doc/net-tools-1.60
HAVE_IP_TOOLS=1 HAVE_MII=1 make || failmake
HAVE_IP_TOOLS=1 HAVE_MII=1 make hostname || failmake
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 mii-tool > $PKG/sbin/mii-tool
cat nameif > $PKG/sbin/nameif
cat netstat > $PKG/bin/netstat
cat plipconfig > $PKG/sbin/plipconfig
cat slattach > $PKG/usr/sbin/slattach
cat ipmaddr > $PKG/sbin/ipmaddr
cat iptunnel > $PKG/sbin/iptunnel
cd man/en_US
install -m644 dnsdomainname.1 domainname.1 hostname.1 nisdomainname.1 ypdomainname.1 \
              $PKG/usr/man/man1

# ypdomainname.1 is a man page link to hostname.1
# So when I first did this script I thought "ooh let's symlink it and save a file"
# and now I spent 5 mins tracking down why this was this way -- pkgdiff revealed the
# difference.
# So let's just save 5 mins in the future and add it to the install command above :) 
#( cd $PKG/usr/man/man1 
#  rm -f ypdomainname.1
#  ln -fs hostname.1 ypdomainname.1 )
install -m644 ethers.5 $PKG/usr/man/man5
install -m644 arp.8 ifconfig.8 mii-tool.8 nameif.8 netstat.8 rarp.8 route.8 slattach.8 plipconfig.8 \
              $PKG/usr/man/man8

########## netdate ##########################################

cd $TMPBUILD
tar zxvvf $CWD/netdate.tar.gz
cd netdate
slackhousekeeping
zcat $CWD/netdate.diff.gz | patch -p1 --backup  || failpatch
zcat $CWD/netdate.diff2.gz | patch -p1 --backup || failpatch
make || failmake
cat netdate > $PKG/usr/sbin/netdate
install -m644 netdate.8 $PKG/usr/man/man8

########## netkit-base ##########################################

cd $TMPBUILD
tar zxvvf $CWD/netkit-base-0.17.tar.gz
cd netkit-base-0.17
slackhousekeeping
# This is a patch to fix ping times > 1s.
zcat $CWD/netkit-base.ping.diff.gz | patch -p1 --verbose || failpatch
./configure --prefix=/usr || failconfig
make || failmake
cd ping
cat ping > $PKG/bin/ping
install -m644 ping.8 $PKG/usr/man/man8
cd ..
mkdir -p $PKG/usr/doc/netkit-base-0.17
cp -a README $PKG/usr/doc/netkit-base-0.17

########## biff+comsat ##########################################

cd $TMPBUILD
tar zxvvf $CWD/biff+comsat-0.17.tar.gz
cd biff+comsat-0.17
slackhousekeeping
zcat $CWD/biff+comsat-0.17.diff.gz | patch -p1 --verbose    || failpatch
zcat $CWD/biff+comsat.offset.diff.gz | patch -p1 --verbose  || failpatch
zcat $CWD/biff+comsat.badutmp.diff.gz | patch -p1 --verbose || failpatch
./configure --prefix=/usr || failconfig
make || failmake
cd biff
cat biff > $PKG/usr/bin/biff
install -m644 biff.1 $PKG/usr/man/man1
cd ../comsat
cat comsat > $PKG/usr/sbin/in.comsat
install -m644 comsat.8 $PKG/usr/man/man8/in.comsat.8
cd ..
mkdir -p $PKG/usr/doc/biff+comsat-0.17
cp -a README $PKG/usr/doc/biff+comsat-0.17

########## bsd-finger ##########################################

cd $TMPBUILD
tar zxvvf $CWD/bsd-finger-0.17.tar.gz
cd bsd-finger-0.17
slackhousekeeping
zcat $CWD/bsd-finger-0.17.diff.gz | patch -p1 || failpatch
./configure --prefix=/usr || failconfig
make || failmake
cd finger
cat finger > $PKG/usr/bin/finger
install -m644 finger.1 $PKG/usr/man/man1
cd ../fingerd
cat fingerd > $PKG/usr/sbin/in.fingerd
install -m644 fingerd.8 $PKG/usr/man/man8/in.fingerd.8
cd ..
mkdir -p $PKG/usr/doc/bsd-finger-0.17
cp -a README $PKG/usr/doc/bsd-finger-0.17

########## netkit-bootparamd ##########################################

cd $TMPBUILD
tar zxvvf $CWD/netkit-bootparamd-0.17.tar.gz
cd netkit-bootparamd-0.17
slackhousekeeping
./configure --prefix=/usr || failconfig
make || failmake
cd rpc.bootparamd
cat bootparamd > $PKG/usr/sbin/rpc.bootparamd
cat callbootd > $PKG/usr/bin/callbootd
install -m644 bootparamd.8 $PKG/usr/man/man8/rpc.bootparamd.8
mkdir -p $PKG/usr/doc/netkit-bootparamd-0.17
cp -a README $PKG/usr/doc/netkit-bootparamd-0.17

##########  netkit-ftp ##########################################

cd $TMPBUILD
tar zxvvf $CWD/netkit-ftp-0.17.tar.gz
cd netkit-ftp-0.17
slackhousekeeping
./configure --prefix=/usr || failconfig
make || failmake
cd ftp
cat ftp > $PKG/bin/ftp
install -m644 ftp.1 $PKG/usr/man/man1
install -m644 netrc.5 $PKG/usr/man/man5
cd ..
mkdir -p $PKG/usr/doc/netkit-ftp-0.17
cp -a README $PKG/usr/doc/netkit-ftp-0.17

##########  netkit-ntalk ##########################################

cd $TMPBUILD
tar zxvvf $CWD/netkit-ntalk-0.17.tar.gz
cd netkit-ntalk-0.17
slackhousekeeping
zcat $CWD/netkit-ntalk-0.17.diff.gz | patch -p1 || failpatch
zcat $CWD/ntalk-0.17-slackware-alt-talkd.patch.gz | patch -p1 --verbose || failpatch
./configure --prefix=/usr || failconfig
make || failmake
cd talk
cat talk > $PKG/usr/bin/talk
install -m644 talk.1 $PKG/usr/man/man1
cd ../talkd
cat talkd > $PKG/usr/sbin/in.talkd
install -m644 talkd.8 $PKG/usr/man/man8/in.talkd.8
cd ..
mkdir -p $PKG/usr/doc/netkit-ntalk-0.17
cp -a README $PKG/usr/doc/netkit-ntalk-0.17

##########  netkit-ntalk-0.11 ##########################################

# Include old version of 'talk', which works better with
# 8-bit character sets:
cd $TMPBUILD
tar zxvvf $CWD/netkit-ntalk-0.11.tar.gz
cd netkit-ntalk-0.11
slackhousekeeping
zcat $CWD/netkit-ntalk-0.11.diff.gz | patch -p0 --verbose    || failpatch
zcat $PORTCWD/sources/ntalk-0.11.time.patch.gz | patch -p0 --verbose || failpatch
./configure --prefix=/usr || failconfig
make || failmake
cd talk
cat talk > $PKG/usr/bin/talk-0.11

##########  netkit-routed ##########################################

cd $TMPBUILD
tar zxvvf $CWD/netkit-routed-0.17.tar.gz
cd netkit-routed-0.17
slackhousekeeping
zcat $CWD/routed.18.candidate.final.patch.gz | patch -p1 --verbose -E || failpatch
zcat $CWD/netkit-routed-0.17.diff.gz | patch -p1 --verbose -E  || failpatch
./configure --prefix=/usr || failconfig
make || failmake
cat routed/routed > $PKG/usr/sbin/routed
cat routed/routed.8 | gzip -9c > $PKG/usr/man/man8/routed.8.gz
cat ripquery/ripquery > $PKG/usr/sbin/ripquery
cat ripquery/ripquery.8 | gzip -9c > $PKG/usr/man/man8/ripquery.8.gz
mkdir -p $PKG/usr/doc/netkit-routed-0.17
cp -a README $PKG/usr/doc/netkit-routed-0.17

##########  netkit-rsh ##########################################

cd $TMPBUILD
tar zxvvf $CWD/netkit-rsh-0.17.tar.gz
cd netkit-rsh-0.17
slackhousekeeping
./configure --prefix=/usr || failconfig
make || failmake
cd rsh
strip rsh
cat rsh > $PKG/usr/bin/rsh
install -m644 rsh.1 $PKG/usr/man/man1
cd ../rshd
cat rshd > $PKG/usr/sbin/in.rshd
install -m644 rshd.8 $PKG/usr/man/man8/in.rshd.8
cd ../rcp
cat rcp > $PKG/usr/bin/rcp
install -m644 rcp.1 $PKG/usr/man/man1
cd ../rexecd
cat rexecd > $PKG/usr/sbin/in.rexecd
install -m644 rexecd.8 $PKG/usr/man/man8
cd ../rlogin
cat rlogin > $PKG/usr/bin/rlogin
install -m644 rlogin.1 $PKG/usr/man/man1
cd ../rlogind
cat rlogind > $PKG/usr/sbin/in.rlogind
install -m644 rlogind.8 $PKG/usr/man/man8/in.rlogind.8
cd ..
mkdir -p $PKG/usr/doc/netkit-rsh-0.17
cp -a README $PKG/usr/doc/netkit-rsh-0.17

##########  netkit-rusers ##########################################

cd $TMPBUILD
tar zxvvf $CWD/netkit-rusers-0.17.tar.gz
cd netkit-rusers-0.17
slackhousekeeping
zcat $CWD/netkit-rusers-0.17.diff.gz | patch -p1 --verbose || failpatch
./configure --prefix=/usr || failconfig
make || failmake
cd rpc.rusersd
cat rusersd > $PKG/usr/sbin/rpc.rusersd
install -m644 rpc.rusersd.8 $PKG/usr/man/man8
cd ../rusers
cat rusers > $PKG/usr/bin/rusers
install -m644 rusers.1 $PKG/usr/man/man1
cd ../rup
cat rup > $PKG/usr/bin/rup
install -m644 rup.1 $PKG/usr/man/man1
cd ..
mkdir -p $PKG/usr/doc/netkit-rusers-0.17
cp -a README $PKG/usr/doc/netkit-rusers-0.17

##########  netkit-rwall ##########################################

cd $TMPBUILD
tar zxvvf $CWD/netkit-rwall-0.17.tar.gz
cd netkit-rwall-0.17
slackhousekeeping
./configure --prefix=/usr || failconfig
make || failmake
cd rpc.rwalld
cat rwalld > $PKG/usr/sbin/rpc.rwalld
install -m644 rpc.rwalld.8 $PKG/usr/man/man8
cd ../rwall
cat rwall > $PKG/usr/bin/rwall
install -m644 rwall.1 $PKG/usr/man/man1
cd ..
mkdir -p $PKG/usr/doc/netkit-rwall-0.17
cp -a README $PKG/usr/doc/netkit-rwall-0.17

##########  netkit-rwho ##############################################
# Note from sw: This rwhod does not work for me at the ISP I work
#               for.  Originally I used Debian's rwhod but it doesn't
#               run as root so this would cause some confusion. Instead
#               we'll just roll with this one
#
cd $TMPBUILD
tar zxvvf $CWD/netkit-rwho-0.17.tar.gz
cd netkit-rwho-0.17
slackhousekeeping
zcat $CWD/netkit-rwho-0.17.diff.gz | patch -p1 --verbose || failpatch
./configure --prefix=/usr || failconfig
make || failmake
cd rwho
cat rwho > $PKG/usr/bin/rwho
install -m644 rwho.1 $PKG/usr/man/man1
cd ../rwhod
cat rwhod > $PKG/usr/sbin/rwhod
install -m644 rwhod.8 $PKG/usr/man/man8
cd ../ruptime
cat ruptime > $PKG/usr/bin/ruptime
install -m644 ruptime.1 $PKG/usr/man/man1
cd ..
mkdir -p $PKG/usr/doc/netkit-rwho-0.17
cp -a README $PKG/usr/doc/netkit-rwho-0.17

##########  netkit-telnet ##########################################

# Extract source:
cd $TMPBUILD
tar zxvvf $CWD/netkit-telnet-0.17.tar.gz
cd netkit-telnet-*
slackhousekeeping

# Apply patches:
zcat $CWD/netkit-telnet-0.17.diff.gz | patch -p1 --verbose || failpatch
zcat $CWD/netkit-telnet-0.17-ayt.patch.gz | patch -p1 --verbose || failpatch

# Configure:
./configure \
   --prefix=/usr || failconfig

# Build netkit's telnetd:
( cd telnetd
  make || failmake

  # Install telnetd into the package:
  cat telnetd > $PKG/usr/sbin/in.telnetd
  install -m644 telnetd.8 $PKG/usr/man/man8/in.telnetd.8 )

# Install netkit-telnet's docs:
mkdir -p $PKG/usr/doc/netkit-telnet-0.17
cp -a README \
      $PKG/usr/doc/netkit-telnet-0.17

# Move the netkit telnet version out of the way because the directory
# name conflicts with the OpenBSD telnet client that we actually use
# in Slackware:
mv telnet telnet-netkit

# OpenBSD telnet client:
# This version is superior to the netkit version:
#
# Extract source:
tar zxvvf $CWD/telnet-OpenBSD-20020321.tar.gz

# Apply patches:
zcat $CWD/telnet-OpenBSD-20020321.diff.gz   | patch -p1 --verbose || failpatch
zcat $CWD/telnet-OpenBSD-014_telnet.diff.gz | patch -p1 --verbose || failpatch

# Build:
cd telnet
make || failmake

# Install OpenBSD telnet client & man page into package:
install -m755 telnet $PKG/bin/
install -m644 telnet.1 $PKG/usr/man/man1 

##########  tftp-hpa ##########################################

cd $TMPBUILD
tar jxvvf $CWD/tftp-hpa-0.42.tar.bz2
cd tftp-hpa-*
slackhousekeeping
./configure --prefix=/usr || failconfig
make || failmake
cd tftp
cat tftp > $PKG/usr/bin/tftp
install -m644 tftp.1 $PKG/usr/man/man1
cd ../tftpd
cat tftpd > $PKG/usr/sbin/in.tftpd
install -m644 tftpd.8 $PKG/usr/man/man8/in.tftpd.8
cd ..
mkdir -p $PKG/usr/doc/tftp-hpa-0.42
cp -a CHANGES INSTALL INSTALL.tftp README README.security \
      $PKG/usr/doc/tftp-hpa-0.42

##########  netkit-timed ##########################################

cd $TMPBUILD
tar zxvvf $CWD/netkit-timed-0.17.tar.gz
cd netkit-timed-0.17
slackhousekeeping
zcat $CWD/netkit-timed-0.17.diff.gz | patch -p1 --verbose -E || failpatch
./configure --prefix=/usr || failconfig
make || failmake
cd timed/timed
cat timed > $PKG/usr/sbin/in.timed
install -m644 timed.8 $PKG/usr/man/man8
cd ../timedc
cat timedc > $PKG/usr/sbin/timedc
install -m644 timedc.8 $PKG/usr/man/man8
cd ../..
mkdir -p $PKG/usr/doc/netkit-timed-0.17
cp -a README $PKG/usr/doc/netkit-timed-0.17

##########  netwrite ##########################################

cd $TMPBUILD
tar zxvvf $CWD/netwrite-0.17.tar.gz
cd netwrite-0.17
slackhousekeeping
zcat $CWD/netwrite-0.17.diff.gz | patch -p1 --verbose || failpatch
./configure --prefix=/usr || failconfig
make || failmake
cd writed
cat writed > $PKG/usr/sbin/in.writed
install -m644 writed.8 $PKG/usr/man/man8/in.writed.8
cd ..
mkdir -p $PKG/usr/doc/netwrite-0.17
cp -a README $PKG/usr/doc/netwrite-0.17

##########  ipmask ##########################################

mkdir $TMPBUILD/ipmask
cd $TMPBUILD/ipmask
cc -s -O2 -o ipmask $CWD/ipmask.c
install -m755 ipmask $PKG/bin

##########  mini-inews ##########################################

cd $TMPBUILD
tar zxvvf $CWD/mini-inews.tar.gz
cd inews
slackhousekeeping
zcat $CWD/mini-inews.diff.gz | patch -p1 -E --verbose || failpatch
make || failmake
cat inews > $PKG/usr/bin/inews-nntp

##########  iputils ##########################################

# ARMedslack is using the Debian source and diff here.
# I'm not sure why but I suspect the original does not build on 
# ARM without patches.

cd $TMPBUILD
#tar xjvf $CWD/iputils-ss021109-try.tar.bz2
tar zxvvf $PORTCWD/sources/iputils_*orig*.tar.gz
cd iputils*
zcat $PORTCWD/sources/iputils_*diff*.gz | patch -p1 --verbose || failpatch
slackhousekeeping
#make || failmake
make symlink
make IPV4_TARGETS=tracepath ping arping clockdiff rarpd rdisc \
     IPV6_TARGETS=tracepath6 traceroute6 ping6 || failmake
make || failmake
cat arping > $PKG/sbin/arping
cat clockdiff > $PKG/usr/sbin/clockdiff
# Replace old ping...
cat ping > $PKG/bin/ping
cat ping6 > $PKG/bin/ping6
cat rarpd > $PKG/usr/sbin/rarpd
cat rdisc > $PKG/usr/sbin/rdisc
cat tracepath > $PKG/usr/bin/tracepath
cat tracepath6 > $PKG/usr/bin/tracepath6
cat traceroute6 > $PKG/usr/bin/traceroute6
( cd doc
  install -m644 arping.8 clockdiff.8 ping.8 rarpd.8 rdisc.8 tracepath.8 traceroute6.8 \
                $PKG/usr/man/man8
  cd $PKG/usr/man/man8
  ln -sf ping.8 ping6.8
  ln -sf tracepath.8 tracepath6.8 )
#mkdir -p $PKG/usr/doc/iputils-ss021109-try
mkdir -p $PKG/usr/doc/iputils-20020927
cp -a RELNOTES \
      $PKG/usr/doc/iputils-20020927
#      $PKG/usr/doc/iputils-ss021109-try

##########  ethtool ##########################################

cd $TMPBUILD
tar zxvvf $CWD/ethtool-4.tar.gz
cd ethtool-*
slackhousekeeping
./configure --prefix=/usr || failconfig
make || failmake
make install DESTDIR=$PKG || failinstall
mkdir -pm755 $PKG/usr/doc/ethtool-4
cp -a AUTHORS COPYING ChangeLog NEWS README \
      $PKG/usr/doc/ethtool-4

##########  bridge-utils #####################################

# http://bridge.sourceforge.net

cd $TMPBUILD
tar zxvvf $CWD/bridge-utils-1.0.6.tar.gz
cd bridge-utils-*
slackhousekeeping
./configure \
   --prefix=/usr || failconfig

# Build:
make || failmake

# Install into package:
make install DESTDIR=$PKG
mv $PKG/usr/sbin/brctl $PKG/sbin/brctl
chown root:bin $PKG/sbin/brctl
strip -g $PKG/usr/lib/libbridge.a

# Install docs:
mkdir -p $PKG/usr/doc/bridge-utils-1.0.6
cp -a AUTHORS COPYING README THANKS TODO doc \
      $PKG/usr/doc/bridge-utils-1.0.6
( cd $PKG/usr/doc/bridge-utils-1.0.6/doc
  rm -f Makefile Makefile.in RPM-GPG-KEY brctl.8 )


##########  vlan #####################################

cd $TMPBUILD
tar jxvvf $CWD/vlan.1.9.tar.bz2
cd vlan
slackhousekeeping
chmod 644 *

# Build:
make vconfig || failmake

# Install into package:
strip --strip-unneeded vconfig
install -oroot -gbin -m755 vconfig $PKG/sbin/
install -m644 vconfig.8 $PKG/usr/man/man8/

# Copy docs:
mkdir $PKG/usr/doc/vlan-1.9
cp -a README howto.html vlan.html \
      $PKG/usr/doc/vlan-1.9

###############################################################

# Set some of the generic Slackware packaging policies:
cd $PKG
slackstripall   # strip all .a archives and all ELFs
slackgzpages -i # compress man & info pages and delete usr/info/dir
slack644docs    # Ensure docs have the correct permissions
slackdesc       # install slack-desc and doinst.sh

# Build the package:
if [ $PORTARCH = arm ]; then
   slackmp # run makepkg
 else
   makepkg -l y -c n $PKGSTORE/$PKGSERIES/$PACKAGE-$VERSION-$ARCH-$BUILD.tgz
fi

# Perform any final checks on the package:
cd $PKG
slackhlinks     # search for any hard links
