aboutsummaryrefslogtreecommitdiff
path: root/util/pkginst
blob: d4a83a24185eecbd7256bce1bac468d6d45c14e3 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
#
#  PKGINST - Install the named package.

if (( $#<1 )); then
    exit 0
else
    pkg=$1
fi

bindir="`dirname $0`"                # get iraf root directory 
irafdir=${bindir%/*}

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


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

/bin/echo "Setting architecture: '$arch' .... "
 

# Get any dependency package names.
deps=`grep ^$pkg .repo_desc | awk '{printf("%s\n",$2)}' | sed -e 's/,/ /g'`
pkg_dep=""
for d in ${deps[@]}; do 
   if [ "$d" != "none" ]; then
      /bin/echo "Adding dependency '$d' ...."
      pkg_dep="$pkg_dep $d"
   fi
done

# Make a unique list of package, i.e. remove multiple instances of a package.
#   [Note:  Not used, the manifest should have this already. ]
list=`/bin/echo $pkg_dep $pkg|awk 'BEGIN {RS=" |\n";}{print $1;}'|sort|uniq`

# Process the requested package and any dependencies.
dep=("$pkg_dep" "$pkg")
for ip in ${dep[@]}; do

  pfile=`grep \ $ip\  .repo_manifest | grep ${arch}\  | head -1 | awk '{printf("%s\n",$4)}'`

  /bin/echo $pfile | grep src.tar.gz  >> /dev/null 2>&1
  if (( $?==0 )); then
    src_only=1
  else
    src_only=0
  fi

  # Remove an existing package file.
  if [ -e $pfile ]; then
    /bin/rm -f $pfile
  fi

  # Download the repo file and unpack it.
  /bin/echo -n "Installing package '$ip' .... "
  ${irafdir}/util/pkgget ${REPO}/$pfile
  if (( $?>0 )); then
    /bin/echo    " [Error]"
    exit $?
  fi

  if [ -e $pfile ]; then

    tar zxf $pfile
    /bin/rm -f $pfile
    /bin/echo `date +%s`"  " ${ip}.${arch} > $ip/.installed.${arch}
    /bin/echo `date +%s`"  " $ip > $ip/.installed	

    if (( $src_only>0 )); then
      /bin/echo    " [SOURCE ONLY]"
      /bin/echo `date +%s`"  " $ip > $ip/.src_only
    else
      /bin/echo    " [OK]"
    fi
  else
    /bin/echo    " [Error]"
  fi

  ${irafdir}/util/pkgenv -init

done

exit 0