File: nvidia-detect.in

package info (click to toggle)
nvidia-graphics-drivers 340.65-2
  • links: PTS, VCS
  • area: non-free
  • in suites: jessie-kfreebsd
  • size: 130,340 kB
  • sloc: sh: 515,262; ansic: 457; makefile: 386; perl: 31
file content (230 lines) | stat: -rw-r--r-- 7,933 bytes parent folder | download
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
#!/bin/bash
# Based on http://wiki.debian.org/NvidiaGraphicsDrivers?action=AttachFile&do=view&target=nvidia-versions.sh
#
# Copyright © 2008-2011 Filipus Klutiero <chealer@gmail.com>
# Copyright © 2011-2014 Andreas Beckmann <anbe@debian.org>
#
# This package is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This package 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/>
#

if [ "$1" = "--help" ]; then
	echo "Usage: nvidia-detect [PCIID]"
	echo "       Reports the Debian packages supporting the NVIDIA GPU that is"
	echo "       installed on the local system (or given as a PCIID parameter)."
	exit 0
fi

shopt -s compat31 nocasematch 2>/dev/null || { echo "Error: this script only works with bash." && exit; } # Avoid cryptic failure when running dash on this script

# last time the PCI IDs were updated
LATEST="#VERSION#"
PACKAGE=

if [ -z "$1" ]; then

if ! (lspci --version) > /dev/null 2>&1; then
	echo "ERROR: The 'lspci' command was not found. Please install the 'pciutils' package." >&2
	exit 1
fi

NV_DEVICES=$(lspci -mn | awk '{ gsub("\"",""); if ($2 == "0300" && ($3 == "10de" || $3 == "12d2")) { print $1 } }')

if [ -z "$NV_DEVICES" ]; then
	echo "No NVIDIA GPU detected."
	exit 0
fi

echo "Detected NVIDIA GPUs:"
for d in $NV_DEVICES ; do
	lspci -nn -s $d
done

if [ "$(echo $NV_DEVICES | wc -w)" != 1 ]; then
	echo "Several NVIDIA GPUs detected. Checking only the first."
fi

NVGA=$(lspci -mn -s ${NV_DEVICES%% *} | awk '{ gsub("\"",""); print $3 $4 }')

else

	PCIID=$(echo "$1" | sed -rn 's/^(10de)?:?([0-9a-fA-F]{4})$/10de\2/ip')
	if [ -z "$PCIID" ]; then
		echo "Error parsing PCI ID '$1'."
		exit 1
	fi

	echo "Checking driver support for PCI ID [$(echo $PCIID | sed -r 's/(....)(....)/\1:\2/')]"
	NVGA="$PCIID"

fi

IDLISTDIR=/usr/share/nvidia

if grep -q -i $NVGA $IDLISTDIR/nvidia-legacy-71xx.ids 2>/dev/null
then
	VERSIONS[71]=71.86
fi

if grep -q -i $NVGA $IDLISTDIR/nvidia-legacy-96xx.ids 2>/dev/null
then
	VERSIONS[96]=96.43
fi

if grep -q -i $NVGA $IDLISTDIR/nvidia-legacy-173xx.ids 2>/dev/null
then
	VERSIONS[173]=173.14
fi

if grep -q -i $NVGA $IDLISTDIR/nvidia-legacy-304xx.ids 2>/dev/null
then
	VERSIONS[304]=304.123
fi

if grep -q -i $NVGA $IDLISTDIR/nvidia-195.ids 2>/dev/null
then
	VERSIONS[195]=195.36.24
fi

if grep -q -i $NVGA $IDLISTDIR/nvidia-295.ids 2>/dev/null
then
	VERSIONS[295]=295.59
fi

if grep -q -i $NVGA $IDLISTDIR/nvidia-346.ids 2>/dev/null
then
	VERSIONS[346]=346.16
fi

if grep -q -i $NVGA $IDLISTDIR/nvidia.ids 2>/dev/null
then
       	# 999 means current
	VERSIONS[999]=$LATEST
fi


