Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | #!/bin/sh |
2 | ||
3 | tool=$0 | |
4 | ||
5 | usage() | |
6 | { | |
7 | echo "" | |
8 | echo "usage: `/bin/basename $tool` -d configdir -p <processor> [-l|-v <version>] [-f] <installdir>" | |
9 | echo "" | |
10 | echo " -d <configdir> : the location of config files" | |
11 | echo " -p <processor> : get software for <processor>: n2" | |
12 | echo " -l : lists all available versions" | |
13 | echo " -v <version> : get version <version>" | |
14 | echo " -f : force create of <installdir>" | |
15 | echo "" | |
16 | echo " Get <version> of Solaris for <processor> and put it in directory" | |
17 | echo " <installdir>. The directory <installdir> is expected to not exist." | |
18 | echo " Use -f if the <installdir> already exists." | |
19 | echo " Use -l to see the available Solaris versions for processor." | |
20 | echo "" | |
21 | } | |
22 | ||
23 | len () | |
24 | { | |
25 | echo $# | |
26 | } | |
27 | ||
28 | err () | |
29 | { | |
30 | echo "Error: $1" | |
31 | usage | |
32 | exit 2 | |
33 | } | |
34 | ||
35 | # Where we keep all the images for solaris | |
36 | # that are and have known to work. | |
37 | ||
38 | configdir="" | |
39 | processor="" | |
40 | get="solaris" | |
41 | version="" | |
42 | force=0 | |
43 | list=/bin/false | |
44 | ||
45 | while getopts d:hp:lv:f OPT; do | |
46 | case $OPT in | |
47 | d) | |
48 | configdir="$configdir $OPTARG" | |
49 | ;; | |
50 | p) | |
51 | processor="$processor $OPTARG" | |
52 | ;; | |
53 | l) | |
54 | list=/bin/true | |
55 | ;; | |
56 | v) | |
57 | version="$version $OPTARG" | |
58 | ;; | |
59 | f) | |
60 | force=1 | |
61 | ;; | |
62 | h) | |
63 | usage | |
64 | exit 0 | |
65 | ;; | |
66 | *) | |
67 | usage | |
68 | exit 2 | |
69 | ;; | |
70 | esac | |
71 | done | |
72 | ||
73 | shift `/bin/expr $OPTIND - 1` | |
74 | ||
75 | # make sure we have config files' location | |
76 | if [ "`len $configdir`" != "1" ]; then | |
77 | err "I need config files' location." | |
78 | fi | |
79 | ||
80 | # Make sure we have a processor | |
81 | ||
82 | if [ "`len $processor`" != "1" ]; then | |
83 | err "I need exactly one -p argument." | |
84 | fi | |
85 | ||
86 | processor=`echo $processor` | |
87 | root=$configdir/$processor | |
88 | ||
89 | if [ ! -d $root ]; then | |
90 | err "I don't have any software for this processor: $processor" | |
91 | fi | |
92 | ||
93 | root=$root/$get | |
94 | installdir=$1 | |
95 | ||
96 | # List versions or check the passed version | |
97 | ||
98 | if $list ; then | |
99 | l="" | |
100 | for v in ${root}/* ; do | |
101 | l="$l `/bin/basename $v`" | |
102 | done | |
103 | echo "Use -v with one of: $l" | |
104 | exit 0 | |
105 | fi | |
106 | ||
107 | if [ "`len $version`" != "1" ]; then | |
108 | err "I need exactly one version please." | |
109 | fi | |
110 | ||
111 | version=`echo $version` | |
112 | ||
113 | if [ ! -d ${root}/$version ]; then | |
114 | err "Version '$version' is not available for $get on $processor" | |
115 | fi | |
116 | ||
117 | # Check we have a directory to install the software | |
118 | ||
119 | if [ "$installdir" = "" ]; then | |
120 | err "Missing directory to install $get to at end of the command line." | |
121 | fi | |
122 | if [ "$force" = "0" -a -d $installdir ]; then | |
123 | err "Directory $installdir already exists, need a new directory name, or use -f." | |
124 | fi | |
125 | ||
126 | # Finally | |
127 | ||
128 | /bin/mkdir -p $installdir | |
129 | ( | |
130 | cd $installdir | |
131 | # create symbolic links for simulate script | |
132 | /bin/ln -s ${root}/${version}/.simulate.sh . | |
133 | /bin/ln -s ${root}/${version}/* . | |
134 | ) |