#!/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:-6.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

# 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 ; }

# This is working around a bug in Slackware ARM. Not sure why it's broken yet.
removepkg db48

# Ensure additional dependencies:

# Ensure $PKGNAM isn't already installed:
slackfailpkgdeps $PKGNAM || removepkg $PKGNAM

#{ 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=$SLKPORTARCH-$( basename $SLACKPACKAGE .t?z ).build.log
( ./$PKGNAM.SlackBuild ) >& /dev/stdout | tee $BUILDLOG

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

# Reinstall db48:
{ slackcheckpkgdeps db48 || installpkg $PKGSTORE/l/db48-[0-9]*.t?z || exit 99 ; }
