#!/bin/bash

# arm/build
# Check package dependencies, set metadata and launch
# package build script.
# by Stuart Winter <stuart@armedslack.org>
#
source /usr/share/slackdev/buildkit.sh

# Package metadata:
export PKGNAM=linuxdoc-tools
export VERSION=0.9.21
export ARCH=arm
export BUILD=5
export PKGSERIES=ap
export SLACKPACKAGE=$PKGNAM-$VERSION-$ARCH-$BUILD.tgz

# Reset the ARM file system: restore it to the 'factory settings'
# as it were (this has no effect when building natively):
sboxsysrestore

# Ensure base ARM packages are installed first:
slackbasedeps

# Ensure $PKGNAM isn't already installed:
slackfailpkgdeps $PKGNAM || removepkg $PKGNAM

# Ensure specific build dependencies - libraries and development tools.
# There are many more dependencies but these are the core ones I picked out
# as I was building the software included within this package.
#
slackcheckpkgdeps libxml2 || installpkg $PKGSTORE/l/libxml2-*.tgz
# to unpack some SRPMs:
slackcheckpkgdeps rpm     || installpkg $PKGSTORE/ap/rpm-*.tgz
# for OpenJade:
slackcheckpkgdeps tetex   || installpkg $PKGSTORE/t/tetex-[0-9]*.tgz
# for AsciiDoc:
slackcheckpkgdeps python  || installpkg $PKGSTORE/d/python-[0-9]*.tgz
# Ensure the packages are installed; exit if not.
slackcheckpkgdeps python,libxml2,rpm,tetex || exit 99

# Stop daemons/processes which tend to modify the contents of the filesystem:
altertrackprep

# Start build:
./trackbuild.$PKGNAM

# Compress the build log:
bzip2 -v9f build.$ARCH.log