#!/bin/sh

source /home/build/armedslack-current/source/armslack-utils/armedenvs.sh
PACKAGE=rdist
VERSION=6.1.5
BUILD=1
PKGSERIES=n # the name of the Slackware 'disk set' or 'series' to which this pkg belongs

slackglibc
mkpkgdirs

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

tar xzvf $CWD/source/*orig*
cd rdist-*
zcat $CWD/source/*diff* | patch -p1 # Debian Patch
fgrep -lr -- 'varargs.h' . | xargs sed -i 's?varargs.h?stdarg.h?g'
# All os-type does is work out what our OS is and in our case, it
# should print 'linux'.  However, inside Scratchbox it doesn't work.
# Let's just rewrite it so it always gives us the result we desire.
( cd build
  rm -f os-type
  cat << EOF > os-type
#!/bin/bash
echo linux
EOF
  chmod 755 os-type )

make || failmake

mkdir -p $PKG/usr/doc/rdist-$VERSION
cp -a ChangeLog Copyright README $PKG/usr/doc/rdist-$VERSION

cd src
install -m755 rdist rdistd $PKG/usr/bin/

cd ../doc
# Fix /usr/local stuff:
perl -pi -e 's?/usr/local/?/usr/?;' *.man
install -m644 rdist.man $PKG/usr/man/man1/rdist.1
install -m644 rdistd.man $PKG/usr/man/man1/rdistd.1

start_fakeroot  # start the fakeroot server so we can set ownerships
cd $PKG         # enter the package's root directory
slackx86        # search for any Intel x86 binaries
slackgzpages -i # compress man & info pages and delete usr/info/dir
slackstripall   # strip *everything* that can be stripped
#slackstripso   # strip .so files only
#slackstripar   # strip .a files only
#slackstripbin  # strip binaries in usr/bin, usr/sbin, sbin and bin
slackslack      # set all files to root.root, chmod -R og-w, slackchown, slack644docs
slackdesc       # install slack-desc and doinst.sh
slackmp         # run makepkg
slackipkg       # install new package (removepkg runs first)
slackhlinks     # search for any hard links
shortwords      # find LDRH/STRH instructions that do not work correctly on StrongARM110 RiscPC

