
#!/bin/sh

#
# Define the usage() function
#

usage ()
{
  echo "usage: $0 release-id-string"
  echo " e.g.: $0 libmesh-0.4.3"
  exit
}


#
# Need at least one command-line argument
#
if [ "$#" != "1" ] ; then
    usage $0
fi

#
# Get the user-specified release string
#
release=$1
#echo "release  = $release"

cvs_rtag=`echo $release | sed -e "s/[.]/_/g"`
#echo "cvs_rtag = $cvs_rtag"

#
# CVS tags cannot contain '.', so replace any '.' with '_'
# and use that to tag the current libmesh CVS repository for this release
#
echo ""
echo "Tagging current CVS repository as \"$cvs_rtag\""
(cd /usr/src/RPM/BUILD/libmesh-complex-0.8.0 ; cvs rtag $cvs_rtag libmesh)

#
# Checkout a clean copy of libmesh from the CVS server,
# use it to create the release...
#
cvsroot=`cat /usr/src/RPM/BUILD/libmesh-complex-0.8.0/CVS/Root`
echo ""
echo "Checking out a fresh copy of the newly tagged code"
cvs -Q -d $cvsroot co -r $cvs_rtag -d $release libmesh

#
# Remove the CVS-associated files & directories from
# the source tree
#
echo ""
echo "Pruning CVS files & directories from directory $release"
rm -rf `find $release -name CVS`
rm -rf `find $release -name .cvsignore`


#
# Create a gzip'ed tar file for the requested release
#
echo ""
echo "Creating $release.tar.gz"
tar zcf $release.tar.gz $release
rm -rf $release

#
# Possibly upload the file to sourceforge
#
echo ""
echo "Done."
echo "Would you like to open an FTP connection to upload.sourceforge.net"
echo "so you can put the file in the /incoming directory?"
echo -n "Y or N? "
read ans
if [ "$ans" = "Y" -o "$ans" = "y" -o "$ans" = "Yes" -o "$ans" = "yes" ]; then
    exec ftp upload.sourceforge.net
fi



# Local Variables:
# mode: shell-script
# End:
