#!/bin/csh -f
#
#  SELF_UPDATE - Update the update scripts.

unalias 	grep ls

set  iraf       = $cwd/
source $iraf/unix/hlib/irafuser.csh

chdir $iraf/util

set REPO        = `${iraf}/util/pkgrepo`
if ($?IRAFARCH) then
    set arch    = $IRAFARCH
else
    set arch    = `${iraf}/unix/hlib/irafarch.csh -actual`
endif


echo -n "Updating utility scripts ...."

# Delete any existing downloads.
if (-e /tmp/util.tgz) then
    /bin/rm -f /tmp/util.tgz
endif

# Get the latest script distribution.
./fget -o /tmp/util.tgz ${REPO}/util-universal.tar.gz

# Go to iraf root, unpack and clean up.  Using the IRAF root gives us
# the chance to update the toplevel Makefile or other build scripts in
# the system, e.g. in the 'vendor' directory.
(chdir ../ ; tar zxf /tmp/util.tgz  ; /bin/rm -f /tmp/util.tgz )

echo "Done"

exit 0
