#!/bin/bash

# aaa_base.SlackBuild
# by Stuart Winter <mozes@slackware.com>
# 1-May-2004

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

# Temporary build locations:
export TMPBUILD=$TMP/build-$PKGNAM
export PKG=$TMP/package-$PKGNAM
mkpkgdirs # Delete and re-create temporary directories

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

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

# Replace the root mail from Patrick with my own.  We don't want
# people mailing Patrick about Slackware ARM:
if [ ${ARCH} = arm ]; then
   #install -vpm640 -oroot -groot $PORTCWD/arm/root.new ${PKG}/var/spool/mail
   # Set the email's date to be the current date:
   # This also updates the time stamp on the file so that when this package
   # is installed, it shows up as a new email.
   xz -dc $PORTCWD/arm/var_spool_mail_root-new.xz | sed 's?%CURRENTDATE%?'"$( date "+%a %b %d %R:%S %Y" )"'?g' > ${PKG}/var/spool/mail/root.new
   chmod 640 ${PKG}/var/spool/mail/root.new
   chown root:root ${PKG}/var/spool/mail/root.new
fi

# Edit the /etc/os-release to use Slackware ARM's homepage:
sed \
    -e 's?/questions/slackware-14/?/questions/slackware-arm-108/?g' \
    -e 's?HOME_URL=.*?HOME_URL="http://arm.slackware.com"?g' \
    $CWD/os-release > $PKG/etc/os-release
chmod 644 $PKG/etc/os-release
chown root:root $PKG/etc/os-release

# Install the Kernel README into /boot:
mkdir -vpm755 ${PKG}/boot
install -vpm644 $PORTCWD/README-kernels.txt ${PKG}/boot/

# 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, slack644docs
slackdesc       # install slack-desc and doinst.sh
slackmp         # run makepkg -l y -c n

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