#!/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 PACKAGE=arts
export VERSION= # deliberately blank - this is set in the {KDE,local}.options file
export ARCH=arm
export BUILD=4
export PKGSERIES=l
export SLACKPACKAGE=$PACKAGE-$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

# Set the config option variables if they are not already set:
if [ -r ../KDE.options ]; then
  . ../KDE.options
fi

# Ensure specific build dependencies (mainly libraries):
slackcheckpkgdeps qt        || installpkg $PKGSTORE/kde/qt-*.tgz
slackcheckpkgdeps alsa-lib  || installpkg $PKGSTORE/l/alsa-lib-*.tgz
slackcheckpkgdeps audiofile || installpkg $PKGSTORE/l/audiofile-*.tgz
slackcheckpkgdeps esound    || installpkg $PKGSTORE/l/esound-*.tgz
slackcheckpkgdeps expat     || installpkg $PKGSTORE/l/expat-*.tgz
slackcheckpkgdeps libmad    || installpkg $PKGSTORE/l/libmad-*.tgz
slackcheckpkgdeps glib2     || installpkg $PKGSTORE/l/glib2-*.tgz
slackcheckpkgdeps libogg    || installpkg $PKGSTORE/l/libvorbis-*.tgz
slackcheckpkgdeps libvorbis || installpkg $PKGSTORE/l/libogg-*.tgz
slackcheckpkgdeps libmad    || installpkg $PKGSTORE/l/libmad-*.tgz
slackcheckpkgdeps libjpeg   || installpkg $PKGSTORE/l/libjpeg-*.tgz
slackcheckpkgdeps libmng    || installpkg $PKGSTORE/l/libmng-*.tgz
slackcheckpkgdeps libpng    || installpkg $PKGSTORE/l/libpng-*.tgz
slackcheckpkgdeps x11-devel || installpkg $PKGSTORE/x/x11-devel-*.tgz
slackcheckpkgdeps x11       || installpkg $PKGSTORE/x/x11-[0-9]*-*.tgz
slackcheckpkgdeps qt,alsa-lib,audiofile,esound,expat,libmad,libmng,glib2,libogg,libvorbis,libmad,libjpeg,libpng,x11-devel,x11 || exit 99

# Launch the package build script:
( ./$PACKAGE.SlackBuild ) >& /dev/stdout | tee build.$ARCH.log

# Compress the build log:
bzip2 -9f build.$ARCH.log
