This repository has been archived by the owner on Sep 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-mali-driver
executable file
·315 lines (254 loc) · 6.74 KB
/
update-mali-driver
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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
#!/bin/sh
# Copyright (C) 2015 Heiko Stuebner <[email protected]>
#
# based on update-flashplugin-nonfree
# Copyright (C) 2006-2014 Bart Martens <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set -e
datadir="/usr/lib/mali"
downloadfile=""
downloadurl=""
target=""
installed=none
upstream=none
supported="rockchip,rk3288"
valid_version=no
targetdir=/tmp
#ordered by increasing time, newest last
versions_rockchip_rk3288() {
available_versions="veyron-1.20-r18 veyron-x11-1.20-r22 veyron-x11-1.20-r26"
}
targetdir_rockchip_rk3288() {
targetdir=/usr/lib/mali
}
download_rockchip_rk3288() {
downloadfile="mali-drivers-$target.run"
downloadurl="http://commondatastorage.googleapis.com/chromeos-localmirror/distfiles/$downloadfile"
}
installed_version_rockchip_rk3288() {
targetdir_rockchip_rk3288
curdir=`pwd`
cd $targetdir
versions_rockchip_rk3288
installed=none
set +e
for i in $available_versions; do
sha512sum -c --quiet --strict $datadir/installed-$i.sha512sum >/dev/null 2>&1
if [ "$?" = "0" ]; then
installed=$i
[ "$verbose" != "yes" ] || echo "found installed : $installed"
cd $curdir
return
fi
done
set -e
[ "$verbose" != "yes" ] || echo "found installed : $installed"
cd $curdir
}
upstream_version_rockchip_rk3288() {
versions_rockchip_rk3288
for i in $available_versions; do
upstream=$i
done
}
check_version_rockchip_rk3288() {
versions_rockchip_rk3288
valid_version=no
for i in $available_versions; do
if [ "$i" = "$target" ]; then
valid_version=yes
fi
done
}
return_0() {
return 0
}
trap "return_0" 0
die_hard() {
echo "ERROR: $1" >&2
exit 1
}
[ `whoami` = "root" ] || die_hard "must be root"
show_usage() {
echo "Usage:"
echo " update-mali-driver --install"
echo " update-mali-driver --uninstall"
echo " update-mali-driver --status"
echo "Additional options:"
echo " --verbose"
echo " --quiet"
exit 1
}
getopt_temp=`getopt -o iusfvqn --long install,uninstall,status,fast,verbose,quiet -n 'update-mali-driver' -- "$@"` || show_usage
eval set -- "$getopt_temp" || show_usage
ACTION=none
fast=no
verbose=no
quiet=no
while [ true ]
do
case "$1" in
-i|--install)
ACTION="--install"
shift
;;
-u|--uninstall)
ACTION="--uninstall"
shift
;;
-s|--status)
ACTION="--status"
shift
;;
-f|--fast)
fast=yes
shift
;;
-v|--verbose)
verbose=yes
shift
;;
-q|--quiet)
quiet=yes
shift
;;
--)
shift
break
;;
*)
echo "Internal error!" >&2
exit 1
;;
esac
done
[ "$ACTION" != "none" -a $# -eq 0 ] || show_usage
[ "$quiet" != "yes" ] || verbose=no
[ "$verbose" != "yes" ] || echo "options : $getopt_temp"
UNPACKDIR=`mktemp -d /tmp/mali-driver.XXXXXXXXXX` || die_hard "mktemp failed"
echo "$UNPACKDIR" | grep -q "^/tmp/mali-driver\." || die_hard "paranoia"
chown nobody $UNPACKDIR
cd "$UNPACKDIR" || die_hard "cd failed"
[ "$verbose" != "yes" ] || echo "temporary directory: $UNPACKDIR"
do_cleanup() {
[ "$verbose" != "yes" ] || echo "cleaning up temporary directory $UNPACKDIR ..."
cd /
echo "$UNPACKDIR" | grep -q "^/tmp/mali-driver\." || die_hard "paranoia"
rm -rf "$UNPACKDIR"
}
die_hard_with_a_cleanup() {
return_0
do_cleanup
die_hard "$1"
}
trap "die_hard_with_a_cleanup interrupted" INT
if [ ! -f /proc/device-tree/compatible ]; then
die_hard_with_a_cleanup "no devicetree information found"
fi
# find machine type and try to match against supported machines
machine=`xargs --null < /proc/device-tree/compatible`
[ "$verbose" != "yes" ] || echo "this machine $machine"
found=""
for i in $machine; do
for j in $supported; do
if [ "$i" = "$j" ]; then
[ "$verbose" != "yes" ] || echo "found match $j"
found=$i
fi
done
done
if [ "x$found" = "x" ]; then
die_hard_with_a_cleanup "no matching driver found"
fi
platform=`echo $found | tr , _`
# version handling
get_installed_version() {
installed_version_$platform
}
get_upstream_version() {
upstream_version_$platform
}
get_targetdir() {
targetdir_$platform
}
check_version() {
valid_version=no
check_version_$platform
}
wgetquiet=' -nv -q '
wgetalways=' -nd -P . '
wgetprogress=' -v --progress=dot:default '
case "$ACTION" in
--install)
[ "$verbose" != "yes" ] || echo "selected action = $ACTION"
get_installed_version
if [ -z "$MALI_TARGET_VERSION" ]; then
get_upstream_version
target="$upstream"
else
target="$MALI_TARGET_VERSION"
check_version
if [ "$valid_version" != "yes" ]; then
die_hard_with_a_cleanup "$target is not a valid version"
fi
fi
if [ "$installed" = "$target" ]; then
echo "already uptodate at version $target"
do_cleanup
exit 0
fi
wgetoptions="$wgetquiet $wgetalways"
[ "$verbose" != "yes" ] || wgetoptions="$wgetalways $wgetprogress"
[ "$verbose" != "yes" ] || echo "wgetoptions=$wgetoptions"
# get download informations
download_$platform
[ "$verbose" != "yes" ] || echo "downloading $downloadurl ..."
HOME=/root \
wget $wgetoptions $downloadurl \
|| [ "$verbose" != "yes" ] || echo "wget failed to download $downloadurl" >&2
# extract downloadfile
sudo -u nobody sh $downloadfile
sha512sum -c --strict $datadir/$target.sha512sum || die_hard_with_a_cleanup "checksum does not match"
get_targetdir
for i in `cat $datadir/veyron-x11-1.20-r22.sha512sum | cut -d "*" -f 2`; do
[ "$verbose" != "yes" ] || echo "installing $i to $targetdir"
cp -a $i $targetdir
done
[ "$verbose" != "yes" ] || echo "end of action $ACTION"
;;
--uninstall)
[ "$verbose" != "yes" ] || echo "selected action = $ACTION"
[ "$verbose" != "yes" ] || echo "removing files ..."
get_installed_version
for i in `cat $datadir/installed-veyron-x11-1.20-r22.sha512sum | cut -d "*" -f 2`; do
[ "$verbose" != "yes" ] || echo "removing $i from $targetdir"
rm $targetdir/$i
done
[ "$verbose" != "yes" ] || echo "end of action $ACTION"
;;
--status)
[ "$verbose" != "yes" ] || echo "selected action = $ACTION"
get_installed_version
echo "Mali driver version installed on this system : $installed"
get_upstream_version
echo "Mali driver version available on upstream site: $upstream"
[ "$verbose" != "yes" ] || echo "end of action $ACTION"
;;
*)
do_cleanup
show_usage
;;
esac
do_cleanup
[ "$verbose" != "yes" ] || echo "end of update-mali-driver"