#!/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=rpm
export VERSION=${VERSION:-4.4.2.3}
export PKGARCH=${PKGARCH:-arm}
export BUILD=${BUILD:-1}
export PKGSERIES=${PKGSERIES:-ap}
export SLACKPACKAGE=$PKGNAM-$VERSION-$PKGARCH-$BUILD.tgz

# Ensure base ARM packages are installed first:
slackbasedeps

# Ensure additional dependencies:
{ slackcheckpkgdeps bzip2    || installpkg $PKGSTORE/a/bzip2-*.tgz || exit 99 ; }
{ slackcheckpkgdeps beecrypt || installpkg $PKGSTORE/l/beecrypt-*.tgz || exit 99 ; }
{ slackcheckpkgdeps expat    || installpkg $PKGSTORE/l/expat-*.tgz || exit 99 ; }
{ slackcheckpkgdeps neon     || installpkg $PKGSTORE/l/neon-*.tgz || exit 99 ; }
{ slackcheckpkgdeps popt     || installpkg $PKGSTORE/l/popt-*.tgz || exit 99 ; }
{ slackcheckpkgdeps openssl  || installpkg $PKGSTORE/n/openssl-*.tgz || exit 99 ; }

# In Slack390's prototype script, Mark says:
# This package seems to have problems when either automake or autoconf are
# installed. This may get fixed in the future, but be prepared to removepkg them
# if problems still occur. The autoconf problem manifested itself as a gcc parse
# error in popt/config.h.
###
# Since I have so many bizarre problems with rpm, I'll take heed of his
# caution:
#slackfailpkgdeps autoconf     || removepkg autoconf
#slackfailpkgdeps autoconf2.13 || removepkg autoconf2.13
#slackfailpkgdeps automake     || removepkg automake

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

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