#!/bin/csh -f 
#
#
################################# sswup ###################################
# Upgrade one or more SSW branches of SSW from UNIX command line
#
# Requires:
# SSW and Perl installed via http://www.lmsal.com/solarsoft/ssw_upgrade.html
#    $SSW/site/setup/ssw_upgrade.mirror -or-
#    $SSW/site/mirror/ssw_upgrade.mirror exists
# (ie, at least one previous execution of ssw_upgrade.pro)
#
#
# 14-March-2000 S.L.Freeland 
#
###########################################################################

if ($#argv == 0) then
   set args="solarsoft_gen"
else
   set args=$argv
endif

if (-e $SSW/site/mirror/ssw_upgrade.mirror) then 
   set mfile=$SSW/site/mirror/ssw_upgrade.mirror
else
   if (-e $SSW/site/setup/ssw_upgrade.mirror) then 
      set mfile=$SSW/site/setup/ssw_upgrade.mirror
   else
      echo "No ssw mirror file; need to run 'ssw_upgrade.pro' at least once"
      exit
   endif
endif

foreach branch ($args)
   set chk=`grep $branch $mfile | grep package=`
   if ($chk != "") then
      set package=`echo $chk | cut -f2 -d"="`
      echo "Mirroring package>> "$package
      $SSW/gen/mirror/mirror -p$package $mfile
   else
      echo "no package match for: "$branch
   endif
end
exit
