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
|
#!/bin/sh
set -e
. /usr/share/debconf/confmodule
log () {
logger -t driver-injection-disk "$@"
}
check_deb_arch () {
arch=$(ar p "$1" control.tar.gz | tar zxO ./control | grep '^Architecture:' | sed -e 's/Architecture: *//')
[ "$arch" = all ] || [ "$arch" = "$(udpkg --print-architecture)" ]
}
lsb_info() {
[ -f /etc/lsb-release ] || return 0
grep "^$1=" /etc/lsb-release |\
sed -e 's/\(.*\)/\L\1/;s/^[^=]*=//; s/^"//; s/"$//' || true
}
install_driver_pkg () {
if echo "$1" | grep -q '\.deb$'; then
# cache deb for installation into /target later
mkdir -p /var/cache/firmware/
cp -a "$1" /var/cache/firmware/ || true
udpkg --unpack "/var/cache/firmware/$(basename "$1")"
else
udpkg --unpack "$1"
fi
}
#try to mount possible driver disk
for device in $(list-devices usb-partition); do
label=$(/sbin/vol_id --label $device 2>/dev/null || true)
if [ "$label" = "OEMDRV" ]; then
db_input high driver-injection-disk/load || true
if ! db_go; then
exit 10 # back up
fi
db_get driver-injection-disk/load
if [ "$RET" = true ]; then
if mountmedia driver-injection-disk; then
dir=/media/$(lsb_info DISTRIB_ID)-drivers/$(lsb_info DISTRIB_CODENAME)
for filename in $dir/*.deb $dir/*.udeb $dir/*.ude; do
if [ -f "$filename" ] && check_deb_arch "$filename"; then
log "installing driver package $filename"
install_driver_pkg "$filename" || true
fi
done
fi
umount /media || true
fi
fi
done
|