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

# Reset the ARM file system: restore it to the 'factory settings'
# as it were (this has no effect when building natively):
sboxsysrestore

# Ensure base ARM packages are installed first:
slackbasedeps

# Ensure $PACKAGE isn't already installed:
#slackfailpkgdeps $PACKAGE || removepkg $PACKAGE
#rm -rf /var/lib/elm 

# Ensure build dependencies:
# Basically just build elm on top of a full system, as this is what Pat does. 
slackcheckpkgdeps ncurses  || installpkg ${PKGSTORE}/l/ncurses-*tgz
slackcheckpkgdeps sendmail || installpkg ${PKGSTORE}/n/sendmail-[0-9]*.tgz
slackcheckpkgdeps ispell   || installpkg ${PKGSTORE}/ap/ispell-*.tgz
slackcheckpkgdeps emacs    || installpkg ${PKGSTORE}/e/emacs-[0-9]*.tgz
slackcheckpkgdeps elvis    || installpkg ${PKGSTORE}/a/elvis-*.tgz
slackcheckpkgdeps ncurses,sendmail,ispell,emacs,elvis || exit 50

# Launch the package build script:
( ./$PACKAGE.SlackBuild ) 2>&1 | tee build.log

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