#!/bin/sh

# Create distribution packages of SWIFT-RMVSY (both TAR.GZ and RPM).
# Miroslav Broz (miroslav.broz@email.cz), Nov 11th 2003

SWIFT=swift-rmvsy
CWD=`pwd`
#RPM=/usr/src/redhat
RPM=/usr/src/packages
#DATE=`date +"%Y%m%d"`
DATE=`awk '/Version:/{print $2}' $SWIFT.spec`
RELEASE=`awk '/Release:/{print $2}' $SWIFT.spec`
PKG=$SWIFT-$DATE
TMP=/tmp/$PKG


rm -rf $TMP
mkdir $TMP
cp -r * $TMP/
cd $TMP
make mrproper
rm $SWIFT-*.tar.gz $SWIFT-*.rpm
cd ..
tar -vczf $PKG.tar.gz $PKG/
cd $CWD
mv /tmp/$PKG.tar.gz .

if [ "$1" = "" ] ; then

cp $SWIFT-$DATE.tar.gz $RPM/SOURCES/
cp $SWIFT.spec $RPM/SPECS/$SWIFT-$DATE.spec
rpm -ba $RPM/SPECS/$SWIFT-$DATE.spec
cp $RPM/SRPMS/$SWIFT-$DATE-$RELEASE.src.rpm .
cp $RPM/RPMS/i386/$SWIFT-$DATE-$RELEASE.i386.rpm .

fi

