#!/bin/sh
# brick-fossil-current - Builds a current Brick source tarball
# License:  MIT/X (for this file only)
# Revision: 110920

# This script builds a  Brick Engine source tarball  based on the code
# that's presently in the engine and bindings Fossil repositories.

NUMBER=110920                   # Set this to a six-digit date
DIR=brickengine-$NUMBER
TARBALL=$DIR.tar.bz2
REPO=http://rs.tc/cgi-bin/

rm -fr $DIR                     || exit 1
mkdir  $DIR                     || exit 1
cd     $DIR                     || exit 1

fossil clone $REPO/fossil.brick-engine \
    fossil.engine               || exit 1
fossil clone $REPO/fossil.brick-engine-bindings \
    fossil.bindings             || exit 1

for x in engine bindings
do
    mkdir $x                    || exit 1
    cd    $x                    || exit 1
    fossil open ../fossil.$x    || exit 1
    cd    ..                    || exit 1
done

rm fossil.* */_FOSSIL_          || exit 1
cd ..                           || exit 1

tar jcf $TARBALL $DIR           || exit 1
rm -fr           $DIR           || exit 1
ls -l   $TARBALL                || exit 1
echo Done
