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

# Ensure base ARM packages are installed first:
slackbasedeps

# Ensure additional dependencies:
{ slackcheckpkgdeps bzip2       || installpkg $PKGSTORE/a/bzip2-[0-9]*.t?z || exit 99 ; }
{ slackcheckpkgdeps file        || installpkg $PKGSTORE/a/file-[0-9]*.t?z || exit 99 ; }
{ slackcheckpkgdeps xz  || installpkg $PKGSTORE/a/bzip2 -9fvz || exit 99 ; }
{ slackcheckpkgdeps sqlite      || installpkg $PKGSTORE/ap/sqlite-[0-9]*.t?z || exit 99 ; }
{ slackcheckpkgdeps python      || installpkg $PKGSTORE/d/python-[0-9]*.t?z || exit 99 ; }
{ slackcheckpkgdeps db48        || installpkg $PKGSTORE/l/db48-[0-9]*.t?z || exit 99 ; }
{ slackcheckpkgdeps popt        || installpkg $PKGSTORE/l/popt-[0-9]*.t?z || exit 99 ; }

# Let's build only against mozilla-nss rather than anything else in the mozilla packages:
removepkg mozilla-firefox seamonkey seamonkey-solibs mozilla-thunderbird
{ slackcheckpkgdeps mozilla-nss || installpkg $PKGSTORE/l/mozilla-nss-[0-9]*.t?z || exit 99 ; }

#{ slackcheckpkgdeps mozilla-firefox     || installpkg $PKGSTORE/xap/mozilla-firefox-[0-9]*.t?z || exit 99 ; }
#{ slackcheckpkgdeps mozilla-thunderbird || installpkg $PKGSTORE/xap/mozilla-thunderbird-[0-9]*.t?z || exit 99 ; }
# but we do need some seamonkey libraries:
#{ slackcheckpkgdeps seamonkey   || installpkg $PKGSTORE/xap/seamonkey-[0-9]*.t?z || exit 99 ; }
#{ slackcheckpkgdeps seamonkey-solibs || installpkg $PKGSTORE/l/seamonkey-solibs-[0-9]*.t?z || 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 .t?z ).build.log
( ./$PKGNAM.SlackBuild ) >& /dev/stdout | tee $BUILDLOG

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