#!/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=kde
export VERSION=3.5.4
export ARCH=arm
export PKGSERIES=kde
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

# Remove the KDE packages first:
( cd /var/log/packages
  removepkg kde-* 
  removepkg kde* 
  removepkg arts
  removepkg qt-* 
  # Now the additional packages:
  removepkg amarok* koffice* qca* qca-tls* 
)

# Ensure specific build dependencies (mainly libraries):
# These are just the ones Pat says we need in order to get going.
#
slackcheckpkgdeps cups    || installpkg $PKGSTORE/a/cups-*.tgz
slackcheckpkgdeps pcre    || installpkg $PKGSTORE/l/pcre-*.tgz
slackcheckpkgdeps libxml2 || installpkg $PKGSTORE/l/libxml2-*.tgz
slackcheckpkgdeps libxslt || installpkg $PKGSTORE/l/libxslt-*.tgz
slackcheckpkgdeps cups,pcre,libxml2,libxslt || exit 99

# I know that not everything requires gcc 3.3 (arts doesn't, for example)
# but I may as well build all of KDE with the same compiler unless there's
# a specific reason not to.
#
# Ensure we have gcc-3.3.x installed:
#[ -d /scratchbox ] || upgradepkg $PKGSTORE/../testing/packages/gcc-3.3.x/*.tgz

# Launch the package build script.
# There is no build script for this one - we have the individual
# logs for each build script.  Although that might make tracking down
# a problem harder, I'll think about that when I come to it.
( ./KDE.SlackBuild ) >& /dev/stdout | tee build.$ARCH.log

# Now switch back to the latest compiler:
#[ -d /scratchbox ] || upgradepkg $PKGSTORE/d/gcc*.tgz

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