#! /bin/csh 
# 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"
   echo "   make_source_tar  target_area  trunk"
   echo "e.g.,"
   echo "   make_source_tar  /home/users/tmap/ferret  v6_6_2_release"
   echo "will make a gzipped tar file of the corresponding Ferret source in the directory"
   echo "   /home/users/tmap/ferret/v6_6_2_release"
   echo "Use 'trunk' if no tag or branch is 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 FERRET/html_docs

# get tar file location
set ctar_file = fer_source.tar.gz
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
tar cvzf $ctar_file  --exclude .svn FERRET >&! tar_create_log
ls -l $ctar_file*
echo "If there are any problems with the tar file, see $source_dir/$tag/tar_create_log"
echo "for more information"

