#! /bin/csh -x
# make_source_tar
# ver 1.0 6/10 *acm*
# ver 2.0 11/10 *acm* change CVS to svn

# this script gets the source code, asking for any particular tag, or for trunk

if ( $#argv == 2 ) then
   set targ_dist_parent = $argv[1]
   set tag = $argv[2]
   set source_dir = $targ_dist_parent
else
   echo ""
   echo usage:
   echo make_source_tar target_area tag
   echo   OR make_source_tar target_area trunk
   echo e.g. "'make_source_tar /home/users/tmap/ferret v6_6_2_release'" will make a 
   echo gzipped tar file of the corresponding Ferret source in the directory
   echo "'/home/users/tmap/ferret/v6_6_2_release'"
   echo "use HEAD if no tag or branch to be used"
   echo ""
 exit 0
endif

cd $source_dir
mkdir $tag
cd $tag

#use svn now to checkout desired files
echo "Extracting FERRET source code......."

if ( $tag == trunk ) then
   svn checkout file:///home/users/tmap/svn/repos/ferret/trunk FERRET >&! .install_log
else
   svn checkout file:///home/users/tmap/svn/repos/ferret/tags/$tag FERRET >&! .install_log
endif
cp ./FERRET/fer/README ./FERRET
rm -rf html_docs

# get tar file location
set ctar_file = fer_source.tar
echo "Ready to create gzipped tar file $ctar_file"
ready:
echo "OK to continue ?"
set ans = $<
switch($ans)
case y:
   breaksw
case n:
   exit 0
default:
   echo "must answer y or n"
   goto ready
endsw

# make the gzipped tar file
cd $source_dir/$tag
rm -f .tar_create_log
tar vcf $ctar_file  --exclude .svn .  >& ./tar_create_log
gzip $ctar_file
ls -l $ctar_file*
echo "If there are any problems w/ the tar file, see "$source_dir/".tar_create_log for"
echo "more information"




