aboutsummaryrefslogtreecommitdiff
path: root/unix/hlib/util.csh/pkginst
blob: 2111a607c49bf4bb54d809e5d252feefe886f6b4 (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
#!/bin/csh -f
#
#  PKGINST - Install the named package.

unalias 	grep sort uniq ls awk

if ($#argv < 1) then
    exit 0
else
    set pkg = $1
endif

set  bindir     = "`dirname $0`"                # get iraf root directory 
set  irafdir    = $bindir:h

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

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

# Get any dependency package names.
set deps=`grep ^$pkg .repo_desc | awk '{printf("%s\n",$2)}' | sed -e 's/,/ /g'`
set pkg_dep = ""
foreach d ( $deps )
   if ("$d" != "none") then
      echo "Adding dependency '$d' ...."
      set pkg_dep = "$pkg_dep $d"
   endif
end

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

# Process the requested package and any dependencies.
foreach ip ($pkg_dep $pkg)

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

  echo $pfile | grep src.tar.gz  > /dev/null
  if ($status == 0) then
    set src_only = 1
  else
    set src_only = 0
  endif

  # Remove an existing package file.
  if (-e $pfile) then
    /bin/rm -f $pfile
  endif

  # Download the repo file and unpack it.
  echo -n "Installing package '$ip' .... "
  ${irafdir}/util/pkgget ${REPO}/$pfile
  if ($status == 1) then
    echo    " [Error]"
    exit $status
  endif

  if (-e $pfile) then

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

    if ($src_only == 1) then
      echo    " [SOURCE ONLY]"
      echo `date +%s`"  " $ip > $ip/.src_only
    else
      echo    " [OK]"
    endif
  else
    echo    " [Error]"
  endif

  ${irafdir}/util/pkgenv -init

end

exit 0