Gentoo Archives: gentoo-commits

From: Ionen Wolkens <ionen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: x11-drivers/nvidia-drivers/
Date: Tue, 28 Dec 2021 13:14:38
Message-Id: 1640697151.1df072f63f101fc09d4c668156a27f5755acda26.ionen@gentoo
1 commit: 1df072f63f101fc09d4c668156a27f5755acda26
2 Author: Ionen Wolkens <ionen <AT> gentoo <DOT> org>
3 AuthorDate: Tue Dec 28 12:00:47 2021 +0000
4 Commit: Ionen Wolkens <ionen <AT> gentoo <DOT> org>
5 CommitDate: Tue Dec 28 13:12:31 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1df072f6
7
8 x11-drivers/nvidia-drivers: sync 460.91.03 ebuild with others
9
10 460.91.03 is unfortunately known needed for (at least) a few laptop
11 users, issues varying between not able to control backlight or not
12 seeing anything displayed at all (bug #780126 and bug #809482, along
13 with several threads on NVIDIA forums complaining about this).
14
15 Can't be kept eternally given NVIDIA shows no sign of continued 460
16 support and it requires xorg-1.20 plus <=5.10 LTS kernels (unlike even
17 the 390.xx branch) -- but, meanwhile, update ebuild to be like the
18 others and easier to maintain. Fortunately no known security issues.
19
20 Let's hope 470/495+ will receive fixes before removal is necessary
21 (perhaps to cleanup old xorg or security concerns), feedback from
22 users welcome to know when it works as expected or if anything else
23 can do (own hardware is not affected, so can't test).
24
25 Bug: https://bugs.gentoo.org/780126
26 Bug: https://bugs.gentoo.org/809482
27 Signed-off-by: Ionen Wolkens <ionen <AT> gentoo.org>
28
29 .../nvidia-drivers-460.91.03-r2.ebuild | 400 +++++++++++++++++++++
30 1 file changed, 400 insertions(+)
31
32 diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-460.91.03-r2.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-460.91.03-r2.ebuild
33 new file mode 100644
34 index 000000000000..655467d6bb9f
35 --- /dev/null
36 +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-460.91.03-r2.ebuild
37 @@ -0,0 +1,400 @@
38 +# Copyright 1999-2021 Gentoo Authors
39 +# Distributed under the terms of the GNU General Public License v2
40 +
41 +EAPI=7
42 +
43 +MODULES_OPTIONAL_USE="driver"
44 +inherit desktop flag-o-matic linux-mod multilib readme.gentoo-r1 \
45 + systemd toolchain-funcs unpacker
46 +
47 +NV_KERNEL_MAX="5.13"
48 +NV_URI="https://download.nvidia.com/XFree86/"
49 +
50 +DESCRIPTION="NVIDIA Accelerated Graphics Driver"
51 +HOMEPAGE="https://www.nvidia.com/download/index.aspx"
52 +SRC_URI="
53 + amd64? ( ${NV_URI}Linux-x86_64/${PV}/NVIDIA-Linux-x86_64-${PV}.run )
54 + arm64? ( ${NV_URI}Linux-aarch64/${PV}/NVIDIA-Linux-aarch64-${PV}.run )
55 + $(printf "${NV_URI}%s/%s-${PV}.tar.bz2 " \
56 + nvidia-{installer,modprobe,persistenced,settings,xconfig}{,})"
57 +# nvidia-installer is unused but here for GPL-2's "distribute sources"
58 +S="${WORKDIR}"
59 +
60 +LICENSE="NVIDIA-r2 BSD BSD-2 GPL-2 MIT ZLIB curl openssl"
61 +SLOT="0/${PV%%.*}"
62 +KEYWORDS="-* ~amd64"
63 +IUSE="+X abi_x86_32 abi_x86_64 +driver persistenced static-libs +tools"
64 +
65 +COMMON_DEPEND="
66 + acct-group/video
67 + persistenced? (
68 + acct-user/nvpd
69 + net-libs/libtirpc:=
70 + )
71 + tools? (
72 + dev-libs/atk
73 + dev-libs/glib:2
74 + dev-libs/jansson:=
75 + media-libs/harfbuzz:=
76 + x11-libs/cairo
77 + x11-libs/gdk-pixbuf:2
78 + x11-libs/gtk+:3
79 + x11-libs/libX11
80 + x11-libs/libXext
81 + x11-libs/libXxf86vm
82 + x11-libs/pango
83 + )"
84 +RDEPEND="
85 + ${COMMON_DEPEND}
86 + X? (
87 + media-libs/libglvnd[X,abi_x86_32(-)?]
88 + x11-libs/libX11[abi_x86_32(-)?]
89 + x11-libs/libXext[abi_x86_32(-)?]
90 + )"
91 +DEPEND="
92 + ${COMMON_DEPEND}
93 + static-libs? (
94 + x11-libs/libX11
95 + x11-libs/libXext
96 + )
97 + tools? (
98 + media-libs/libglvnd
99 + sys-apps/dbus
100 + x11-base/xorg-proto
101 + x11-libs/libXrandr
102 + x11-libs/libXv
103 + x11-libs/libvdpau
104 + )"
105 +BDEPEND="
106 + sys-devel/m4
107 + virtual/pkgconfig"
108 +PDEPEND="X? ( <x11-base/xorg-server-1.21 )"
109 +
110 +QA_PREBUILT="opt/bin/* usr/lib*"
111 +
112 +PATCHES=(
113 + "${FILESDIR}"/nvidia-modprobe-390.141-uvm-perms.patch
114 + "${FILESDIR}"/nvidia-settings-390.144-desktop.patch
115 + "${FILESDIR}"/nvidia-settings-390.144-no-gtk2.patch
116 + "${FILESDIR}"/nvidia-settings-390.144-raw-ldflags.patch
117 +)
118 +
119 +pkg_setup() {
120 + use driver || return
121 +
122 + local CONFIG_CHECK="
123 + PROC_FS
124 + ~DRM_KMS_HELPER
125 + ~SYSVIPC
126 + ~!DRM_SIMPLEDRM
127 + ~!LOCKDEP
128 + !DEBUG_MUTEXES"
129 + local ERROR_DRM_KMS_HELPER="CONFIG_DRM_KMS_HELPER: is not set but needed for Xorg auto-detection
130 + of drivers (no custom config), and for wayland / nvidia-drm.modeset=1.
131 + Cannot be directly selected in the kernel's menuconfig, and may need
132 + selection of a DRM device even if unused, e.g. CONFIG_DRM_AMDGPU=m or
133 + DRM_I915=y, DRM_NOUVEAU=m also acceptable if a module and not built-in.
134 + Note: DRM_SIMPLEDRM may cause issues and is better disabled for now."
135 +
136 + use amd64 && kernel_is -ge 5 8 && CONFIG_CHECK+=" X86_PAT" #817764
137 +
138 + MODULE_NAMES="
139 + nvidia(video:kernel)
140 + nvidia-drm(video:kernel)
141 + nvidia-modeset(video:kernel)
142 + nvidia-uvm(video:kernel)"
143 +
144 + linux-mod_pkg_setup
145 +
146 + [[ ${MERGE_TYPE} == binary ]] && return
147 +
148 + BUILD_PARAMS='NV_VERBOSE=1 IGNORE_CC_MISMATCH=yes SYSSRC="${KV_DIR}" SYSOUT="${KV_OUT_DIR}"'
149 + BUILD_TARGETS="modules"
150 +
151 + if linux_chkconfig_present CC_IS_CLANG; then
152 + ewarn "Warning: building ${PN} with a clang-built kernel is experimental"
153 +
154 + BUILD_PARAMS+=' CC=${CHOST}-clang'
155 + if linux_chkconfig_present LD_IS_LLD; then
156 + BUILD_PARAMS+=' LD=ld.lld'
157 + if linux_chkconfig_present LTO_CLANG_THIN; then
158 + # kernel enables cache by default leading to sandbox violations
159 + BUILD_PARAMS+=' ldflags-y=--thinlto-cache-dir= LDFLAGS_MODULE=--thinlto-cache-dir='
160 + fi
161 + fi
162 + fi
163 +
164 + if kernel_is -gt ${NV_KERNEL_MAX/./ }; then
165 + ewarn "Kernel ${KV_MAJOR}.${KV_MINOR} is either known to break this version of ${PN}"
166 + ewarn "or was not tested with it. It is recommended to use one of:"
167 + ewarn " <=sys-kernel/gentoo-kernel-${NV_KERNEL_MAX}"
168 + ewarn " <=sys-kernel/gentoo-sources-${NV_KERNEL_MAX}"
169 + ewarn "You are free to try or use /etc/portage/patches, but support will"
170 + ewarn "not be given and issues wait until NVIDIA releases a fixed version."
171 + ewarn
172 + ewarn "Do _not_ file a bug report if run into issues."
173 + ewarn
174 + fi
175 +}
176 +
177 +src_prepare() {
178 + # make patches usable across versions
179 + rm nvidia-modprobe && mv nvidia-modprobe{-${PV},} || die
180 + rm nvidia-persistenced && mv nvidia-persistenced{-${PV},} || die
181 + rm nvidia-settings && mv nvidia-settings{-${PV},} || die
182 + rm nvidia-xconfig && mv nvidia-xconfig{-${PV},} || die
183 +
184 + default
185 +
186 + # prevent detection of incomplete kernel DRM support (bug #603818)
187 + sed 's/defined(CONFIG_DRM/defined(CONFIG_DRM_KMS_HELPER/g' \
188 + -i kernel/conftest.sh || die
189 +
190 + sed 's/__USER__/nvpd/' \
191 + nvidia-persistenced/init/systemd/nvidia-persistenced.service.template \
192 + > "${T}"/nvidia-persistenced.service || die
193 +}
194 +
195 +src_compile() {
196 + tc-export AR CC LD OBJCOPY
197 +
198 + NV_ARGS=(
199 + PREFIX="${EPREFIX}"/usr
200 + HOST_CC="$(tc-getBUILD_CC)"
201 + HOST_LD="$(tc-getBUILD_LD)"
202 + NV_USE_BUNDLED_LIBJANSSON=0
203 + NV_VERBOSE=1 DO_STRIP= MANPAGE_GZIP= OUTPUTDIR=out
204 + )
205 +
206 + use driver && linux-mod_src_compile
207 +
208 + emake "${NV_ARGS[@]}" -C nvidia-modprobe
209 + use persistenced && emake "${NV_ARGS[@]}" -C nvidia-persistenced
210 + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig
211 +
212 + if use tools; then
213 + # cflags: avoid noisy logs, only use here and set first to let override
214 + # ldflags: abi currently needed if LD=ld.lld
215 + CFLAGS="-Wno-deprecated-declarations ${CFLAGS}" \
216 + RAW_LDFLAGS="$(get_abi_LDFLAGS) $(raw-ldflags)" \
217 + emake "${NV_ARGS[@]}" -C nvidia-settings
218 + elif use static-libs; then
219 + emake "${NV_ARGS[@]}" -C nvidia-settings/src out/libXNVCtrl.a
220 + fi
221 +}
222 +
223 +src_install() {
224 + local libdir=$(get_libdir) libdir32=$(ABI=x86 get_libdir)
225 +
226 + NV_ARGS+=( DESTDIR="${D}" LIBDIR="${ED}"/usr/${libdir} )
227 +
228 + local -A paths=(
229 + [APPLICATION_PROFILE]=/usr/share/nvidia
230 + [CUDA_ICD]=/etc/OpenCL/vendors
231 + [EGL_EXTERNAL_PLATFORM_JSON]=/usr/share/egl/egl_external_platform.d
232 + [GLVND_EGL_ICD_JSON]=/usr/share/glvnd/egl_vendor.d
233 + [VULKAN_ICD_JSON]=/usr/share/vulkan
234 + [XORG_OUTPUTCLASS_CONFIG]=/usr/share/X11/xorg.conf.d
235 +
236 + [GLX_MODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules/extensions
237 + [GLX_MODULE_SYMLINK]=/usr/${libdir}/xorg/modules
238 + [XMODULE_SHARED_LIB]=/usr/${libdir}/xorg/modules
239 + )
240 +
241 + local skip_files=(
242 + $(usex X '' '
243 + libGLX_nvidia libglxserver_nvidia
244 + libnvidia-ifr
245 + nvidia_icd.json nvidia_layers.json')
246 + libGLX_indirect # non-glvnd unused fallback
247 + libnvidia-gtk nvidia-{settings,xconfig} # built from source
248 + libnvidia-egl-wayland 10_nvidia_wayland # gui-libs/egl-wayland
249 + )
250 + local skip_modules=(
251 + $(usex X '' 'nvfbc vdpau xdriver')
252 + installer nvpd # handled separately / built from source
253 + )
254 + local skip_types=(
255 + GLVND_LIB GLVND_SYMLINK EGL_CLIENT.\* GLX_CLIENT.\* # media-libs/libglvnd
256 + OPENCL_WRAPPER.\* # virtual/opencl
257 + DOCUMENTATION DOT_DESKTOP .\*_SRC DKMS_CONF # handled separately / unused
258 + )
259 +
260 + local DOCS=(
261 + README.txt NVIDIA_Changelog supported-gpus/supported-gpus.json
262 + nvidia-settings/doc/{FRAMELOCK,NV-CONTROL-API}.txt
263 + )
264 + local HTML_DOCS=( html/. )
265 + einstalldocs
266 +
267 + local DISABLE_AUTOFORMATTING=yes
268 + local DOC_CONTENTS="\
269 +Trusted users should be in the 'video' group to use NVIDIA devices.
270 +You can add yourself by using: gpasswd -a my-user video
271 +
272 +See '${EPREFIX}/etc/modprobe.d/nvidia.conf' for modules options.\
273 +$(use amd64 && usex abi_x86_32 '' "
274 +
275 +Note that without USE=abi_x86_32 on ${PN}, 32bit applications
276 +(typically using wine / steam) will not be able to use GPU acceleration.")
277 +
278 +For general information on using ${PN}, please see:
279 +https://wiki.gentoo.org/wiki/NVIDIA/nvidia-drivers"
280 + readme.gentoo_create_doc
281 +
282 + if use driver; then
283 + linux-mod_src_install
284 +
285 + insinto /etc/modprobe.d
286 + newins "${FILESDIR}"/nvidia-470.conf nvidia.conf
287 +
288 + # used for gpu verification with binpkgs (not kept, see pkg_preinst)
289 + insinto /usr/share/nvidia
290 + doins supported-gpus/supported-gpus.json
291 + fi
292 +
293 + emake "${NV_ARGS[@]}" -C nvidia-modprobe install
294 + fowners :video /usr/bin/nvidia-modprobe #505092
295 + fperms 4710 /usr/bin/nvidia-modprobe
296 +
297 + if use persistenced; then
298 + emake "${NV_ARGS[@]}" -C nvidia-persistenced install
299 + newconfd "${FILESDIR}"/nvidia-persistenced.confd nvidia-persistenced
300 + newinitd "${FILESDIR}"/nvidia-persistenced.initd nvidia-persistenced
301 + systemd_dounit "${T}"/nvidia-persistenced.service
302 + fi
303 +
304 + if use tools; then
305 + emake "${NV_ARGS[@]}" -C nvidia-settings install
306 +
307 + doicon nvidia-settings/doc/nvidia-settings.png
308 + domenu nvidia-settings/doc/nvidia-settings.desktop
309 +
310 + exeinto /etc/X11/xinit/xinitrc.d
311 + newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings
312 + fi
313 +
314 + if use static-libs; then
315 + dolib.a nvidia-settings/src/out/libXNVCtrl.a
316 +
317 + insinto /usr/include/NVCtrl
318 + doins nvidia-settings/src/libXNVCtrl/NVCtrl{Lib,}.h
319 + fi
320 +
321 + use X && emake "${NV_ARGS[@]}" -C nvidia-xconfig install
322 +
323 + # mimic nvidia-installer by reading .manifest to install files
324 + # 0:file 1:perms 2:type 3+:subtype/arguments -:module
325 + local m into
326 + while IFS=' ' read -ra m; do
327 + ! [[ ${#m[@]} -ge 2 && ${m[-1]} =~ MODULE: ]] ||
328 + eval '[[ " ${m[0]##*/}" =~ ^(\ '${skip_files[*]/%/.*|\\}' )$ ]]' ||
329 + eval '[[ " ${m[2]}" =~ ^(\ '${skip_types[*]/%/|\\}' )$ ]]' ||
330 + has ${m[-1]#MODULE:} "${skip_modules[@]}" && continue
331 +
332 + case ${m[2]} in
333 + MANPAGE)
334 + gzip -dc ${m[0]} | newman - ${m[0]%.gz}; assert
335 + continue
336 + ;;
337 + VDPAU_SYMLINK) m[4]=vdpau/; m[5]=${m[5]#vdpau/};; # .so to vdpau/
338 + esac
339 +
340 + if [[ -v paths[${m[2]}] ]]; then
341 + into=${paths[${m[2]}]}
342 + elif [[ ${m[2]} =~ _BINARY$ ]]; then
343 + into=/opt/bin
344 + elif [[ ${m[3]} == COMPAT32 ]]; then
345 + use abi_x86_32 || continue
346 + into=/usr/${libdir32}
347 + elif [[ ${m[2]} =~ _LIB$|_SYMLINK$ ]]; then
348 + into=/usr/${libdir}
349 + else
350 + die "No known installation path for ${m[0]}"
351 + fi
352 + [[ ${m[3]: -2} == ?/ ]] && into+=/${m[3]%/}
353 + [[ ${m[4]: -2} == ?/ ]] && into+=/${m[4]%/}
354 +
355 + if [[ ${m[2]} =~ _SYMLINK$ ]]; then
356 + [[ ${m[4]: -1} == / ]] && m[4]=${m[5]}
357 + dosym ${m[4]} ${into}/${m[0]}
358 + continue
359 + fi
360 + [[ ${m[0]} =~ ^libnvidia-ngx.so ]] &&
361 + dosym ${m[0]} ${into}/${m[0]%.so*}.so.1 # soname not in .manifest
362 +
363 + printf -v m[1] %o $((m[1] | 0200)) # 444->644
364 + insopts -m${m[1]}
365 + insinto ${into}
366 + doins ${m[0]}
367 + done < .manifest || die
368 +
369 + # MODULE:installer non-skipped extras
370 + exeinto /lib/systemd/system-sleep
371 + doexe nvidia
372 + dobin nvidia-sleep.sh
373 + systemd_dounit nvidia-{hibernate,resume,suspend}.service
374 +
375 + dobin nvidia-bug-report.sh
376 +}
377 +
378 +pkg_preinst() {
379 + has_version "${CATEGORY}/${PN}[abi_x86_32]" && NV_HAD_ABI32=
380 +
381 + use driver || return
382 + linux-mod_pkg_preinst
383 +
384 + # set video group id based on live system (bug #491414)
385 + local g=$(getent group video | cut -d: -f3)
386 + [[ ${g} ]] || die "Failed to determine video group id"
387 + sed -i "s/@VIDEOGID@/${g}/" "${ED}"/etc/modprobe.d/nvidia.conf || die
388 +
389 + # try to find driver mismatches using temporary supported-gpus.json
390 + for g in $(grep -l 0x10de /sys/bus/pci/devices/*/vendor 2>/dev/null); do
391 + g=$(grep -io "\"devid\":\"$(<${g%vendor}device)\"[^}]*branch\":\"[0-9]*" \
392 + "${ED}"/usr/share/nvidia/supported-gpus.json 2>/dev/null)
393 + if [[ ${g} ]]; then
394 + g=$((${g##*\"}+1))
395 + if ver_test -ge ${g}; then
396 + NV_LEGACY_MASK=">=${CATEGORY}/${PN}-${g}"
397 + break
398 + fi
399 + fi
400 + done
401 + rm "${ED}"/usr/share/nvidia/supported-gpus.json || die
402 +}
403 +
404 +pkg_postinst() {
405 + use driver && linux-mod_pkg_postinst
406 +
407 + readme.gentoo_print_elog
408 +
409 + if [[ -r /proc/driver/nvidia/version &&
410 + $(</proc/driver/nvidia/version) != *" ${PV} "* ]]; then
411 + ewarn "Currently loaded NVIDIA modules do not match the newly installed"
412 + ewarn "libraries and may prevent launching GPU-accelerated applications."
413 + use driver && ewarn "The easiest way to fix this is usually to reboot."
414 + fi
415 +
416 + if [[ -v NV_LEGACY_MASK ]]; then
417 + ewarn
418 + ewarn "***WARNING***"
419 + ewarn
420 + ewarn "You are installing a version of ${PN} known not to work"
421 + ewarn "with a GPU of the current system. If unwanted, add the mask:"
422 + if [[ -d ${EROOT}/etc/portage/package.mask ]]; then
423 + ewarn " echo '${NV_LEGACY_MASK}' > ${EROOT}/etc/portage/package.mask/${PN}"
424 + else
425 + ewarn " echo '${NV_LEGACY_MASK}' >> ${EROOT}/etc/portage/package.mask"
426 + fi
427 + ewarn "...then downgrade to a legacy branch if possible. For details, see:"
428 + ewarn "https://www.nvidia.com/object/IO_32667.html"
429 + fi
430 +
431 + if use !abi_x86_32 && [[ -v NV_HAD_ABI32 ]]; then
432 + elog
433 + elog "USE=abi_x86_32 is disabled, 32bit applications will not be able to"
434 + elog "use nvidia-drivers for acceleration without it (e.g. commonly used"
435 + elog "with app-emulation/wine-* or steam). Re-enable if needed."
436 + fi
437 +}