if [[ ${#VERSIONS[*]} == 0 ]]; then
       	echo "Uh oh. Your card is not supported by any driver version up to $LATEST."
	echo "A newer driver may add support for your card."
	echo "Newer driver releases may be available in backports."
	exit 0;
fi

	if grep -q "lenny\|^5" /etc/debian_version;
	then
		if [[ -n ${VERSIONS[173]} ]];
		then
			if [[ -n ${VERSIONS[96]} ]];
			then echo "Your card is supported by all driver versions.";
			else
			echo "Your card is supported by the default drivers.";
			fi;
		elif [[ -n ${VERSIONS[96]} ]]; then
			echo "Your card is only supported up to the 96.43 legacy drivers series. You can use VERSION=\"-legacy-96xx\"";
		else
			if [[ -n ${VERSIONS[71]} ]]; then
				echo "Uh oh. Your card is only supported by the 71.86 legacy drivers series, which is not in any current Debian suite.";
			else
				echo "Uh oh. Your card is only supported by the current drivers series, which is only in Squeeze.";
			fi;
		fi;
	elif grep -q "squeeze\|^6" /etc/debian_version;
	then
		if [[ -n ${VERSIONS[195]} ]]; then
			if [[ -n ${VERSIONS[173]} ]]; then
				if [[ -n ${VERSIONS[96]} ]]; then
				       	echo "Your card is supported by all driver versions.";
				else
					echo "Your card is supported by the default drivers and version 173.";
				fi;
			else
				echo "Your card is supported by the default drivers.";
			fi;
			PACKAGE="nvidia-glx"
		elif [[ -n ${VERSIONS[295]} ]]; then
			echo "Your card is only supported by the updated drivers from squeeze-backports."
			echo "See http://backports.debian.org for instructions how to use backports."
			PACKAGE="nvidia-glx/squeeze-backports"
		elif [[ -n ${VERSIONS[173]} ]]; then
			echo "Your card is only supported up to the 173.14 legacy drivers series.";
			PACKAGE="nvidia-glx-legacy-173xx"
		elif [[ -n ${VERSIONS[96]} ]]; then
			echo "Your card is only supported up to the 96.43 legacy drivers series.";
			PACKAGE="nvidia-glx-legacy-96xx"
		elif [[ -n ${VERSIONS[999]} ]]; then
			echo "Uh oh. Your card is only supported by a newer version of the current drivers series.";
		else
			echo "Uh oh. Your card is only supported by the 71.86 legacy drivers series, which is not in any current Debian suite.";
		fi;
	elif grep -q "wheezy\|^7" /etc/debian_version;
	then
		if [[ -n ${VERSIONS[304]} ]]; then
			if [[ -n ${VERSIONS[173]} ]]; then
				if [[ -n ${VERSIONS[96]} ]]; then
				       	echo "Your card is supported by all driver versions.";
				else
					echo "Your card is supported by the default drivers and legacy driver series 173.";
				fi;
			else
				echo "Your card is supported by the default drivers.";
			fi;
			PACKAGE="nvidia-glx"
		elif [[ -n ${VERSIONS[999]} ]]; then
			echo "Your card is only supported by the updated drivers from wheezy-backports."
			echo "See http://backports.debian.org for instructions how to use backports."
			PACKAGE="nvidia-driver/wheezy-backports"
		elif [[ -n ${VERSIONS[173]} ]]; then
			echo "Your card is only supported up to the 173.14 legacy drivers series.";
			PACKAGE="nvidia-glx-legacy-173xx"
		elif [[ -n ${VERSIONS[96]} ]]; then
			echo "Your card is only supported up to the 96.43 legacy drivers series.";
			PACKAGE="nvidia-glx-legacy-96xx"
		else
			echo "Uh oh. Your card is only supported by the 71.86 legacy drivers series, which is not in any current Debian suite.";
		fi;
	elif grep -q "jessie\|^8" /etc/debian_version
	then
		if [[ -n ${VERSIONS[999]} ]]; then
			if [[ -n ${VERSIONS[304]} ]]; then
				echo "Your card is supported by the default drivers and legacy driver series 304."
			else
				echo "Your card is supported by the default drivers."
			fi
			PACKAGE="nvidia-driver"
		elif [[ -n ${VERSIONS[304]} ]]; then
			echo "Your card is only supported up to the 304 legacy drivers series."
			PACKAGE="nvidia-legacy-304xx-driver"
		elif [[ -n ${VERSIONS[346]} ]]; then
			echo "Your card is only supported by a newer driver that will be made available in jessie-backports."
			echo "See http://backports.debian.org for instructions how to use backports."
			echo "You may also find driver packages in experimental."
			PACKAGE="nvidia-driver/jessie-backports"
		elif [[ -n ${VERSIONS[173]} ]]; then
			echo "Uh oh. Your card is only supported by the 173.14 legacy drivers series, which is not in any current Debian suite."
		elif [[ -n ${VERSIONS[96]} ]]; then
			echo "Uh oh. Your card is only supported by the 96.43 legacy drivers series, which is not in any current Debian suite."
		else
			echo "Uh oh. Your card is only supported by the 71.86 legacy drivers series, which is not in any current Debian suite."
		fi
	elif grep -q "^4" /etc/debian_version;
	then
		echo "Uh oh. You are running Etch, which is no longer supported.";
	else
		echo "Uh oh. Failed to identify your Debian suite.";
	fi;

if [ -n "$PACKAGE" ]; then
	echo "It is recommended to install the"
	echo "    $PACKAGE"
	echo "package."
fi