#!/bin/bash

#
# build.sh - Build script for Project RPMs
#
# $Id: build.sh 34 2008-05-09 09:30:23Z mariusr@D.ETHZ.CH $
# $HeadURL:$
#


# CHANGE THESE
PROJ=Infotrend
VERSION=`cat VERSION`
TARSOURCES="$PROJ-$VERSION"

#### NOTHING TO CHANGE BELOW HERE FOR SIMPLE BRICKS #########################

TARBALL=$TARSOURCES.tgz
SPEC=$PROJ.spec

# Set rpmbuildenv
rpmbuildenv svn

# Make sure the %_sourcedir directory exists
SOURCEDIR=`rpmbuild --eval '%_sourcedir' $SPEC`
if [ ! -d "$SOURCEDIR" ] ; then
     echo "No %_sourcedir directory '$SOURCEDIR'"
     exit 1;
fi

# Either 'cd' to the build directory or run 'build.sh' using an absolute
# path
cd `dirname $0`

# Build tar
ln -s . $TARSOURCES
tar -h --exclude="$TARSOURCES/$PROJ*" --exclude='.svn' -zcf "$SOURCEDIR/$TARBALL" $TARSOURCES
rm $TARSOURCES

#Build rpm
rpmbuild -ba $SPEC
