-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathdoinstall
executable file
·203 lines (165 loc) · 5.5 KB
/
doinstall
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
#!/bin/sh
## Read the base directory (absolute path name)
## Sets the variable $basedir
ask_basedir() {
clear
default_dir=`type gnatmake 2>/dev/null| cut -d' ' -f3`
default_dir=`dirname "$default_dir" 2>/dev/null`
if [ "$default_dir" != "" -a "$default_dir" != "." -a "$default_dir" != "/usr/bin" ]; then
default_dir=`cd "$default_dir/.."; pwd`
cat <<EOF
GNAT has been found in $default_dir.
Do you want to install GNAT Studio there too? Hit RETURN if yes or enter
the name of the directory in which GNAT Studio should be installed:
EOF
else
default_dir=/opt/gnatstudio
cat <<EOF
Enter the name of the directory in which you would like to install GNAT Studio
EOF
fi
while [ "$basedir" = "" ]; do
printf "[$default_dir] "
read basedir
if [ "$basedir" = "" ]; then
basedir="$default_dir"
fi
if echo "$basedir" | grep -E -e "^[/~]" >/dev/null; then
true
else
basedir=`pwd`/"$basedir"
fi
done
# Suppress the final / in basedir
basedir=`echo "$basedir" | sed -e 's/\/$//'`
# Check that we have permission to write in $basedir
if test -d "$basedir"; then
if test -w "$basedir"; then
if [ -x "$basedir/bin/gnatstudio" ]; then
echo " $basedir/bin/gnatstudio found."
printf " Do you want to overwrite existing installation [Y/n] ? "
read x
if [ "$x" = "n" -o "$x" = "N" ]; then
echo "Aborting the installation process"
exit
fi
fi
else
echo "You do not have permission to write in $basedir"
echo "Please check whether you should be root to install in that directory."
echo "Aborting the installation process"
exit
fi
else
echo ""
echo " Directory $basedir does not exist."
printf " Do you want to create it [Y/n] ? "
read x
if [ "$x" = "n" -o "$x" = "N" ]; then
echo "Aborting the installation process"
exit
fi
if ! mkdir -p "$basedir" 2>/dev/null ; then
echo "You do not have permission to write in $basedir"
echo "Please check whether you should be root to install in that directory."
echo "Aborting the installation process"
exit
fi
fi
echo ""
printf " Are you now ready to proceed with the installation [Y/n] ? "
read x
if [ "$x" = "n" -o "$x" = "N" ]; then
echo "Aborting the installation process"
exit
fi
}
##################################
## Do the actual installation
##################################
install_binaries() {
echo "Installing the binaries ...."
cd "$basedir"
rm -rf "$basedir/lib"/gnatstudio* "$basedir/bin/gnatstudio" "$basedir/bin/gnatstudio_exe"
rm -f "$basedir/share/gnatstudio/plug-ins"/*.pyc
rm -f "$basedir/share/gnatstudio/plug-ins/open_file.py"
rm -f "$basedir/share/gnatstudio/plug-ins/spark.py"
rm -f "$basedir/share/gnatstudio/library"/*.py*
rm -f "$basedir/share/gnatstudio/library"/*.xml
rm -rf "$basedir/share/gnatstudio/templates"
for f in "$basedir/share/gnatstudio/plug-ins"/*.xml \
"$basedir/share/gnatstudio/plug-ins"/*.py; do
grep -E -e '(<documentation_file>|<gnat_examples>)' "$f" >/dev/null 2>&1
if [ $? -ne 0 ]; then
rm -f "$f"
fi
done
# Do the installation through tar, to preserve symbolic links
# We also explicitly work on specific directories to avoid
# copying junk files
(cd "$current_dir" && tar cf - bin etc lib libexec share) | tar xf -
# XXX It is not clear whether this code is needed, both directories
# are not present
for d in etc/pango etc/gtk-2.0; do
if [ -d "$d" ]; then
for f in "$d"/*; do
sed -e "s^@PREFIX@^$basedir^g" < "$f" > "$f.new"
mv "$f.new" "$f"
done
fi
done
# Update gdkpixbuf loaders cache
LD_LIBRARY_PATH=$basedir/lib/gnatstudio:$LD_LIBRARY_PATH \
GDK_PIXBUF_MODULE_FILE=$basedir/lib/gnatstudio/gdk-pixbuf-2.0/2.10.0/loaders.cache \
GDK_PIXBUF_MODULEDIR=$basedir/lib/gnatstudio/gdk-pixbuf-2.0/2.10.0/loaders \
$basedir/bin/gdk-pixbuf-query-loaders --update-cache
# Update immodules cache
LD_LIBRARY_PATH=$basedir/lib/gnatstudio:$LD_LIBRARY_PATH \
GTK_IM_MODULE_FILE=$basedir/lib/gnatstudio/gtk-3.0/3.0.0/immodules.cache \
GTK_PATH=$basedir/lib/gnatstudio/gtk-3.0 \
$basedir/bin/gtk-query-immodules-3.0 --update-cache
}
##
## Write the end message
##
end_message() {
clear
cat <<EOF
GNAT Studio has now been installed on your machine.
You can start it with the following command:
$basedir/bin/gnatstudio
Make sure that GNAT Studio is in your path by typing one of the following
commands:
for csh and tcsh shells:
setenv PATH "$basedir/bin:\$PATH"
for sh, bash, ksh and zsh:
PATH="$basedir/bin:\$PATH"; export PATH
EOF
}
current_dir=`cd "$(dirname "$0")"; pwd`
if [ $# -eq 1 ]; then
if [ "$1" = "--help" ]; then
cat << EOF
Usage: $0 [install_dir]
When no argument is specified, runs the GNAT Studio installer
interactively, otherwise installs automatically under install_dir.
EOF
else
echo " installing GNAT Studio under $1"
basedir="$1"
mkdir -p "$basedir" && install_binaries && end_message
fi
exit 0
fi
clear
cat <<EOF
This script is provided to simplify the installation of GNAT Studio.
You will be asked for confirmation before the actual installation is
done. You can break out of this script at any time before this.
Hit RETURN to continue.
EOF
read x
## Main program
ask_basedir
install_binaries
end_message