Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / api / sam / src / getsolaris
CommitLineData
920dae64
AT
1#!/bin/sh
2
3tool=$0
4
5usage()
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
23len ()
24{
25 echo $#
26}
27
28err ()
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
38configdir=""
39processor=""
40get="solaris"
41version=""
42force=0
43list=/bin/false
44
45while 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
71done
72
73shift `/bin/expr $OPTIND - 1`
74
75# make sure we have config files' location
76if [ "`len $configdir`" != "1" ]; then
77 err "I need config files' location."
78fi
79
80# Make sure we have a processor
81
82if [ "`len $processor`" != "1" ]; then
83 err "I need exactly one -p argument."
84fi
85
86processor=`echo $processor`
87root=$configdir/$processor
88
89if [ ! -d $root ]; then
90 err "I don't have any software for this processor: $processor"
91fi
92
93root=$root/$get
94installdir=$1
95
96# List versions or check the passed version
97
98if $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
105fi
106
107if [ "`len $version`" != "1" ]; then
108 err "I need exactly one version please."
109fi
110
111version=`echo $version`
112
113if [ ! -d ${root}/$version ]; then
114 err "Version '$version' is not available for $get on $processor"
115fi
116
117# Check we have a directory to install the software
118
119if [ "$installdir" = "" ]; then
120 err "Missing directory to install $get to at end of the command line."
121fi
122if [ "$force" = "0" -a -d $installdir ]; then
123 err "Directory $installdir already exists, need a new directory name, or use -f."
124fi
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)