#!/bin/bash
# 
# Get current Jamin cvs code
#
#
STAMP=`date +"%Y%m%d.%H%M%S"`
REVISION=0

if [ ! -d jamin-${STAMP} ] ; then
   echo
   echo "Creating download directory: jamin-${STAMP}"
   mkdir jamin-${STAMP}
else
   echo "Error: download directory jamin-${STAMP} already exists!"
   exit 1
fi
cd jamin-${STAMP}
echo

echo "NOTE: press <enter> when prompted for password"
echo
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/jamin login

echo "  getting jamin..."
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/jamin co . 

echo "  creating jamin tarball..."
if [ -d jamin ] ; then
   JAMIN_VERSION=`grep AM_INIT_AUTOMAKE jamin/configure.in | awk '{print $2}' | sed 's/)//'`
   if [ -z "$JAMIN_VERSION" ] ; then
	echo 
	echo "Could not find version of Jamin"
	echo
	exit 1
   fi
   touch jamin/CVS-${STAMP}
   mv jamin jamin-${JAMIN_VERSION}-cvs
   tar czf ../jamin-${JAMIN_VERSION}-cvs.tar.gz jamin-${JAMIN_VERSION}-cvs
fi
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/jamin logout
cd ../
if [ -d jamin-${STAMP} ] ; then
   echo "  removing download directory..."
   rm -r jamin-${STAMP}
fi
# print current version numbers for spec file
echo
echo "Current version numbers:"
echo
echo "%define version ${JAMIN_VERSION}"
echo "%define cvsdate ${STAMP}"
echo
exit
