#!/bin/bash

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

# https://buildd.debian.org/build.php?arch=armel&pkg=qt4-x11
#
# Apparently debian have had trouble with this, so let's make sure
# our architecture is always hard coded:
#export LD_PRELOAD=/usr/lib/libfakeuname.so
#export FAKEUNAMEARCH=armv5tel

# Package metadata:
export PKGNAM=qtwebkit
export VERSION=2.3.4
export BUILD=1_doesnt_matter
export PKGSERIES=l
export SLACKPACKAGE=$PKGNAM-$VERSION-$ARCH-$BUILD.txz

## ******************************************************************* ##
# For test packages - best to store in another location rather than
# overwriting the working copy in the main tree:
# export PKGSTORE=/tmp/
# mkdir -vpm755 $PKGSTORE/$PKGSERIES
## ******************************************************************* ##

# 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

# You need the temporary 'qtnowebkit' package installed.
if [ ! -f /var/log/packages/qtnowebkit ]; then
   echo "You should use the build-qt script to build qt before building this package"
   exit 99
fi

# Launch the package build script:
BUILDLOG=$( basename $SLACKPACKAGE .t?z ).build.log
( ./$PKGNAM.SlackBuild ) >& /dev/stdout | tee $BUILDLOG

# Compress the build log:
bzip2 -9fvz $BUILDLOG
