#! /bin/csh -f

echo "--------------------------------------------------------------------------"
echo "NewDist: Building compressed file for CDEV Distribution"
echo "         Prior to running this program, make sure that all changes "
echo "         that are to be distributed with this release have been checked" 
echo "         into CVS."
echo " "
echo "         Last used successfully by Walt Akers on 07/24/99"
echo "--------------------------------------------------------------------------"

if ($#argv < 2) then
	echo "Format is: NewDist MajorVer MinorVer <Release>"
	echo "           ... MajorVer is the major version number of cdev"
	echo "           ... MinorVer is the minor version number of cdev"
	echo "           ... Release is the release number of cdev\n"
	echo "Example:   To create a distribution for cdev/1.6.2 the"
	echo "           command will be NewDist 1 6 2\n"
	exit
else
	set MAJORVER=$1
	set MINORVER=$2
	if($#argv >2) then
		set RELEASE=$3
		set CVSTAG=CDEV_R${MAJORVER}_${MINORVER}_${RELEASE}
		set DISTDIR=cdev_${MAJORVER}.${MINORVER}.${RELEASE}
	else
		set RELEASE=None
		set CVSTAG=CDEV_R${MAJORVER}_${MINORVER}
		set DISTDIR=cdev_${MAJORVER}.${MINORVER}
	endif
endif

echo "Steps:     This program will perform the following steps"
echo "           to create the distribution.\n"
echo "           1) It will install a revision number in cdev"
echo "              that identifies this version using the "
echo "              MajorVer/MinorVer/Revision number provided.\n"
echo "             (cdev/1.6.2 would be labeled CDEV_R1_6_2.\n"
echo "           2) cvs export will be executed to create a" 
echo "              clean copy of the distribution in a new"
echo "              directory.\n"
echo "             (cdev/1.6.2 would be installed in cdev_1.6.2)\n"
echo "           3) tar will be used to create an archive of the"
echo "              cdev distribution.\n"
echo "             (cdev/1.6.2 would be archived to cdev_1.6.2.tar)\n" 
echo "           4) gzip will be used to make a compress the archive\n"
echo "             (cdev/1.6.2 would be compressed to cdev_1.6.2.tar.gz\n"
echo "           5) compress will be used to compress the archive using"
echo "              an alternate format.\n"
echo "             (cdev/1.6.2 would be compressed to cdev_1.6.2.tar.Z)\n"
echo "           6) The temporary directory will be deleted.\n"
echo "------------------------------- OPTIONS --------------------------------\n"
echo "Major Version     : $MAJORVER "
echo "Minor Version     : $MINORVER "
echo "Release           : $RELEASE "
echo "CVS Release Tag   : $CVSTAG "
echo "Distribution Name : $DISTDIR \n"
echo "------------------------------------------------------------------------\n"

echo "Press <CTRL>+C to quit or <RETURN> to continue"
read 
echo "Continuing...\n"
echo "STEP 1: Tagging CDEV with Revision Tag $CVSTAG"
cvs rtag -afRF $CVSTAG cdev

echo "STEP 2: Exporting  CDEV to temporary directory $DISTDIR"
cvs export -r $CVSTAG -d $DISTDIR cdev

echo "STEP 3: Creating archive ${DISTDIR}.tar from $DISTDIR"
tar -cvhf ${DISTDIR}.tar $DISTDIR
cp ${DISTDIR}.tar ${DISTDIR}.tar.saf

echo "STEP 4: Compressing ${DISTDIR}.tar using gzip"
gzip ${DISTDIR}.tar

echo "STEP 5: Compressing ${DISTDIR}.tag using compress"
mv ${DISTDIR}.tar.saf ${DISTDIR}.tar
compress ${DISTDIR}.tar

echo "STEP 6: Deleting temporary directory"
rm -rf ${DISTDIR}
