forked from AdaCore/gnatcoverage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doinstall.tmplt
executable file
·264 lines (197 loc) · 5.41 KB
/
doinstall.tmplt
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
#! /bin/sh
#
# GNATcoverage binary distribution installation script
# Copyright (c) 2011-2020, Free Software Foundation
#
####################
# Global variables #
####################
version="<version>"
machine="<machine>"
prefix="/usr/local/gnat"
TMPDIR=${TEMP:=`pwd`}
tmpout="${TMPDIR}/install.log"
tmpvalue="${TMPDIR}/install.$$"
#####################################################
# Says that a given command was not found and exits #
#####################################################
command_not_found () {
cmd="$1"
cat << EOF
The $cmd command could not be found on your PATH. It is required to have
it in your PATH in order to install successfully $long_qualifier. Please
add the directory were $cmd can be found on your PATH or contact your
system administrator to have it installed in a standard location.
EOF
exit 1
}
#########################
# Check the environment #
#########################
check_env () {
# type returns 0 on success, >0 on failure
for cmd in mkdir tar tee cat clear; do
type_out=`type $cmd 2>&1`
type_rv=$?
if [ $type_rv -ne 0 ]; then
command_not_found $cmd
fi
done
}
###################################
# Set the production descriptions #
###################################
set_qualifier () {
qualifier="GNATcoverage"
long_qualifier="$qualifier"
}
###########################################
# Ask for the base installation directory #
###########################################
ask_base_prefix() {
cat << EOF
In which directory do you want to install $qualifier ? [$prefix]:
EOF
read ans_prefix
if [ "x$ans_prefix" != "x" ]; then
prefix=$ans_prefix
fi
}
#####################################
# Install GNATcoverage into $prefix #
#####################################
standard_installation () {
# Makes the real installation
mkdir -p $prefix
(tar cf - bin lib libexec share \
| (cd $prefix; tar xf -)) 2>&1 | tee $tmpout
# Check that installation was OK
error_exit=false
if [ ! -f "$tmpout" ]; then
error_exit=true
cat << EOF
An error occurred during installation. The installation log file,
$tmpout, could not be written.
EOF
elif [ -s "$tmpout" ]; then
error_exit=true
cat << EOF
An error occurred during installation. You can find a complete log
of the installation in $tmpout.
EOF
fi
if $error_exit; then
cat << EOF
Don't hesitate to send a message to [email protected]
with you customer number on the subject line if you have any
question about this installation process.
EOF
exit 1
fi
case $machine in
*) clear ;;
esac
cat << EOF
$qualifier is now installed. To launch it, you must put
$prefix/bin
in front of your PATH environment variable. The following
commands enable you to do this:
PATH=$prefix/bin:\$PATH; export PATH (Bourne shell)
setenv PATH $prefix/bin:\$PATH (C shell)
Thank you for installing $long_qualifier!
EOF
}
######################
# #
# Start installation #
# #
######################
set_qualifier
check_env
# This avoids some problems when cd prints the new directory when CDPATH
# is defined
unset CDPATH
if [ $# -eq 1 ]; then
if [ "$1" = "--help" ]; then
cat << EOF
Usage: $0 [install_dir]
When no argument is specified, runs the GNATcoverage installer
interactively, otherwise installs automatically under install_dir.
EOF
else
echo " installing GNATcoverage under $1"
prefix="$1"
standard_installation
fi
exit 0
fi
clear
cat << EOF
This script is provided to perform the installation of the
binary version of the $qualifier package identified as
$version for $machine
This package is maintained by AdaCore, For information on commercial
support please contact [email protected].
Confirmation is required before any write action is taken.
Please press RETURN to continue.
EOF
read dummy
# Ask information for non-standard installation
confirm="KO"
curdir=`pwd`
while [ "x$confirm" != "xOK" ]; do
# Ask the base directory for installation
clear
cat << EOF
To install $qualifier, you need to specify a base directory.
All the files will be installed in subdirectories of this base.
Important Note: You should not use ~ or ~username wildcards
when specifying this directory name.
EOF
ask_base_prefix
while [ "$prefix" = "$curdir" ]; do
#target base directory cannot be the same as the current dir
cat << EOF
The target base directory cannot be the current directory.
Please enter another directory name.
EOF
ask_base_prefix
done
# Ask confirmation
cat << EOF
The $long_qualifier installation directory will be:
$prefix
Is this correct ? Type 'Y' if so, otherwise type 'N' and you'll
be prompted for another directory name.
Do you want to continue ? [yY|nN]:
EOF
read confirm
case $confirm in
[yY])
confirm="OK"
;;
*)
confirm="KO"
;;
esac
done
# Ask confirmation
clear
cat << EOF
$long_qualifier is now about to be installed in
$prefix.
Type 'Y' if you want to proceed with installation or any other key
if you wish to abort.
Do you want to proceed with installation ? [yY|nN]:
EOF
read proceed
case $proceed in
[yY]*)
;;
*)
echo "Aborting installation on user request"
exit 0
;;
esac
# Do the real installation
standard_installation