File: check-for-mismatching-nvidia-module

package info (click to toggle)
nvidia-support 20151021+9
  • links: PTS, VCS
  • area: contrib
  • in suites: buster, sid
  • size: 328 kB
  • sloc: sh: 184; makefile: 6
file content (65 lines) | stat: -rwxr-xr-x 1,897 bytes parent folder | download | duplicates (4)
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
#!/bin/sh
# This script is called from the postinst of all libgl1-nvidia{,-legacy-*}-glx{,-ia32}, 
# xserver-xorg-video-nvidia* and libcuda1{,-ia32} packages.
set -e

. /usr/share/debconf/confmodule

package="nvidia-support"
templates="$(dpkg-query --control-path "$package" templates)"
if [ -n "$templates" ]; then
	db_x_loadtemplatefile "$templates" "$package"
fi


# Upstream version of the newly installed driver.
new_version="$1"

test -n "$new_version" || exit 0

warn_nvidia=""
warn_nouveau=""

# Is an nvidia module currently loaded?
if [ -e /proc/driver/nvidia/version ]; then

	running_version="$(grep NVRM /proc/driver/nvidia/version | awk '{ print $8 }')"

	if [ -z "$running_version" ]; then
		echo "ERROR: Cannot get version of currently loaded NVIDIA module." >&2
	elif [ "$running_version" != "$new_version" ]; then
		warn_nvidia="1"
	fi

fi

# Is the nouveau module currently loaded?
if [ -x /bin/lsmod ] && [ -n "$(lsmod 2>/dev/null | grep nouveau)" ]; then
	warn_nouveau="1"
fi

test -n "$warn_nvidia$warn_nouveau" || exit 0

# Allow preseeding to FALSE.
db_get nvidia-support/check-running-module-version
test "$RET" = "true" || exit 0

# Don't warn multiple times for the same version.
db_get nvidia-support/last-mismatching-module-version
test "$RET" != "$new_version" || exit 0

if [ "$warn_nvidia" ]; then
	db_subst nvidia-support/warn-mismatching-module-version running-version "$running_version"
	db_subst nvidia-support/warn-mismatching-module-version new-version "$new_version"
	db_fset nvidia-support/warn-mismatching-module-version seen false
	db_input high nvidia-support/warn-mismatching-module-version || true
fi
if [ "$warn_nouveau" ]; then
	db_fset nvidia-support/warn-nouveau-module-loaded seen false
	db_input high nvidia-support/warn-nouveau-module-loaded || true
fi
db_go || true
db_set nvidia-support/last-mismatching-module-version "$new_version"


exit 0