aboutsummaryrefslogtreecommitdiff
path: root/util/self_update
blob: 8e438909bc842b9ab1d7b6596fd77944f1aba543 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
#
#  SELF_UPDATE - Update the update scripts.


# Initialize the $iraf and environment.
if [ -z "$iraf" ]; then
  if [ -e "$FAKEHOME/setup.sh" ]; then
    source $FAKEHOME/setup.sh
  else
    source unix/hlib/setup.sh
  fi
else
    source $iraf/unix/hlib/setup.sh
fi

source $iraf/unix/hlib/irafuser.sh

cd $iraf/util

REPO=`${iraf}/util/pkgrepo`
if [ -n "$IRAFARCH" ]; then
    arch=$IRAFARCH
else
    arch=`${iraf}/unix/hlib/irafarch.sh -actual`
fi


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

# Delete any existing downloads.
if [ -e /tmp/util.tgz ]; then
    /bin/rm -f /tmp/util.tgz
fi

# 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.
(cd ../; tar zxf /tmp/util.tgz; /bin/rm -f /tmp/util.tgz )

# Edit the current IRAF path into the scripts.
cd $iraf/unix/hlib
pfiles=("cl.sh" "cl.csh" "ecl.sh" "ecl.csh" "vocl.sh" "vocl.csh" "setup.sh" "setup.csh" "mkiraf.sh" "mkiraf.csh")
d_iraf="/iraf/iraf/"
TEMP="/tmp/iraf_update.$$"
/bin/rm -f $TEMP

for file in ${pfiles[@]}; do
    sed -e "s+$d_iraf+$iraf+" $file > $TEMP
    mv $TEMP $file
done
cd $iraf
/bin/echo "Done"

exit 0