Gentoo Archives: gentoo-commits

From: Jeroen Roovers <jer@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Wed, 27 Nov 2019 15:07:09
Message-Id: 1574867220.245f417b539760ccf4939630f2c6b826ce34a556.jer@gentoo
1 commit: 245f417b539760ccf4939630f2c6b826ce34a556
2 Author: Jeroen Roovers <jer <AT> gentoo <DOT> org>
3 AuthorDate: Wed Nov 27 14:37:21 2019 +0000
4 Commit: Jeroen Roovers <jer <AT> gentoo <DOT> org>
5 CommitDate: Wed Nov 27 15:07:00 2019 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=245f417b
7
8 eclass/nvidia-driver.eclass: Add nvidia-driver_check(), various tweaks
9
10 - Add nvidia-driver_check() to replace nvidia_drivers_versions_check()
11 duplication in every ebuild
12 - Use EAPI=7 ver_test() instead of versionator.eclass's
13 version_compare()
14 - Replace "video card" with "GPU" in various places.
15 - epatch_user() => eapply_user()
16 - Whitespace and formatting
17 - Use nvidia-driver_* format for eclass functions
18
19 Signed-off-by: Jeroen Roovers <jer <AT> gentoo.org>
20
21 eclass/nvidia-driver.eclass | 87 +++++++++++++++++++++++++++++++--------------
22 1 file changed, 60 insertions(+), 27 deletions(-)
23
24 diff --git a/eclass/nvidia-driver.eclass b/eclass/nvidia-driver.eclass
25 index a8631947748..b71b7a769ae 100644
26 --- a/eclass/nvidia-driver.eclass
27 +++ b/eclass/nvidia-driver.eclass
28 @@ -6,12 +6,12 @@
29 # Jeroen Roovers <jer@g.o>
30 # @AUTHOR:
31 # Original author: Doug Goldstein <cardoe@g.o>
32 -# @BLURB: Provide useful messages for nvidia-drivers based on currently installed Nvidia card
33 +# @BLURB: Provide useful messages for nvidia-drivers
34 # @DESCRIPTION:
35 -# Provide useful messages for nvidia-drivers based on currently installed Nvidia
36 -# card. It inherits versionator.
37 +# Provide useful messages for nvidia-drivers based on currently installed
38 +# Nvidia GPU and Linux kernel.
39
40 -inherit readme.gentoo-r1 versionator
41 +inherit readme.gentoo-r1
42
43 DEPEND="sys-apps/pciutils"
44 RESTRICT="bindist mirror test"
45 @@ -105,10 +105,10 @@ mask_304x=">=x11-drivers/nvidia-drivers-305.0.0"
46 mask_340x=">=x11-drivers/nvidia-drivers-341.0.0"
47 mask_390x=">=x11-drivers/nvidia-drivers-391.0.0"
48
49 -# @FUNCTION: nvidia-driver-get-card
50 +# @FUNCTION: nvidia-driver_get_gpu
51 # @DESCRIPTION:
52 -# Retrieve the PCI device ID for each Nvidia video card you have
53 -nvidia-driver-get-card() {
54 +# Retrieve the PCI device ID for each Nvidia GPU you have
55 +nvidia-driver_get_gpu() {
56 local NVIDIA_CARD=$(
57 [ -x /usr/sbin/lspci ] && /usr/sbin/lspci -d 10de: -n \
58 | awk -F'[: ]' '/ 03[0-9][0-9]: /{print $6}'
59 @@ -121,48 +121,48 @@ nvidia-driver-get-card() {
60 fi
61 }
62
63 -nvidia-driver-get-mask() {
64 - local NVIDIA_CARDS="$(nvidia-driver-get-card)"
65 - local card drv
66 +nvidia-driver_get_mask() {
67 + local nvidia_gpus="$(nvidia-driver_get_gpu)"
68 + local nvidia_gpu drv
69
70 - for card in ${NVIDIA_CARDS}; do
71 + for nvidia_gpu in ${nvidia_gpus}; do
72 for drv in ${drv_71xx}; do
73 - if [ "x${card}" = "x${drv}" ]; then
74 + if [ "x${nvidia_gpu}" = "x${drv}" ]; then
75 echo "${mask_71xx}"
76 return 0
77 fi
78 done
79
80 for drv in ${drv_96xx}; do
81 - if [ "x${card}" = "x${drv}" ]; then
82 + if [ "x${nvidia_gpu}" = "x${drv}" ]; then
83 echo "${mask_96xx}"
84 return 0
85 fi
86 done
87
88 for drv in ${drv_173x}; do
89 - if [ "x${card}" = "x${drv}" ]; then
90 + if [ "x${nvidia_gpu}" = "x${drv}" ]; then
91 echo "${mask_173x}"
92 return 0
93 fi
94 done
95
96 for drv in ${drv_304x}; do
97 - if [ "x${card}" = "x${drv}" ]; then
98 + if [ "x${nvidia_gpu}" = "x${drv}" ]; then
99 echo "${mask_304x}"
100 return 0
101 fi
102 done
103
104 for drv in ${drv_340x}; do
105 - if [ "x${card}" = "x${drv}" ]; then
106 + if [ "x${nvidia_gpu}" = "x${drv}" ]; then
107 echo "${mask_340x}"
108 return 0
109 fi
110 done
111
112 for drv in ${drv_390x}; do
113 - if [ "x${card}" = "x${drv}" ]; then
114 + if [ "x${nvidia_gpu}" = "x${drv}" ]; then
115 echo "${mask_390x}"
116 return 0
117 fi
118 @@ -173,23 +173,22 @@ nvidia-driver-get-mask() {
119 return 1
120 }
121
122 -# @FUNCTION: nvidia-driver-check-warning
123 +# @FUNCTION: nvidia-driver_check_gpu
124 # @DESCRIPTION:
125 -# Prints out a warning if the driver does not work w/ the installed video card
126 -nvidia-driver-check-warning() {
127 - local NVIDIA_MASK="$(nvidia-driver-get-mask)"
128 +# Prints out a warning if the driver does not work w/ the installed video nvidia_gpu
129 +nvidia-driver_check_gpu() {
130 + local NVIDIA_MASK="$(nvidia-driver_get_mask)"
131
132 if [ -n "${NVIDIA_MASK}" ]; then
133 - version_compare "${NVIDIA_MASK##*-}" "${PV}"
134 - if [ x"${?}" = x1 ]; then
135 + if ! ver_test "${NVIDIA_MASK##*-}" -eq "${PV}" ; then
136 ewarn "***** WARNING *****"
137 ewarn
138 ewarn "You are currently installing a version of nvidia-drivers that is"
139 - ewarn "known not to work with a video card you have installed on your"
140 - ewarn "system. If this is intentional, please ignore this. If it is not"
141 - ewarn "please perform the following steps:"
142 + ewarn "known not to work with a GPU you have installed on your system."
143 + ewarn "If this is intentional, please ignore this. If it is not please"
144 + ewarn "perform the following steps:"
145 ewarn
146 - ewarn "Add the following mask entry to /etc/portage/package.mask by"
147 + ewarn "Add the following mask entry to the local package.mask file:"
148 if [ -d "${ROOT}/etc/portage/package.mask" ]; then
149 ewarn "echo \"${NVIDIA_MASK}\" > /etc/portage/package.mask/nvidia-drivers"
150 else
151 @@ -204,3 +203,37 @@ nvidia-driver-check-warning() {
152 fi
153 fi
154 }
155 +
156 +nvidia-driver_check_kernel() {
157 + if kernel_is ge $(ver_cut 1 ${NV_KV_MAX_PLUS}) $(ver_cut 2 ${NV_KV_MAX_PLUS}); then
158 + ewarn "Gentoo supports kernels which are supported by NVIDIA"
159 + ewarn "which are limited to the following kernels:"
160 + ewarn "<sys-kernel/gentoo-sources-${NV_KV_MAX_PLUS}"
161 + ewarn "<sys-kernel/vanilla-sources-${NV_KV_MAX_PLUS}"
162 + ewarn ""
163 + ewarn "You are free to utilize eapply_user to provide whatever"
164 + ewarn "support you feel is appropriate, but will not receive"
165 + ewarn "support as a result of those changes."
166 + ewarn ""
167 + ewarn "Do not file a bug report about this."
168 + ewarn ""
169 + fi
170 +
171 + check_extra_config
172 +}
173 +
174 +nvidia-driver_check() {
175 + if use amd64 && has_multilib_profile && \
176 + [ "${DEFAULT_ABI}" != "amd64" ]; then
177 + eerror "This ebuild doesn't currently support changing your default ABI"
178 + die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
179 + fi
180 +
181 + # Since Nvidia ships many different series of drivers, we need to give the user
182 + # some kind of guidance as to what version they should install. This tries
183 + # to point the user in the right direction but can't be perfect. check
184 + # nvidia-driver.eclass
185 + nvidia-driver_check_gpu
186 +
187 + use kernel_linux && nvidia-driver_check_kernel
188 +}