#!/bin/bash

# aaa_base.SlackBuild
# by Stuart Winter <stuart@armedslack.org> for the Slackware porting Project.
# 1-May-2004

# 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 and re-create temporary directories

start_fakeroot
cd $PKG
explodepkg $CWD/_aaa_base.tar.gz

install -m644 $CWD/slack-desc $PKG/install
install -m644 $CWD/slackware-version $PKG/etc

# If this is ARMedslack then we'll brand it as such:
if [ $PORTARCH = arm ]; then
   ( cd $PKG/etc
     ln -fs slackware-version armedslack-version 
     echo "ARMedslack version 1.0 (`cat slackware-version`)" > slackware-version )
fi

# Replace the root mail from Patrick with my own.  We don't want
# people mailing Patrick about ARMedslack when he has nothing to do with it! ;-)
if [ ${PORTARCH} = arm ]; then
   install -m640 -oroot -groot $PORTCWD/arm/root.new ${PKG}/var/spool/mail
fi

# If necessary, start the fakeroot server so we can set file/dir ownerships:
start_fakeroot

# Apply generic Slackware packaging policies:
cd $PKG
slackgzpages -i # compress man & info pages and delete usr/info/dir
slackslack      # chown -R root:root, chmod -R og-w, slackchown (root:bin), slack644docs
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
