#!/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

# Package metadata:
export PKGNAM=QScintilla
export VERSION=${VERSION:-2.14.1}
export BUILD=${BUILD:-4}
export PKGSERIES=${PKGSERIES:-l}
export SLACKPACKAGE=$PKGNAM-$VERSION-$PKGARCH-$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
## ******************************************************************* ##

# Ensure base ARM packages are installed first:
slackbasedeps

# Ensure $PKGNAM isn't already installed:
# With v 2.10.7, it fails to make install if the package isn't present.
# That's a bug, but not one I fancy fixing right now when there's a work around
# to just keep the old one installed whilst building the new ;-)
#slackfailpkgdeps $PKGNAM || removepkg $PKGNAM

# Ensure specific build dependencies (mainly libraries):
{ slackcheckpkgdeps freetype        || installpkg $PKGSTORE/l/freetype-[0-9]*.t?z || exit 99; }
{ slackcheckpkgdeps glib2           || installpkg $PKGSTORE/l/glib2-[0-9]*.t?z   || exit 99; }
{ slackcheckpkgdeps libpng          || installpkg $PKGSTORE/l/libpng-[0-9]*.t?z  || exit 99; }
{ slackcheckpkgdeps qt5             || installpkg $PKGSTORE/l/qt5-[0-9]*.t?z      || exit 99; }
{ slackcheckpkgdeps fontconfig      || installpkg $PKGSTORE/x/fontconfig-[0-9]*.t?z || exit 99; }
{ slackcheckpkgdeps libICE          || installpkg $PKGSTORE/x/libICE-[0-9]*.t?z  || exit 99; }
{ slackcheckpkgdeps libSM           || installpkg $PKGSTORE/x/libSM-[0-9]*.t?z   || exit 99; }
{ slackcheckpkgdeps libX11          || installpkg $PKGSTORE/x/libX11-[0-9]*.t?z  || exit 99; }
{ slackcheckpkgdeps libXext         || installpkg $PKGSTORE/x/libXext-[0-9]*.t?z || exit 99; }
{ slackcheckpkgdeps libXrender      || installpkg $PKGSTORE/x/libXrender-[0-9]*.t?z || exit 99; }
# lddslack won't find this - don't remove it if refreshing the list:

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

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