#!/bin/sh
#
# $Id: build_rpm,v 1.4 2001/11/06 06:29:57 blais Exp $
#

if [ ! -f "configure.in" -o ! -f "tools/rpm_spec" ]; then
     echo "You must be running this script from the topdir directory."
fi

# Note: this script assume that release_bin has already been called.

echo "Getting version number"
VERSION=`grep AM_INIT_AUTOMAKE configure.in | sed -e 's/[^0-9]*\([.0-9]*\).*/\1/'`
echo "   Version is " $VERSION

echo "Creating spec file"
sed -e "s/@VERSION@/$VERSION/" tools/rpm_spec > /usr/src/redhat/SPECS/xxdiff-$VERSION.spec

echo "Copying pristine build"
if [ ! -f "../xxdiff-$VERSION.i386.tar.gz" ]; then
     echo "You must be running this script from the topdir directory."
fi
cp ../xxdiff-$VERSION.i386.tar.gz /usr/src/redhat/SOURCES

echo "Building binary package"
rpm -ba /usr/src/redhat/SPECS/xxdiff-$VERSION.spec

echo "Copy binary package home"
cp /usr/src/redhat/RPMS/i386/xxdiff-$VERSION*.i386.rpm /home/blais
chmod 777 /home/blais/xxdiff-$VERSION*.i386.rpm

echo "Done."
