#!/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 PACKAGE=rpm
export PKGSERIES=ap
export VERSION=4.2.1
export BUILD=1
export ARCH=arm
export SLACKPACKAGE=$PACKAGE-$VERSION-$ARCH-$BUILD.tgz

# Ensure base ARM packages are installed first:
slackbasedeps

# I want to rebuild beecrypt every time and since it's not
# an ARMedslack (or Slackware) package, it won't be around when
# we next reinstall:
removepkg beecrypt
rm -rf /tmp/beecrypt-*

# Ensure additional dependencies. Actually rpm contains its own copy of db3 but..
slackcheckpkgdeps beecrypt || ( ./beecrypt.SlackBuild 2>&1 | tee beecrypt_build.log )
slackcheckpkgdeps beecrypt || installpkg /tmp/beecrypt-*.tgz
slackcheckpkgdeps db3      || installpkg $PKGSTORE/l/db3-*.tgz
slackcheckpkgdeps popt     || installpkg $PKGSTORE/l/popt-*.tgz
slackcheckpkgdeps beecrypt,db3,popt || 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 build script:
( ./$PACKAGE.SlackBuild ) 2>&1 | tee build.log

# beecrypt is no longer required
removepkg beecrypt

# Compress the build log:
bzip2 -9f build.log
