Gentoo Archives: gentoo-commits

From: Jeroen Roovers <jer@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: x11-drivers/nvidia-drivers/
Date: Thu, 03 Nov 2016 17:28:42
Message-Id: 1478193861.fac640d8cfb3f90d15955317e4138ddb505f9790.jer@gentoo
1 commit: fac640d8cfb3f90d15955317e4138ddb505f9790
2 Author: Jeroen Roovers <jer <AT> gentoo <DOT> org>
3 AuthorDate: Thu Nov 3 17:24:21 2016 +0000
4 Commit: Jeroen Roovers <jer <AT> gentoo <DOT> org>
5 CommitDate: Thu Nov 3 17:24:21 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fac640d8
7
8 x11-drivers/nvidia-drivers: Install Vulkan configuration file when USE=X (bug #596486 by Timo Rothenpieler).
9
10 Package-Manager: portage-2.3.2
11
12 .../nvidia-drivers/nvidia-drivers-364.19-r1.ebuild | 548 ++++++++++++++++++++
13 .../nvidia-drivers/nvidia-drivers-367.57-r1.ebuild | 552 ++++++++++++++++++++
14 .../nvidia-drivers/nvidia-drivers-370.28-r1.ebuild | 552 ++++++++++++++++++++
15 .../nvidia-drivers/nvidia-drivers-375.10-r1.ebuild | 560 +++++++++++++++++++++
16 4 files changed, 2212 insertions(+)
17
18 diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-364.19-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-364.19-r1.ebuild
19 new file mode 100644
20 index 00000000..75cf2be
21 --- /dev/null
22 +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-364.19-r1.ebuild
23 @@ -0,0 +1,548 @@
24 +# Copyright 1999-2016 Gentoo Foundation
25 +# Distributed under the terms of the GNU General Public License v2
26 +# $Id$
27 +
28 +EAPI=5
29 +
30 +inherit eutils flag-o-matic linux-info linux-mod multilib nvidia-driver \
31 + portability toolchain-funcs unpacker user udev
32 +
33 +NV_URI="http://us.download.nvidia.com/XFree86/"
34 +X86_NV_PACKAGE="NVIDIA-Linux-x86-${PV}"
35 +AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}"
36 +X86_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86-${PV}"
37 +AMD64_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86_64-${PV}"
38 +
39 +DESCRIPTION="NVIDIA Accelerated Graphics Driver"
40 +HOMEPAGE="http://www.nvidia.com/ http://www.nvidia.com/Download/Find.aspx"
41 +SRC_URI="
42 + amd64-fbsd? ( ${NV_URI}FreeBSD-x86_64/${PV}/${AMD64_FBSD_NV_PACKAGE}.tar.gz )
43 + amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run )
44 + x86-fbsd? ( ${NV_URI}FreeBSD-x86/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz )
45 + x86? ( ${NV_URI}Linux-x86/${PV}/${X86_NV_PACKAGE}.run )
46 + tools? ( ftp://download.nvidia.com/XFree86/nvidia-settings/nvidia-settings-${PV}.tar.bz2 )
47 +"
48 +
49 +LICENSE="GPL-2 NVIDIA-r2"
50 +SLOT="0/${PV%.*}"
51 +KEYWORDS="-* ~amd64 ~x86 ~amd64-fbsd ~x86-fbsd"
52 +RESTRICT="bindist mirror"
53 +EMULTILIB_PKG="true"
54 +
55 +IUSE="acpi compat +driver gtk3 kernel_FreeBSD kernel_linux +kms multilib pax_kernel static-libs +tools uvm wayland +X"
56 +REQUIRED_USE="
57 + tools? ( X )
58 + static-libs? ( tools )
59 +"
60 +
61 +COMMON="
62 + app-eselect/eselect-opencl
63 + kernel_linux? ( >=sys-libs/glibc-2.6.1 )
64 + tools? (
65 + dev-libs/atk
66 + dev-libs/glib:2
67 + dev-libs/jansson
68 + gtk3? ( x11-libs/gtk+:3 )
69 + x11-libs/cairo
70 + x11-libs/gdk-pixbuf[X]
71 + x11-libs/gtk+:2
72 + x11-libs/libX11
73 + x11-libs/libXext
74 + x11-libs/libXrandr
75 + x11-libs/libXv
76 + x11-libs/libXxf86vm
77 + x11-libs/pango[X]
78 + )
79 + X? (
80 + >=app-eselect/eselect-opengl-1.0.9
81 + app-misc/pax-utils
82 + )
83 +"
84 +DEPEND="
85 + ${COMMON}
86 + kernel_linux? ( virtual/linux-sources )
87 +"
88 +RDEPEND="
89 + ${COMMON}
90 + acpi? ( sys-power/acpid )
91 + tools? ( !media-video/nvidia-settings )
92 + wayland? ( dev-libs/wayland )
93 + X? (
94 + <x11-base/xorg-server-1.18.99:=
95 + >=x11-libs/libvdpau-1.0
96 + multilib? (
97 + >=x11-libs/libX11-1.6.2[abi_x86_32]
98 + >=x11-libs/libXext-1.3.2[abi_x86_32]
99 + )
100 + )
101 +"
102 +
103 +QA_PREBUILT="opt/* usr/lib*"
104 +
105 +S=${WORKDIR}/
106 +
107 +pkg_pretend() {
108 + if use amd64 && has_multilib_profile && \
109 + [ "${DEFAULT_ABI}" != "amd64" ]; then
110 + eerror "This ebuild doesn't currently support changing your default ABI"
111 + die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
112 + fi
113 +
114 + if use kernel_linux && kernel_is ge 4 6; then
115 + ewarn "Gentoo supports kernels which are supported by NVIDIA"
116 + ewarn "which are limited to the following kernels:"
117 + ewarn "<sys-kernel/gentoo-sources-4.6"
118 + ewarn "<sys-kernel/vanilla-sources-4.6"
119 + ewarn ""
120 + ewarn "You are free to utilize epatch_user to provide whatever"
121 + ewarn "support you feel is appropriate, but will not receive"
122 + ewarn "support as a result of those changes."
123 + ewarn ""
124 + ewarn "Do not file a bug report about this."
125 + ewarn ""
126 + fi
127 +
128 + # Since Nvidia ships many different series of drivers, we need to give the user
129 + # some kind of guidance as to what version they should install. This tries
130 + # to point the user in the right direction but can't be perfect. check
131 + # nvidia-driver.eclass
132 + nvidia-driver-check-warning
133 +
134 + # Kernel features/options to check for
135 + CONFIG_CHECK="~ZONE_DMA ~MTRR ~SYSVIPC ~!LOCKDEP"
136 + use x86 && CONFIG_CHECK+=" ~HIGHMEM"
137 +
138 + # Now do the above checks
139 + use kernel_linux && check_extra_config
140 +}
141 +
142 +pkg_setup() {
143 + # try to turn off distcc and ccache for people that have a problem with it
144 + export DISTCC_DISABLE=1
145 + export CCACHE_DISABLE=1
146 +
147 + if use driver && use kernel_linux; then
148 + MODULE_NAMES="nvidia(video:${S}/kernel)"
149 + use uvm && MODULE_NAMES+=" nvidia-uvm(video:${S}/kernel)"
150 + use kms && MODULE_NAMES+=" nvidia-modeset(video:${S}/kernel) nvidia-drm(video:${S}/kernel)"
151 +
152 + # This needs to run after MODULE_NAMES (so that the eclass checks
153 + # whether the kernel supports loadable modules) but before BUILD_PARAMS
154 + # is set (so that KV_DIR is populated).
155 + linux-mod_pkg_setup
156 +
157 + BUILD_PARAMS="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \
158 + SYSOUT=${KV_OUT_DIR} CC=$(tc-getBUILD_CC) NV_VERBOSE=1"
159 +
160 + # linux-mod_src_compile calls set_arch_to_kernel, which
161 + # sets the ARCH to x86 but NVIDIA's wrapping Makefile
162 + # expects x86_64 or i386 and then converts it to x86
163 + # later on in the build process
164 + BUILD_FIXES="ARCH=$(uname -m | sed -e 's/i.86/i386/')"
165 + fi
166 +
167 + if use kernel_linux && kernel_is lt 2 6 9; then
168 + eerror "You must build this against 2.6.9 or higher kernels."
169 + fi
170 +
171 + # set variables to where files are in the package structure
172 + if use kernel_FreeBSD; then
173 + use x86-fbsd && S="${WORKDIR}/${X86_FBSD_NV_PACKAGE}"
174 + use amd64-fbsd && S="${WORKDIR}/${AMD64_FBSD_NV_PACKAGE}"
175 + NV_DOC="${S}/doc"
176 + NV_OBJ="${S}/obj"
177 + NV_SRC="${S}/src"
178 + NV_MAN="${S}/x11/man"
179 + NV_X11="${S}/obj"
180 + NV_SOVER=1
181 + elif use kernel_linux; then
182 + NV_DOC="${S}"
183 + NV_OBJ="${S}"
184 + NV_SRC="${S}/kernel"
185 + NV_MAN="${S}"
186 + NV_X11="${S}"
187 + NV_SOVER=${PV}
188 + else
189 + die "Could not determine proper NVIDIA package"
190 + fi
191 +}
192 +
193 +src_prepare() {
194 + if use pax_kernel; then
195 + ewarn "Using PAX patches is not supported. You will be asked to"
196 + ewarn "use a standard kernel should you have issues. Should you"
197 + ewarn "need support with these patches, contact the PaX team."
198 + epatch "${FILESDIR}"/${PN}-364.12-pax.patch
199 + fi
200 +
201 + # Allow user patches so they can support RC kernels and whatever else
202 + epatch_user
203 +}
204 +
205 +src_compile() {
206 + # This is already the default on Linux, as there's no toplevel Makefile, but
207 + # on FreeBSD there's one and triggers the kernel module build, as we install
208 + # it by itself, pass this.
209 +
210 + cd "${NV_SRC}"
211 + if use kernel_FreeBSD; then
212 + MAKE="$(get_bmake)" CFLAGS="-Wno-sign-compare" emake CC="$(tc-getCC)" \
213 + LD="$(tc-getLD)" LDFLAGS="$(raw-ldflags)" || die
214 + elif use driver && use kernel_linux; then
215 + MAKEOPTS=-j1 linux-mod_src_compile
216 + fi
217 +
218 + if use tools; then
219 + emake -C "${S}"/nvidia-settings-${PV}/src \
220 + AR="$(tc-getAR)" \
221 + CC="$(tc-getCC)" \
222 + LIBDIR="$(get_libdir)" \
223 + NV_VERBOSE=1 \
224 + RANLIB="$(tc-getRANLIB)" \
225 + DO_STRIP= \
226 + build-xnvctrl
227 +
228 + emake -C "${S}"/nvidia-settings-${PV}/src \
229 + CC="$(tc-getCC)" \
230 + GTK3_AVAILABLE=$(usex gtk3 1 0) \
231 + LD="$(tc-getCC)" \
232 + LIBDIR="$(get_libdir)" \
233 + NVML_ENABLED=0 \
234 + NV_USE_BUNDLED_LIBJANSSON=0 \
235 + NV_VERBOSE=1 \
236 + DO_STRIP=
237 + fi
238 +}
239 +
240 +# Install nvidia library:
241 +# the first parameter is the library to install
242 +# the second parameter is the provided soversion
243 +# the third parameter is the target directory if it is not /usr/lib
244 +donvidia() {
245 + # Full path to library
246 + nv_LIB="${1}"
247 +
248 + # SOVER to use
249 + nv_SOVER="$(scanelf -qF'%S#F' ${nv_LIB})"
250 +
251 + # Where to install
252 + nv_DEST="${2}"
253 +
254 + # Get just the library name
255 + nv_LIBNAME=$(basename "${nv_LIB}")
256 +
257 + if [[ "${nv_DEST}" ]]; then
258 + exeinto ${nv_DEST}
259 + action="doexe"
260 + else
261 + nv_DEST="/usr/$(get_libdir)"
262 + action="dolib.so"
263 + fi
264 +
265 + # Install the library
266 + ${action} ${nv_LIB} || die "failed to install ${nv_LIBNAME}"
267 +
268 + # If the library has a SONAME and SONAME does not match the library name,
269 + # then we need to create a symlink
270 + if [[ ${nv_SOVER} ]] && ! [[ "${nv_SOVER}" = "${nv_LIBNAME}" ]]; then
271 + dosym ${nv_LIBNAME} ${nv_DEST}/${nv_SOVER} \
272 + || die "failed to create ${nv_DEST}/${nv_SOVER} symlink"
273 + fi
274 +
275 + dosym ${nv_LIBNAME} ${nv_DEST}/${nv_LIBNAME/.so*/.so} \
276 + || die "failed to create ${nv_LIBNAME/.so*/.so} symlink"
277 +}
278 +
279 +src_install() {
280 + if use driver && use kernel_linux; then
281 + linux-mod_src_install
282 +
283 + # Add the aliases
284 + # This file is tweaked with the appropriate video group in
285 + # pkg_preinst, see bug #491414
286 + insinto /etc/modprobe.d
287 + newins "${FILESDIR}"/nvidia-169.07 nvidia.conf
288 + doins "${FILESDIR}"/nvidia-rmmod.conf
289 +
290 + # Ensures that our device nodes are created when not using X
291 + exeinto "$(get_udevdir)"
292 + newexe "${FILESDIR}"/nvidia-udev.sh-r1 nvidia-udev.sh
293 + udev_newrules "${FILESDIR}"/nvidia.udev-rule 99-nvidia.rules
294 + elif use kernel_FreeBSD; then
295 + if use x86-fbsd; then
296 + insinto /boot/modules
297 + doins "${S}/src/nvidia.kld"
298 + fi
299 +
300 + exeinto /boot/modules
301 + doexe "${S}/src/nvidia.ko"
302 + fi
303 +
304 + # NVIDIA kernel <-> userspace driver config lib
305 + donvidia ${NV_OBJ}/libnvidia-cfg.so.${NV_SOVER}
306 +
307 + # NVIDIA framebuffer capture library
308 + donvidia ${NV_OBJ}/libnvidia-fbc.so.${NV_SOVER}
309 +
310 + # NVIDIA video encode/decode <-> CUDA
311 + if use kernel_linux; then
312 + donvidia ${NV_OBJ}/libnvcuvid.so.${NV_SOVER}
313 + donvidia ${NV_OBJ}/libnvidia-encode.so.${NV_SOVER}
314 + fi
315 +
316 + if use X; then
317 + # Xorg DDX driver
318 + insinto /usr/$(get_libdir)/xorg/modules/drivers
319 + doins ${NV_X11}/nvidia_drv.so
320 +
321 + # Xorg GLX driver
322 + donvidia ${NV_X11}/libglx.so.${NV_SOVER} \
323 + /usr/$(get_libdir)/opengl/nvidia/extensions
324 +
325 + # Xorg nvidia.conf
326 + if has_version '>=x11-base/xorg-server-1.16'; then
327 + insinto /usr/share/X11/xorg.conf.d
328 + newins {,50-}nvidia-drm-outputclass.conf
329 + fi
330 + fi
331 +
332 + # OpenCL ICD for NVIDIA
333 + if use kernel_linux; then
334 + insinto /etc/OpenCL/vendors
335 + doins ${NV_OBJ}/nvidia.icd
336 + fi
337 +
338 + # Documentation
339 + dohtml ${NV_DOC}/html/*
340 + if use kernel_FreeBSD; then
341 + dodoc "${NV_DOC}/README"
342 + use X && doman "${NV_MAN}/nvidia-xconfig.1"
343 + use tools && doman "${NV_MAN}/nvidia-settings.1"
344 + else
345 + # Docs
346 + newdoc "${NV_DOC}/README.txt" README
347 + dodoc "${NV_DOC}/NVIDIA_Changelog"
348 + doman "${NV_MAN}/nvidia-smi.1.gz"
349 + use X && doman "${NV_MAN}/nvidia-xconfig.1.gz"
350 + use tools && doman "${NV_MAN}/nvidia-settings.1.gz"
351 + doman "${NV_MAN}/nvidia-cuda-mps-control.1.gz"
352 + fi
353 +
354 + # Helper Apps
355 + exeinto /opt/bin/
356 +
357 + if use X; then
358 + doexe ${NV_OBJ}/nvidia-xconfig
359 +
360 + insinto /etc/vulkan/icd.d
361 + doins nvidia_icd.json
362 + fi
363 +
364 + if use kernel_linux; then
365 + doexe ${NV_OBJ}/nvidia-cuda-mps-control
366 + doexe ${NV_OBJ}/nvidia-cuda-mps-server
367 + doexe ${NV_OBJ}/nvidia-debugdump
368 + doexe ${NV_OBJ}/nvidia-persistenced
369 + doexe ${NV_OBJ}/nvidia-smi
370 +
371 + # install nvidia-modprobe setuid and symlink in /usr/bin (bug #505092)
372 + doexe ${NV_OBJ}/nvidia-modprobe
373 + fowners root:video /opt/bin/nvidia-modprobe
374 + fperms 4710 /opt/bin/nvidia-modprobe
375 + dosym /{opt,usr}/bin/nvidia-modprobe
376 +
377 + doman nvidia-cuda-mps-control.1.gz
378 + doman nvidia-modprobe.1.gz
379 + doman nvidia-persistenced.1.gz
380 + newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi
381 + newconfd "${FILESDIR}/nvidia-persistenced.conf" nvidia-persistenced
382 + newinitd "${FILESDIR}/nvidia-persistenced.init" nvidia-persistenced
383 + fi
384 +
385 + if use tools; then
386 + emake -C "${S}"/nvidia-settings-${PV}/src/ \
387 + DESTDIR="${D}" \
388 + GTK3_AVAILABLE=$(usex gtk3 1 0) \
389 + LIBDIR="${D}/usr/$(get_libdir)" \
390 + NV_USE_BUNDLED_LIBJANSSON=0 \
391 + NV_VERBOSE=1 \
392 + PREFIX=/usr \
393 + DO_STRIP= \
394 + install
395 +
396 + if use static-libs; then
397 + dolib.a "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/libXNVCtrl.a
398 +
399 + insinto /usr/include/NVCtrl
400 + doins "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/*.h
401 + fi
402 +
403 + insinto /usr/share/nvidia/
404 + doins nvidia-application-profiles-${PV}-key-documentation
405 +
406 + insinto /etc/nvidia
407 + newins \
408 + nvidia-application-profiles-${PV}-rc nvidia-application-profiles-rc
409 +
410 + # There is no icon in the FreeBSD tarball.
411 + use kernel_FreeBSD || \
412 + doicon ${NV_OBJ}/nvidia-settings.png
413 +
414 + domenu "${FILESDIR}"/nvidia-settings.desktop
415 +
416 + exeinto /etc/X11/xinit/xinitrc.d
417 + newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings
418 + fi
419 +
420 + dobin ${NV_OBJ}/nvidia-bug-report.sh
421 +
422 + if has_multilib_profile && use multilib; then
423 + local OABI=${ABI}
424 + for ABI in $(get_install_abis); do
425 + src_install-libs
426 + done
427 + ABI=${OABI}
428 + unset OABI
429 + else
430 + src_install-libs
431 + fi
432 +
433 + is_final_abi || die "failed to iterate through all ABIs"
434 +
435 + readme.gentoo_create_doc
436 +}
437 +
438 +src_install-libs() {
439 + local inslibdir=$(get_libdir)
440 + local GL_ROOT="/usr/$(get_libdir)/opengl/nvidia/lib"
441 + local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia"
442 + local libdir=${NV_OBJ}
443 +
444 + if use kernel_linux && has_multilib_profile && [[ ${ABI} == "x86" ]]; then
445 + libdir=${NV_OBJ}/32
446 + fi
447 +
448 + if use X; then
449 + NV_GLX_LIBRARIES=(
450 + "libEGL.so.1 ${GL_ROOT}"
451 + "libEGL_nvidia.so.${NV_SOVER} ${GL_ROOT}"
452 + "libGL.so.$(usex compat ${NV_SOVER} 1.0.0) ${GL_ROOT}"
453 + "libGLESv1_CM.so.1 ${GL_ROOT}"
454 + "libGLESv1_CM_nvidia.so.${NV_SOVER} ${GL_ROOT}"
455 + "libGLESv2.so.2 ${GL_ROOT}"
456 + "libGLESv2_nvidia.so.${NV_SOVER} ${GL_ROOT}"
457 + "libGLX.so.0 ${GL_ROOT}"
458 + "libGLX_nvidia.so.${NV_SOVER} ${GL_ROOT}"
459 + "libGLdispatch.so.0 ${GL_ROOT}"
460 + "libOpenCL.so.1.0.0 ${CL_ROOT}"
461 + "libOpenGL.so.0 ${GL_ROOT}"
462 + "libcuda.so.${NV_SOVER}"
463 + "libnvcuvid.so.${NV_SOVER}"
464 + "libnvidia-compiler.so.${NV_SOVER}"
465 + "libnvidia-eglcore.so.${NV_SOVER}"
466 + "libnvidia-encode.so.${NV_SOVER}"
467 + "libnvidia-fatbinaryloader.so.${NV_SOVER}"
468 + "libnvidia-fbc.so.${NV_SOVER}"
469 + "libnvidia-glcore.so.${NV_SOVER}"
470 + "libnvidia-glsi.so.${NV_SOVER}"
471 + "libnvidia-ifr.so.${NV_SOVER}"
472 + "libnvidia-opencl.so.${NV_SOVER}"
473 + "libnvidia-ptxjitcompiler.so.${NV_SOVER}"
474 + "libvdpau_nvidia.so.${NV_SOVER}"
475 + )
476 +
477 + if use wayland && has_multilib_profile && [[ ${ABI} == "amd64" ]];
478 + then
479 + NV_GLX_LIBRARIES+=(
480 + "libnvidia-egl-wayland.so.${NV_SOVER}"
481 + )
482 + fi
483 +
484 + if use kernel_linux && has_multilib_profile && [[ ${ABI} == "amd64" ]];
485 + then
486 + NV_GLX_LIBRARIES+=(
487 + "libnvidia-wfb.so.${NV_SOVER}"
488 + )
489 + fi
490 +
491 + if use kernel_FreeBSD; then
492 + NV_GLX_LIBRARIES+=(
493 + "libnvidia-tls.so.${NV_SOVER}"
494 + )
495 + fi
496 +
497 + if use kernel_linux; then
498 + NV_GLX_LIBRARIES+=(
499 + "libnvidia-ml.so.${NV_SOVER}"
500 + "tls/libnvidia-tls.so.${NV_SOVER}"
501 + )
502 + fi
503 +
504 + for NV_LIB in "${NV_GLX_LIBRARIES[@]}"; do
505 + donvidia ${libdir}/${NV_LIB}
506 + done
507 + fi
508 +}
509 +
510 +pkg_preinst() {
511 + if use driver && use kernel_linux; then
512 + linux-mod_pkg_preinst
513 +
514 + local videogroup="$(egetent group video | cut -d ':' -f 3)"
515 + if [ -z "${videogroup}" ]; then
516 + eerror "Failed to determine the video group gid"
517 + die "Failed to determine the video group gid"
518 + else
519 + sed -i \
520 + -e "s:PACKAGE:${PF}:g" \
521 + -e "s:VIDEOGID:${videogroup}:" \
522 + "${D}"/etc/modprobe.d/nvidia.conf || die
523 + fi
524 + fi
525 +
526 + # Clean the dynamic libGL stuff's home to ensure
527 + # we dont have stale libs floating around
528 + if [ -d "${ROOT}"/usr/lib/opengl/nvidia ]; then
529 + rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
530 + fi
531 + # Make sure we nuke the old nvidia-glx's env.d file
532 + if [ -e "${ROOT}"/etc/env.d/09nvidia ]; then
533 + rm -f "${ROOT}"/etc/env.d/09nvidia
534 + fi
535 +}
536 +
537 +pkg_postinst() {
538 + use driver && use kernel_linux && linux-mod_pkg_postinst
539 +
540 + # Switch to the nvidia implementation
541 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old nvidia
542 + "${ROOT}"/usr/bin/eselect opencl set --use-old nvidia
543 +
544 + readme.gentoo_print_elog
545 +
546 + if ! use X; then
547 + elog "You have elected to not install the X.org driver. Along with"
548 + elog "this the OpenGL libraries and VDPAU libraries were not"
549 + elog "installed. Additionally, once the driver is loaded your card"
550 + elog "and fan will run at max speed which may not be desirable."
551 + elog "Use the 'nvidia-smi' init script to have your card and fan"
552 + elog "speed scale appropriately."
553 + elog
554 + fi
555 + if ! use tools; then
556 + elog "USE=tools controls whether the nvidia-settings application"
557 + elog "is installed. If you would like to use it, enable that"
558 + elog "flag and re-emerge this ebuild. Optionally you can install"
559 + elog "media-video/nvidia-settings"
560 + elog
561 + fi
562 +}
563 +
564 +pkg_prerm() {
565 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
566 +}
567 +
568 +pkg_postrm() {
569 + use driver && use kernel_linux && linux-mod_pkg_postrm
570 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
571 +}
572
573 diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-367.57-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-367.57-r1.ebuild
574 new file mode 100644
575 index 00000000..5ff46f1
576 --- /dev/null
577 +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-367.57-r1.ebuild
578 @@ -0,0 +1,552 @@
579 +# Copyright 1999-2016 Gentoo Foundation
580 +# Distributed under the terms of the GNU General Public License v2
581 +# $Id$
582 +
583 +EAPI=5
584 +
585 +inherit eutils flag-o-matic linux-info linux-mod multilib nvidia-driver \
586 + portability toolchain-funcs unpacker user udev
587 +
588 +NV_URI="http://us.download.nvidia.com/XFree86/"
589 +X86_NV_PACKAGE="NVIDIA-Linux-x86-${PV}"
590 +AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}"
591 +ARM_NV_PACKAGE="NVIDIA-Linux-armv7l-gnueabihf-${PV}"
592 +X86_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86-${PV}"
593 +AMD64_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86_64-${PV}"
594 +
595 +DESCRIPTION="NVIDIA Accelerated Graphics Driver"
596 +HOMEPAGE="http://www.nvidia.com/ http://www.nvidia.com/Download/Find.aspx"
597 +SRC_URI="
598 + amd64-fbsd? ( ${NV_URI}FreeBSD-x86_64/${PV}/${AMD64_FBSD_NV_PACKAGE}.tar.gz )
599 + amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run )
600 + arm? ( ${NV_URI}Linux-x86-ARM/${PV}/${ARM_NV_PACKAGE}.run )
601 + x86-fbsd? ( ${NV_URI}FreeBSD-x86/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz )
602 + x86? ( ${NV_URI}Linux-x86/${PV}/${X86_NV_PACKAGE}.run )
603 + tools? ( ftp://download.nvidia.com/XFree86/nvidia-settings/nvidia-settings-${PV}.tar.bz2 )
604 +"
605 +
606 +LICENSE="GPL-2 NVIDIA-r2"
607 +SLOT="0/${PV%.*}"
608 +KEYWORDS="-* ~amd64 ~x86 ~amd64-fbsd ~x86-fbsd"
609 +RESTRICT="bindist mirror"
610 +EMULTILIB_PKG="true"
611 +
612 +IUSE="acpi compat +driver gtk3 kernel_FreeBSD kernel_linux +kms multilib pax_kernel static-libs +tools uvm wayland +X"
613 +REQUIRED_USE="
614 + tools? ( X )
615 + static-libs? ( tools )
616 +"
617 +
618 +COMMON="
619 + app-eselect/eselect-opencl
620 + kernel_linux? ( >=sys-libs/glibc-2.6.1 )
621 + tools? (
622 + dev-libs/atk
623 + dev-libs/glib:2
624 + dev-libs/jansson
625 + gtk3? ( x11-libs/gtk+:3 )
626 + x11-libs/cairo
627 + x11-libs/gdk-pixbuf[X]
628 + x11-libs/gtk+:2
629 + x11-libs/libX11
630 + x11-libs/libXext
631 + x11-libs/libXrandr
632 + x11-libs/libXv
633 + x11-libs/libXxf86vm
634 + x11-libs/pango[X]
635 + )
636 + X? (
637 + >=app-eselect/eselect-opengl-1.0.9
638 + app-misc/pax-utils
639 + )
640 +"
641 +DEPEND="
642 + ${COMMON}
643 + kernel_linux? ( virtual/linux-sources )
644 +"
645 +RDEPEND="
646 + ${COMMON}
647 + acpi? ( sys-power/acpid )
648 + tools? ( !media-video/nvidia-settings )
649 + wayland? ( dev-libs/wayland )
650 + X? (
651 + <x11-base/xorg-server-1.18.99:=
652 + >=x11-libs/libvdpau-1.0
653 + multilib? (
654 + >=x11-libs/libX11-1.6.2[abi_x86_32]
655 + >=x11-libs/libXext-1.3.2[abi_x86_32]
656 + )
657 + )
658 +"
659 +
660 +QA_PREBUILT="opt/* usr/lib*"
661 +
662 +S=${WORKDIR}/
663 +
664 +pkg_pretend() {
665 + if use amd64 && has_multilib_profile && \
666 + [ "${DEFAULT_ABI}" != "amd64" ]; then
667 + eerror "This ebuild doesn't currently support changing your default ABI"
668 + die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
669 + fi
670 +
671 + if use kernel_linux && kernel_is ge 4 8; then
672 + ewarn "Gentoo supports kernels which are supported by NVIDIA"
673 + ewarn "which are limited to the following kernels:"
674 + ewarn "<sys-kernel/gentoo-sources-4.8"
675 + ewarn "<sys-kernel/vanilla-sources-4.8"
676 + ewarn ""
677 + ewarn "You are free to utilize epatch_user to provide whatever"
678 + ewarn "support you feel is appropriate, but will not receive"
679 + ewarn "support as a result of those changes."
680 + ewarn ""
681 + ewarn "Do not file a bug report about this."
682 + ewarn ""
683 + fi
684 +
685 + # Since Nvidia ships many different series of drivers, we need to give the user
686 + # some kind of guidance as to what version they should install. This tries
687 + # to point the user in the right direction but can't be perfect. check
688 + # nvidia-driver.eclass
689 + nvidia-driver-check-warning
690 +
691 + # Kernel features/options to check for
692 + CONFIG_CHECK="~ZONE_DMA ~MTRR ~SYSVIPC ~!LOCKDEP"
693 + use x86 && CONFIG_CHECK+=" ~HIGHMEM"
694 +
695 + # Now do the above checks
696 + use kernel_linux && check_extra_config
697 +}
698 +
699 +pkg_setup() {
700 + # try to turn off distcc and ccache for people that have a problem with it
701 + export DISTCC_DISABLE=1
702 + export CCACHE_DISABLE=1
703 +
704 + if use driver && use kernel_linux; then
705 + MODULE_NAMES="nvidia(video:${S}/kernel)"
706 + use uvm && MODULE_NAMES+=" nvidia-uvm(video:${S}/kernel)"
707 + use kms && MODULE_NAMES+=" nvidia-modeset(video:${S}/kernel) nvidia-drm(video:${S}/kernel)"
708 +
709 + # This needs to run after MODULE_NAMES (so that the eclass checks
710 + # whether the kernel supports loadable modules) but before BUILD_PARAMS
711 + # is set (so that KV_DIR is populated).
712 + linux-mod_pkg_setup
713 +
714 + BUILD_PARAMS="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \
715 + SYSOUT=${KV_OUT_DIR} CC=$(tc-getBUILD_CC) NV_VERBOSE=1"
716 +
717 + # linux-mod_src_compile calls set_arch_to_kernel, which
718 + # sets the ARCH to x86 but NVIDIA's wrapping Makefile
719 + # expects x86_64 or i386 and then converts it to x86
720 + # later on in the build process
721 + BUILD_FIXES="ARCH=$(uname -m | sed -e 's/i.86/i386/')"
722 + fi
723 +
724 + if use kernel_linux && kernel_is lt 2 6 9; then
725 + eerror "You must build this against 2.6.9 or higher kernels."
726 + fi
727 +
728 + # set variables to where files are in the package structure
729 + if use kernel_FreeBSD; then
730 + use x86-fbsd && S="${WORKDIR}/${X86_FBSD_NV_PACKAGE}"
731 + use amd64-fbsd && S="${WORKDIR}/${AMD64_FBSD_NV_PACKAGE}"
732 + NV_DOC="${S}/doc"
733 + NV_OBJ="${S}/obj"
734 + NV_SRC="${S}/src"
735 + NV_MAN="${S}/x11/man"
736 + NV_X11="${S}/obj"
737 + NV_SOVER=1
738 + elif use kernel_linux; then
739 + NV_DOC="${S}"
740 + NV_OBJ="${S}"
741 + NV_SRC="${S}/kernel"
742 + NV_MAN="${S}"
743 + NV_X11="${S}"
744 + NV_SOVER=${PV}
745 + else
746 + die "Could not determine proper NVIDIA package"
747 + fi
748 +}
749 +
750 +src_prepare() {
751 + epatch "${FILESDIR}"/${PN}-367.57-profiles-rc.patch
752 +
753 + if use pax_kernel; then
754 + ewarn "Using PAX patches is not supported. You will be asked to"
755 + ewarn "use a standard kernel should you have issues. Should you"
756 + ewarn "need support with these patches, contact the PaX team."
757 + epatch "${FILESDIR}"/${PN}-367.57-pax.patch
758 + fi
759 +
760 + # Allow user patches so they can support RC kernels and whatever else
761 + epatch_user
762 +}
763 +
764 +src_compile() {
765 + # This is already the default on Linux, as there's no toplevel Makefile, but
766 + # on FreeBSD there's one and triggers the kernel module build, as we install
767 + # it by itself, pass this.
768 +
769 + cd "${NV_SRC}"
770 + if use kernel_FreeBSD; then
771 + MAKE="$(get_bmake)" CFLAGS="-Wno-sign-compare" emake CC="$(tc-getCC)" \
772 + LD="$(tc-getLD)" LDFLAGS="$(raw-ldflags)" || die
773 + elif use driver && use kernel_linux; then
774 + MAKEOPTS=-j1 linux-mod_src_compile
775 + fi
776 +
777 + if use tools; then
778 + emake -C "${S}"/nvidia-settings-${PV}/src \
779 + AR="$(tc-getAR)" \
780 + CC="$(tc-getCC)" \
781 + LIBDIR="$(get_libdir)" \
782 + NV_VERBOSE=1 \
783 + RANLIB="$(tc-getRANLIB)" \
784 + DO_STRIP= \
785 + build-xnvctrl
786 +
787 + emake -C "${S}"/nvidia-settings-${PV}/src \
788 + CC="$(tc-getCC)" \
789 + GTK3_AVAILABLE=$(usex gtk3 1 0) \
790 + LD="$(tc-getCC)" \
791 + LIBDIR="$(get_libdir)" \
792 + NVML_ENABLED=0 \
793 + NV_USE_BUNDLED_LIBJANSSON=0 \
794 + NV_VERBOSE=1 \
795 + DO_STRIP=
796 + fi
797 +}
798 +
799 +# Install nvidia library:
800 +# the first parameter is the library to install
801 +# the second parameter is the provided soversion
802 +# the third parameter is the target directory if it is not /usr/lib
803 +donvidia() {
804 + # Full path to library
805 + nv_LIB="${1}"
806 +
807 + # SOVER to use
808 + nv_SOVER="$(scanelf -qF'%S#F' ${nv_LIB})"
809 +
810 + # Where to install
811 + nv_DEST="${2}"
812 +
813 + # Get just the library name
814 + nv_LIBNAME=$(basename "${nv_LIB}")
815 +
816 + if [[ "${nv_DEST}" ]]; then
817 + exeinto ${nv_DEST}
818 + action="doexe"
819 + else
820 + nv_DEST="/usr/$(get_libdir)"
821 + action="dolib.so"
822 + fi
823 +
824 + # Install the library
825 + ${action} ${nv_LIB} || die "failed to install ${nv_LIBNAME}"
826 +
827 + # If the library has a SONAME and SONAME does not match the library name,
828 + # then we need to create a symlink
829 + if [[ ${nv_SOVER} ]] && ! [[ "${nv_SOVER}" = "${nv_LIBNAME}" ]]; then
830 + dosym ${nv_LIBNAME} ${nv_DEST}/${nv_SOVER} \
831 + || die "failed to create ${nv_DEST}/${nv_SOVER} symlink"
832 + fi
833 +
834 + dosym ${nv_LIBNAME} ${nv_DEST}/${nv_LIBNAME/.so*/.so} \
835 + || die "failed to create ${nv_LIBNAME/.so*/.so} symlink"
836 +}
837 +
838 +src_install() {
839 + if use driver && use kernel_linux; then
840 + linux-mod_src_install
841 +
842 + # Add the aliases
843 + # This file is tweaked with the appropriate video group in
844 + # pkg_preinst, see bug #491414
845 + insinto /etc/modprobe.d
846 + newins "${FILESDIR}"/nvidia-169.07 nvidia.conf
847 + doins "${FILESDIR}"/nvidia-rmmod.conf
848 +
849 + # Ensures that our device nodes are created when not using X
850 + exeinto "$(get_udevdir)"
851 + newexe "${FILESDIR}"/nvidia-udev.sh-r1 nvidia-udev.sh
852 + udev_newrules "${FILESDIR}"/nvidia.udev-rule 99-nvidia.rules
853 + elif use kernel_FreeBSD; then
854 + if use x86-fbsd; then
855 + insinto /boot/modules
856 + doins "${S}/src/nvidia.kld"
857 + fi
858 +
859 + exeinto /boot/modules
860 + doexe "${S}/src/nvidia.ko"
861 + fi
862 +
863 + # NVIDIA kernel <-> userspace driver config lib
864 + donvidia ${NV_OBJ}/libnvidia-cfg.so.${NV_SOVER}
865 +
866 + # NVIDIA framebuffer capture library
867 + donvidia ${NV_OBJ}/libnvidia-fbc.so.${NV_SOVER}
868 +
869 + # NVIDIA video encode/decode <-> CUDA
870 + if use kernel_linux; then
871 + donvidia ${NV_OBJ}/libnvcuvid.so.${NV_SOVER}
872 + donvidia ${NV_OBJ}/libnvidia-encode.so.${NV_SOVER}
873 + fi
874 +
875 + if use X; then
876 + # Xorg DDX driver
877 + insinto /usr/$(get_libdir)/xorg/modules/drivers
878 + doins ${NV_X11}/nvidia_drv.so
879 +
880 + # Xorg GLX driver
881 + donvidia ${NV_X11}/libglx.so.${NV_SOVER} \
882 + /usr/$(get_libdir)/opengl/nvidia/extensions
883 +
884 + # Xorg nvidia.conf
885 + if has_version '>=x11-base/xorg-server-1.16'; then
886 + insinto /usr/share/X11/xorg.conf.d
887 + newins {,50-}nvidia-drm-outputclass.conf
888 + fi
889 + fi
890 +
891 + # OpenCL ICD for NVIDIA
892 + if use kernel_linux; then
893 + insinto /etc/OpenCL/vendors
894 + doins ${NV_OBJ}/nvidia.icd
895 + fi
896 +
897 + # Documentation
898 + dohtml ${NV_DOC}/html/*
899 + if use kernel_FreeBSD; then
900 + dodoc "${NV_DOC}/README"
901 + use X && doman "${NV_MAN}/nvidia-xconfig.1"
902 + use tools && doman "${NV_MAN}/nvidia-settings.1"
903 + else
904 + # Docs
905 + newdoc "${NV_DOC}/README.txt" README
906 + dodoc "${NV_DOC}/NVIDIA_Changelog"
907 + doman "${NV_MAN}/nvidia-smi.1.gz"
908 + use X && doman "${NV_MAN}/nvidia-xconfig.1.gz"
909 + use tools && doman "${NV_MAN}/nvidia-settings.1.gz"
910 + doman "${NV_MAN}/nvidia-cuda-mps-control.1.gz"
911 + fi
912 +
913 + # Helper Apps
914 + exeinto /opt/bin/
915 +
916 + if use X; then
917 + doexe ${NV_OBJ}/nvidia-xconfig
918 +
919 + insinto /etc/vulkan/icd.d
920 + doins nvidia_icd.json
921 + fi
922 +
923 + if use kernel_linux; then
924 + doexe ${NV_OBJ}/nvidia-cuda-mps-control
925 + doexe ${NV_OBJ}/nvidia-cuda-mps-server
926 + doexe ${NV_OBJ}/nvidia-debugdump
927 + doexe ${NV_OBJ}/nvidia-persistenced
928 + doexe ${NV_OBJ}/nvidia-smi
929 +
930 + # install nvidia-modprobe setuid and symlink in /usr/bin (bug #505092)
931 + doexe ${NV_OBJ}/nvidia-modprobe
932 + fowners root:video /opt/bin/nvidia-modprobe
933 + fperms 4710 /opt/bin/nvidia-modprobe
934 + dosym /{opt,usr}/bin/nvidia-modprobe
935 +
936 + doman nvidia-cuda-mps-control.1.gz
937 + doman nvidia-modprobe.1.gz
938 + doman nvidia-persistenced.1.gz
939 + newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi
940 + newconfd "${FILESDIR}/nvidia-persistenced.conf" nvidia-persistenced
941 + newinitd "${FILESDIR}/nvidia-persistenced.init" nvidia-persistenced
942 + fi
943 +
944 + if use tools; then
945 + emake -C "${S}"/nvidia-settings-${PV}/src/ \
946 + DESTDIR="${D}" \
947 + GTK3_AVAILABLE=$(usex gtk3 1 0) \
948 + LIBDIR="${D}/usr/$(get_libdir)" \
949 + NV_USE_BUNDLED_LIBJANSSON=0 \
950 + NV_VERBOSE=1 \
951 + PREFIX=/usr \
952 + DO_STRIP= \
953 + install
954 +
955 + if use static-libs; then
956 + dolib.a "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/libXNVCtrl.a
957 +
958 + insinto /usr/include/NVCtrl
959 + doins "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/*.h
960 + fi
961 +
962 + insinto /usr/share/nvidia/
963 + doins nvidia-application-profiles-${PV}-key-documentation
964 +
965 + insinto /etc/nvidia
966 + newins \
967 + nvidia-application-profiles-${PV}-rc nvidia-application-profiles-rc
968 +
969 + # There is no icon in the FreeBSD tarball.
970 + use kernel_FreeBSD || \
971 + doicon ${NV_OBJ}/nvidia-settings.png
972 +
973 + domenu "${FILESDIR}"/nvidia-settings.desktop
974 +
975 + exeinto /etc/X11/xinit/xinitrc.d
976 + newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings
977 + fi
978 +
979 + dobin ${NV_OBJ}/nvidia-bug-report.sh
980 +
981 + if has_multilib_profile && use multilib; then
982 + local OABI=${ABI}
983 + for ABI in $(get_install_abis); do
984 + src_install-libs
985 + done
986 + ABI=${OABI}
987 + unset OABI
988 + else
989 + src_install-libs
990 + fi
991 +
992 + is_final_abi || die "failed to iterate through all ABIs"
993 +
994 + readme.gentoo_create_doc
995 +}
996 +
997 +src_install-libs() {
998 + local inslibdir=$(get_libdir)
999 + local GL_ROOT="/usr/$(get_libdir)/opengl/nvidia/lib"
1000 + local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia"
1001 + local libdir=${NV_OBJ}
1002 +
1003 + if use kernel_linux && has_multilib_profile && [[ ${ABI} == "x86" ]]; then
1004 + libdir=${NV_OBJ}/32
1005 + fi
1006 +
1007 + if use X; then
1008 + NV_GLX_LIBRARIES=(
1009 + "libEGL.so.1 ${GL_ROOT}"
1010 + "libEGL_nvidia.so.${NV_SOVER} ${GL_ROOT}"
1011 + "libGL.so.$(usex compat ${NV_SOVER} 1.0.0) ${GL_ROOT}"
1012 + "libGLESv1_CM.so.1 ${GL_ROOT}"
1013 + "libGLESv1_CM_nvidia.so.${NV_SOVER} ${GL_ROOT}"
1014 + "libGLESv2.so.2 ${GL_ROOT}"
1015 + "libGLESv2_nvidia.so.${NV_SOVER} ${GL_ROOT}"
1016 + "libGLX.so.0 ${GL_ROOT}"
1017 + "libGLX_nvidia.so.${NV_SOVER} ${GL_ROOT}"
1018 + "libGLdispatch.so.0 ${GL_ROOT}"
1019 + "libOpenCL.so.1.0.0 ${CL_ROOT}"
1020 + "libOpenGL.so.0 ${GL_ROOT}"
1021 + "libcuda.so.${NV_SOVER}"
1022 + "libnvcuvid.so.${NV_SOVER}"
1023 + "libnvidia-compiler.so.${NV_SOVER}"
1024 + "libnvidia-eglcore.so.${NV_SOVER}"
1025 + "libnvidia-encode.so.${NV_SOVER}"
1026 + "libnvidia-fatbinaryloader.so.${NV_SOVER}"
1027 + "libnvidia-fbc.so.${NV_SOVER}"
1028 + "libnvidia-glcore.so.${NV_SOVER}"
1029 + "libnvidia-glsi.so.${NV_SOVER}"
1030 + "libnvidia-ifr.so.${NV_SOVER}"
1031 + "libnvidia-opencl.so.${NV_SOVER}"
1032 + "libnvidia-ptxjitcompiler.so.${NV_SOVER}"
1033 + "libvdpau_nvidia.so.${NV_SOVER}"
1034 + )
1035 +
1036 + if use wayland && has_multilib_profile && [[ ${ABI} == "amd64" ]];
1037 + then
1038 + NV_GLX_LIBRARIES+=(
1039 + "libnvidia-egl-wayland.so.${NV_SOVER}"
1040 + )
1041 + fi
1042 +
1043 + if use kernel_linux && has_multilib_profile && [[ ${ABI} == "amd64" ]];
1044 + then
1045 + NV_GLX_LIBRARIES+=(
1046 + "libnvidia-wfb.so.${NV_SOVER}"
1047 + )
1048 + fi
1049 +
1050 + if use kernel_FreeBSD; then
1051 + NV_GLX_LIBRARIES+=(
1052 + "libnvidia-tls.so.${NV_SOVER}"
1053 + )
1054 + fi
1055 +
1056 + if use kernel_linux; then
1057 + NV_GLX_LIBRARIES+=(
1058 + "libnvidia-ml.so.${NV_SOVER}"
1059 + "tls/libnvidia-tls.so.${NV_SOVER}"
1060 + )
1061 + fi
1062 +
1063 + for NV_LIB in "${NV_GLX_LIBRARIES[@]}"; do
1064 + donvidia ${libdir}/${NV_LIB}
1065 + done
1066 + fi
1067 +}
1068 +
1069 +pkg_preinst() {
1070 + if use driver && use kernel_linux; then
1071 + linux-mod_pkg_preinst
1072 +
1073 + local videogroup="$(egetent group video | cut -d ':' -f 3)"
1074 + if [ -z "${videogroup}" ]; then
1075 + eerror "Failed to determine the video group gid"
1076 + die "Failed to determine the video group gid"
1077 + else
1078 + sed -i \
1079 + -e "s:PACKAGE:${PF}:g" \
1080 + -e "s:VIDEOGID:${videogroup}:" \
1081 + "${D}"/etc/modprobe.d/nvidia.conf || die
1082 + fi
1083 + fi
1084 +
1085 + # Clean the dynamic libGL stuff's home to ensure
1086 + # we dont have stale libs floating around
1087 + if [ -d "${ROOT}"/usr/lib/opengl/nvidia ]; then
1088 + rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
1089 + fi
1090 + # Make sure we nuke the old nvidia-glx's env.d file
1091 + if [ -e "${ROOT}"/etc/env.d/09nvidia ]; then
1092 + rm -f "${ROOT}"/etc/env.d/09nvidia
1093 + fi
1094 +}
1095 +
1096 +pkg_postinst() {
1097 + use driver && use kernel_linux && linux-mod_pkg_postinst
1098 +
1099 + # Switch to the nvidia implementation
1100 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old nvidia
1101 + "${ROOT}"/usr/bin/eselect opencl set --use-old nvidia
1102 +
1103 + readme.gentoo_print_elog
1104 +
1105 + if ! use X; then
1106 + elog "You have elected to not install the X.org driver. Along with"
1107 + elog "this the OpenGL libraries and VDPAU libraries were not"
1108 + elog "installed. Additionally, once the driver is loaded your card"
1109 + elog "and fan will run at max speed which may not be desirable."
1110 + elog "Use the 'nvidia-smi' init script to have your card and fan"
1111 + elog "speed scale appropriately."
1112 + elog
1113 + fi
1114 + if ! use tools; then
1115 + elog "USE=tools controls whether the nvidia-settings application"
1116 + elog "is installed. If you would like to use it, enable that"
1117 + elog "flag and re-emerge this ebuild. Optionally you can install"
1118 + elog "media-video/nvidia-settings"
1119 + elog
1120 + fi
1121 +}
1122 +
1123 +pkg_prerm() {
1124 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
1125 +}
1126 +
1127 +pkg_postrm() {
1128 + use driver && use kernel_linux && linux-mod_pkg_postrm
1129 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
1130 +}
1131
1132 diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-370.28-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-370.28-r1.ebuild
1133 new file mode 100644
1134 index 00000000..d5c8846
1135 --- /dev/null
1136 +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-370.28-r1.ebuild
1137 @@ -0,0 +1,552 @@
1138 +# Copyright 1999-2016 Gentoo Foundation
1139 +# Distributed under the terms of the GNU General Public License v2
1140 +# $Id$
1141 +
1142 +EAPI=5
1143 +
1144 +inherit eutils flag-o-matic linux-info linux-mod multilib nvidia-driver \
1145 + portability toolchain-funcs unpacker user udev
1146 +
1147 +NV_URI="http://us.download.nvidia.com/XFree86/"
1148 +X86_NV_PACKAGE="NVIDIA-Linux-x86-${PV}"
1149 +AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}"
1150 +ARM_NV_PACKAGE="NVIDIA-Linux-armv7l-gnueabihf-${PV}"
1151 +X86_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86-${PV}"
1152 +AMD64_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86_64-${PV}"
1153 +
1154 +DESCRIPTION="NVIDIA Accelerated Graphics Driver"
1155 +HOMEPAGE="http://www.nvidia.com/ http://www.nvidia.com/Download/Find.aspx"
1156 +SRC_URI="
1157 + amd64-fbsd? ( ${NV_URI}FreeBSD-x86_64/${PV}/${AMD64_FBSD_NV_PACKAGE}.tar.gz )
1158 + amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run )
1159 + arm? ( ${NV_URI}Linux-x86-ARM/${PV}/${ARM_NV_PACKAGE}.run )
1160 + x86-fbsd? ( ${NV_URI}FreeBSD-x86/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz )
1161 + x86? ( ${NV_URI}Linux-x86/${PV}/${X86_NV_PACKAGE}.run )
1162 + tools? ( ftp://download.nvidia.com/XFree86/nvidia-settings/nvidia-settings-${PV}.tar.bz2 )
1163 +"
1164 +
1165 +LICENSE="GPL-2 NVIDIA-r2"
1166 +SLOT="0/${PV%.*}"
1167 +KEYWORDS="-* ~amd64 ~x86 ~amd64-fbsd ~x86-fbsd"
1168 +RESTRICT="bindist mirror"
1169 +EMULTILIB_PKG="true"
1170 +
1171 +IUSE="acpi compat +driver gtk3 kernel_FreeBSD kernel_linux +kms multilib pax_kernel static-libs +tools uvm wayland +X"
1172 +REQUIRED_USE="
1173 + tools? ( X )
1174 + static-libs? ( tools )
1175 +"
1176 +
1177 +COMMON="
1178 + app-eselect/eselect-opencl
1179 + kernel_linux? ( >=sys-libs/glibc-2.6.1 )
1180 + tools? (
1181 + dev-libs/atk
1182 + dev-libs/glib:2
1183 + dev-libs/jansson
1184 + gtk3? ( x11-libs/gtk+:3 )
1185 + x11-libs/cairo
1186 + x11-libs/gdk-pixbuf[X]
1187 + x11-libs/gtk+:2
1188 + x11-libs/libX11
1189 + x11-libs/libXext
1190 + x11-libs/libXrandr
1191 + x11-libs/libXv
1192 + x11-libs/libXxf86vm
1193 + x11-libs/pango[X]
1194 + )
1195 + X? (
1196 + >=app-eselect/eselect-opengl-1.0.9
1197 + app-misc/pax-utils
1198 + )
1199 +"
1200 +DEPEND="
1201 + ${COMMON}
1202 + kernel_linux? ( virtual/linux-sources )
1203 +"
1204 +RDEPEND="
1205 + ${COMMON}
1206 + acpi? ( sys-power/acpid )
1207 + tools? ( !media-video/nvidia-settings )
1208 + wayland? ( dev-libs/wayland )
1209 + X? (
1210 + <x11-base/xorg-server-1.18.99:=
1211 + >=x11-libs/libvdpau-1.0
1212 + multilib? (
1213 + >=x11-libs/libX11-1.6.2[abi_x86_32]
1214 + >=x11-libs/libXext-1.3.2[abi_x86_32]
1215 + )
1216 + )
1217 +"
1218 +
1219 +QA_PREBUILT="opt/* usr/lib*"
1220 +
1221 +S=${WORKDIR}/
1222 +
1223 +pkg_pretend() {
1224 + if use amd64 && has_multilib_profile && \
1225 + [ "${DEFAULT_ABI}" != "amd64" ]; then
1226 + eerror "This ebuild doesn't currently support changing your default ABI"
1227 + die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
1228 + fi
1229 +
1230 + if use kernel_linux && kernel_is ge 4 8; then
1231 + ewarn "Gentoo supports kernels which are supported by NVIDIA"
1232 + ewarn "which are limited to the following kernels:"
1233 + ewarn "<sys-kernel/gentoo-sources-4.8"
1234 + ewarn "<sys-kernel/vanilla-sources-4.8"
1235 + ewarn ""
1236 + ewarn "You are free to utilize epatch_user to provide whatever"
1237 + ewarn "support you feel is appropriate, but will not receive"
1238 + ewarn "support as a result of those changes."
1239 + ewarn ""
1240 + ewarn "Do not file a bug report about this."
1241 + ewarn ""
1242 + fi
1243 +
1244 + # Since Nvidia ships many different series of drivers, we need to give the user
1245 + # some kind of guidance as to what version they should install. This tries
1246 + # to point the user in the right direction but can't be perfect. check
1247 + # nvidia-driver.eclass
1248 + nvidia-driver-check-warning
1249 +
1250 + # Kernel features/options to check for
1251 + CONFIG_CHECK="~ZONE_DMA ~MTRR ~SYSVIPC ~!LOCKDEP"
1252 + use x86 && CONFIG_CHECK+=" ~HIGHMEM"
1253 +
1254 + # Now do the above checks
1255 + use kernel_linux && check_extra_config
1256 +}
1257 +
1258 +pkg_setup() {
1259 + # try to turn off distcc and ccache for people that have a problem with it
1260 + export DISTCC_DISABLE=1
1261 + export CCACHE_DISABLE=1
1262 +
1263 + if use driver && use kernel_linux; then
1264 + MODULE_NAMES="nvidia(video:${S}/kernel)"
1265 + use uvm && MODULE_NAMES+=" nvidia-uvm(video:${S}/kernel)"
1266 + use kms && MODULE_NAMES+=" nvidia-modeset(video:${S}/kernel) nvidia-drm(video:${S}/kernel)"
1267 +
1268 + # This needs to run after MODULE_NAMES (so that the eclass checks
1269 + # whether the kernel supports loadable modules) but before BUILD_PARAMS
1270 + # is set (so that KV_DIR is populated).
1271 + linux-mod_pkg_setup
1272 +
1273 + BUILD_PARAMS="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \
1274 + SYSOUT=${KV_OUT_DIR} CC=$(tc-getBUILD_CC) NV_VERBOSE=1"
1275 +
1276 + # linux-mod_src_compile calls set_arch_to_kernel, which
1277 + # sets the ARCH to x86 but NVIDIA's wrapping Makefile
1278 + # expects x86_64 or i386 and then converts it to x86
1279 + # later on in the build process
1280 + BUILD_FIXES="ARCH=$(uname -m | sed -e 's/i.86/i386/')"
1281 + fi
1282 +
1283 + if use kernel_linux && kernel_is lt 2 6 9; then
1284 + eerror "You must build this against 2.6.9 or higher kernels."
1285 + fi
1286 +
1287 + # set variables to where files are in the package structure
1288 + if use kernel_FreeBSD; then
1289 + use x86-fbsd && S="${WORKDIR}/${X86_FBSD_NV_PACKAGE}"
1290 + use amd64-fbsd && S="${WORKDIR}/${AMD64_FBSD_NV_PACKAGE}"
1291 + NV_DOC="${S}/doc"
1292 + NV_OBJ="${S}/obj"
1293 + NV_SRC="${S}/src"
1294 + NV_MAN="${S}/x11/man"
1295 + NV_X11="${S}/obj"
1296 + NV_SOVER=1
1297 + elif use kernel_linux; then
1298 + NV_DOC="${S}"
1299 + NV_OBJ="${S}"
1300 + NV_SRC="${S}/kernel"
1301 + NV_MAN="${S}"
1302 + NV_X11="${S}"
1303 + NV_SOVER=${PV}
1304 + else
1305 + die "Could not determine proper NVIDIA package"
1306 + fi
1307 +}
1308 +
1309 +src_prepare() {
1310 + epatch "${FILESDIR}"/${P}-profiles-rc.patch
1311 +
1312 + if use pax_kernel; then
1313 + ewarn "Using PAX patches is not supported. You will be asked to"
1314 + ewarn "use a standard kernel should you have issues. Should you"
1315 + ewarn "need support with these patches, contact the PaX team."
1316 + epatch "${FILESDIR}"/${PN}-367.35-pax.patch
1317 + fi
1318 +
1319 + # Allow user patches so they can support RC kernels and whatever else
1320 + epatch_user
1321 +}
1322 +
1323 +src_compile() {
1324 + # This is already the default on Linux, as there's no toplevel Makefile, but
1325 + # on FreeBSD there's one and triggers the kernel module build, as we install
1326 + # it by itself, pass this.
1327 +
1328 + cd "${NV_SRC}"
1329 + if use kernel_FreeBSD; then
1330 + MAKE="$(get_bmake)" CFLAGS="-Wno-sign-compare" emake CC="$(tc-getCC)" \
1331 + LD="$(tc-getLD)" LDFLAGS="$(raw-ldflags)" || die
1332 + elif use driver && use kernel_linux; then
1333 + MAKEOPTS=-j1 linux-mod_src_compile
1334 + fi
1335 +
1336 + if use tools; then
1337 + emake -C "${S}"/nvidia-settings-${PV}/src \
1338 + AR="$(tc-getAR)" \
1339 + CC="$(tc-getCC)" \
1340 + LIBDIR="$(get_libdir)" \
1341 + NV_VERBOSE=1 \
1342 + RANLIB="$(tc-getRANLIB)" \
1343 + DO_STRIP= \
1344 + build-xnvctrl
1345 +
1346 + emake -C "${S}"/nvidia-settings-${PV}/src \
1347 + CC="$(tc-getCC)" \
1348 + GTK3_AVAILABLE=$(usex gtk3 1 0) \
1349 + LD="$(tc-getCC)" \
1350 + LIBDIR="$(get_libdir)" \
1351 + NVML_ENABLED=0 \
1352 + NV_USE_BUNDLED_LIBJANSSON=0 \
1353 + NV_VERBOSE=1 \
1354 + DO_STRIP=
1355 + fi
1356 +}
1357 +
1358 +# Install nvidia library:
1359 +# the first parameter is the library to install
1360 +# the second parameter is the provided soversion
1361 +# the third parameter is the target directory if it is not /usr/lib
1362 +donvidia() {
1363 + # Full path to library
1364 + nv_LIB="${1}"
1365 +
1366 + # SOVER to use
1367 + nv_SOVER="$(scanelf -qF'%S#F' ${nv_LIB})"
1368 +
1369 + # Where to install
1370 + nv_DEST="${2}"
1371 +
1372 + # Get just the library name
1373 + nv_LIBNAME=$(basename "${nv_LIB}")
1374 +
1375 + if [[ "${nv_DEST}" ]]; then
1376 + exeinto ${nv_DEST}
1377 + action="doexe"
1378 + else
1379 + nv_DEST="/usr/$(get_libdir)"
1380 + action="dolib.so"
1381 + fi
1382 +
1383 + # Install the library
1384 + ${action} ${nv_LIB} || die "failed to install ${nv_LIBNAME}"
1385 +
1386 + # If the library has a SONAME and SONAME does not match the library name,
1387 + # then we need to create a symlink
1388 + if [[ ${nv_SOVER} ]] && ! [[ "${nv_SOVER}" = "${nv_LIBNAME}" ]]; then
1389 + dosym ${nv_LIBNAME} ${nv_DEST}/${nv_SOVER} \
1390 + || die "failed to create ${nv_DEST}/${nv_SOVER} symlink"
1391 + fi
1392 +
1393 + dosym ${nv_LIBNAME} ${nv_DEST}/${nv_LIBNAME/.so*/.so} \
1394 + || die "failed to create ${nv_LIBNAME/.so*/.so} symlink"
1395 +}
1396 +
1397 +src_install() {
1398 + if use driver && use kernel_linux; then
1399 + linux-mod_src_install
1400 +
1401 + # Add the aliases
1402 + # This file is tweaked with the appropriate video group in
1403 + # pkg_preinst, see bug #491414
1404 + insinto /etc/modprobe.d
1405 + newins "${FILESDIR}"/nvidia-169.07 nvidia.conf
1406 + doins "${FILESDIR}"/nvidia-rmmod.conf
1407 +
1408 + # Ensures that our device nodes are created when not using X
1409 + exeinto "$(get_udevdir)"
1410 + newexe "${FILESDIR}"/nvidia-udev.sh-r1 nvidia-udev.sh
1411 + udev_newrules "${FILESDIR}"/nvidia.udev-rule 99-nvidia.rules
1412 + elif use kernel_FreeBSD; then
1413 + if use x86-fbsd; then
1414 + insinto /boot/modules
1415 + doins "${S}/src/nvidia.kld"
1416 + fi
1417 +
1418 + exeinto /boot/modules
1419 + doexe "${S}/src/nvidia.ko"
1420 + fi
1421 +
1422 + # NVIDIA kernel <-> userspace driver config lib
1423 + donvidia ${NV_OBJ}/libnvidia-cfg.so.${NV_SOVER}
1424 +
1425 + # NVIDIA framebuffer capture library
1426 + donvidia ${NV_OBJ}/libnvidia-fbc.so.${NV_SOVER}
1427 +
1428 + # NVIDIA video encode/decode <-> CUDA
1429 + if use kernel_linux; then
1430 + donvidia ${NV_OBJ}/libnvcuvid.so.${NV_SOVER}
1431 + donvidia ${NV_OBJ}/libnvidia-encode.so.${NV_SOVER}
1432 + fi
1433 +
1434 + if use X; then
1435 + # Xorg DDX driver
1436 + insinto /usr/$(get_libdir)/xorg/modules/drivers
1437 + doins ${NV_X11}/nvidia_drv.so
1438 +
1439 + # Xorg GLX driver
1440 + donvidia ${NV_X11}/libglx.so.${NV_SOVER} \
1441 + /usr/$(get_libdir)/opengl/nvidia/extensions
1442 +
1443 + # Xorg nvidia.conf
1444 + if has_version '>=x11-base/xorg-server-1.16'; then
1445 + insinto /usr/share/X11/xorg.conf.d
1446 + newins {,50-}nvidia-drm-outputclass.conf
1447 + fi
1448 + fi
1449 +
1450 + # OpenCL ICD for NVIDIA
1451 + if use kernel_linux; then
1452 + insinto /etc/OpenCL/vendors
1453 + doins ${NV_OBJ}/nvidia.icd
1454 + fi
1455 +
1456 + # Documentation
1457 + dohtml ${NV_DOC}/html/*
1458 + if use kernel_FreeBSD; then
1459 + dodoc "${NV_DOC}/README"
1460 + use X && doman "${NV_MAN}/nvidia-xconfig.1"
1461 + use tools && doman "${NV_MAN}/nvidia-settings.1"
1462 + else
1463 + # Docs
1464 + newdoc "${NV_DOC}/README.txt" README
1465 + dodoc "${NV_DOC}/NVIDIA_Changelog"
1466 + doman "${NV_MAN}/nvidia-smi.1.gz"
1467 + use X && doman "${NV_MAN}/nvidia-xconfig.1.gz"
1468 + use tools && doman "${NV_MAN}/nvidia-settings.1.gz"
1469 + doman "${NV_MAN}/nvidia-cuda-mps-control.1.gz"
1470 + fi
1471 +
1472 + # Helper Apps
1473 + exeinto /opt/bin/
1474 +
1475 + if use X; then
1476 + doexe ${NV_OBJ}/nvidia-xconfig
1477 +
1478 + insinto /etc/vulkan/icd.d
1479 + doins nvidia_icd.json
1480 + fi
1481 +
1482 + if use kernel_linux; then
1483 + doexe ${NV_OBJ}/nvidia-cuda-mps-control
1484 + doexe ${NV_OBJ}/nvidia-cuda-mps-server
1485 + doexe ${NV_OBJ}/nvidia-debugdump
1486 + doexe ${NV_OBJ}/nvidia-persistenced
1487 + doexe ${NV_OBJ}/nvidia-smi
1488 +
1489 + # install nvidia-modprobe setuid and symlink in /usr/bin (bug #505092)
1490 + doexe ${NV_OBJ}/nvidia-modprobe
1491 + fowners root:video /opt/bin/nvidia-modprobe
1492 + fperms 4710 /opt/bin/nvidia-modprobe
1493 + dosym /{opt,usr}/bin/nvidia-modprobe
1494 +
1495 + doman nvidia-cuda-mps-control.1.gz
1496 + doman nvidia-modprobe.1.gz
1497 + doman nvidia-persistenced.1.gz
1498 + newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi
1499 + newconfd "${FILESDIR}/nvidia-persistenced.conf" nvidia-persistenced
1500 + newinitd "${FILESDIR}/nvidia-persistenced.init" nvidia-persistenced
1501 + fi
1502 +
1503 + if use tools; then
1504 + emake -C "${S}"/nvidia-settings-${PV}/src/ \
1505 + DESTDIR="${D}" \
1506 + GTK3_AVAILABLE=$(usex gtk3 1 0) \
1507 + LIBDIR="${D}/usr/$(get_libdir)" \
1508 + NV_USE_BUNDLED_LIBJANSSON=0 \
1509 + NV_VERBOSE=1 \
1510 + PREFIX=/usr \
1511 + DO_STRIP= \
1512 + install
1513 +
1514 + if use static-libs; then
1515 + dolib.a "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/libXNVCtrl.a
1516 +
1517 + insinto /usr/include/NVCtrl
1518 + doins "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/*.h
1519 + fi
1520 +
1521 + insinto /usr/share/nvidia/
1522 + doins nvidia-application-profiles-${PV}-key-documentation
1523 +
1524 + insinto /etc/nvidia
1525 + newins \
1526 + nvidia-application-profiles-${PV}-rc nvidia-application-profiles-rc
1527 +
1528 + # There is no icon in the FreeBSD tarball.
1529 + use kernel_FreeBSD || \
1530 + doicon ${NV_OBJ}/nvidia-settings.png
1531 +
1532 + domenu "${FILESDIR}"/nvidia-settings.desktop
1533 +
1534 + exeinto /etc/X11/xinit/xinitrc.d
1535 + newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings
1536 + fi
1537 +
1538 + dobin ${NV_OBJ}/nvidia-bug-report.sh
1539 +
1540 + if has_multilib_profile && use multilib; then
1541 + local OABI=${ABI}
1542 + for ABI in $(get_install_abis); do
1543 + src_install-libs
1544 + done
1545 + ABI=${OABI}
1546 + unset OABI
1547 + else
1548 + src_install-libs
1549 + fi
1550 +
1551 + is_final_abi || die "failed to iterate through all ABIs"
1552 +
1553 + readme.gentoo_create_doc
1554 +}
1555 +
1556 +src_install-libs() {
1557 + local inslibdir=$(get_libdir)
1558 + local GL_ROOT="/usr/$(get_libdir)/opengl/nvidia/lib"
1559 + local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia"
1560 + local libdir=${NV_OBJ}
1561 +
1562 + if use kernel_linux && has_multilib_profile && [[ ${ABI} == "x86" ]]; then
1563 + libdir=${NV_OBJ}/32
1564 + fi
1565 +
1566 + if use X; then
1567 + NV_GLX_LIBRARIES=(
1568 + "libEGL.so.1 ${GL_ROOT}"
1569 + "libEGL_nvidia.so.${NV_SOVER} ${GL_ROOT}"
1570 + "libGL.so.$(usex compat ${NV_SOVER} 1.0.0) ${GL_ROOT}"
1571 + "libGLESv1_CM.so.1 ${GL_ROOT}"
1572 + "libGLESv1_CM_nvidia.so.${NV_SOVER} ${GL_ROOT}"
1573 + "libGLESv2.so.2 ${GL_ROOT}"
1574 + "libGLESv2_nvidia.so.${NV_SOVER} ${GL_ROOT}"
1575 + "libGLX.so.0 ${GL_ROOT}"
1576 + "libGLX_nvidia.so.${NV_SOVER} ${GL_ROOT}"
1577 + "libGLdispatch.so.0 ${GL_ROOT}"
1578 + "libOpenCL.so.1.0.0 ${CL_ROOT}"
1579 + "libOpenGL.so.0 ${GL_ROOT}"
1580 + "libcuda.so.${NV_SOVER}"
1581 + "libnvcuvid.so.${NV_SOVER}"
1582 + "libnvidia-compiler.so.${NV_SOVER}"
1583 + "libnvidia-eglcore.so.${NV_SOVER}"
1584 + "libnvidia-encode.so.${NV_SOVER}"
1585 + "libnvidia-fatbinaryloader.so.${NV_SOVER}"
1586 + "libnvidia-fbc.so.${NV_SOVER}"
1587 + "libnvidia-glcore.so.${NV_SOVER}"
1588 + "libnvidia-glsi.so.${NV_SOVER}"
1589 + "libnvidia-ifr.so.${NV_SOVER}"
1590 + "libnvidia-opencl.so.${NV_SOVER}"
1591 + "libnvidia-ptxjitcompiler.so.${NV_SOVER}"
1592 + "libvdpau_nvidia.so.${NV_SOVER}"
1593 + )
1594 +
1595 + if use wayland && has_multilib_profile && [[ ${ABI} == "amd64" ]];
1596 + then
1597 + NV_GLX_LIBRARIES+=(
1598 + "libnvidia-egl-wayland.so.${NV_SOVER}"
1599 + )
1600 + fi
1601 +
1602 + if use kernel_linux && has_multilib_profile && [[ ${ABI} == "amd64" ]];
1603 + then
1604 + NV_GLX_LIBRARIES+=(
1605 + "libnvidia-wfb.so.${NV_SOVER}"
1606 + )
1607 + fi
1608 +
1609 + if use kernel_FreeBSD; then
1610 + NV_GLX_LIBRARIES+=(
1611 + "libnvidia-tls.so.${NV_SOVER}"
1612 + )
1613 + fi
1614 +
1615 + if use kernel_linux; then
1616 + NV_GLX_LIBRARIES+=(
1617 + "libnvidia-ml.so.${NV_SOVER}"
1618 + "tls/libnvidia-tls.so.${NV_SOVER}"
1619 + )
1620 + fi
1621 +
1622 + for NV_LIB in "${NV_GLX_LIBRARIES[@]}"; do
1623 + donvidia ${libdir}/${NV_LIB}
1624 + done
1625 + fi
1626 +}
1627 +
1628 +pkg_preinst() {
1629 + if use driver && use kernel_linux; then
1630 + linux-mod_pkg_preinst
1631 +
1632 + local videogroup="$(egetent group video | cut -d ':' -f 3)"
1633 + if [ -z "${videogroup}" ]; then
1634 + eerror "Failed to determine the video group gid"
1635 + die "Failed to determine the video group gid"
1636 + else
1637 + sed -i \
1638 + -e "s:PACKAGE:${PF}:g" \
1639 + -e "s:VIDEOGID:${videogroup}:" \
1640 + "${D}"/etc/modprobe.d/nvidia.conf || die
1641 + fi
1642 + fi
1643 +
1644 + # Clean the dynamic libGL stuff's home to ensure
1645 + # we dont have stale libs floating around
1646 + if [ -d "${ROOT}"/usr/lib/opengl/nvidia ]; then
1647 + rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
1648 + fi
1649 + # Make sure we nuke the old nvidia-glx's env.d file
1650 + if [ -e "${ROOT}"/etc/env.d/09nvidia ]; then
1651 + rm -f "${ROOT}"/etc/env.d/09nvidia
1652 + fi
1653 +}
1654 +
1655 +pkg_postinst() {
1656 + use driver && use kernel_linux && linux-mod_pkg_postinst
1657 +
1658 + # Switch to the nvidia implementation
1659 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old nvidia
1660 + "${ROOT}"/usr/bin/eselect opencl set --use-old nvidia
1661 +
1662 + readme.gentoo_print_elog
1663 +
1664 + if ! use X; then
1665 + elog "You have elected to not install the X.org driver. Along with"
1666 + elog "this the OpenGL libraries and VDPAU libraries were not"
1667 + elog "installed. Additionally, once the driver is loaded your card"
1668 + elog "and fan will run at max speed which may not be desirable."
1669 + elog "Use the 'nvidia-smi' init script to have your card and fan"
1670 + elog "speed scale appropriately."
1671 + elog
1672 + fi
1673 + if ! use tools; then
1674 + elog "USE=tools controls whether the nvidia-settings application"
1675 + elog "is installed. If you would like to use it, enable that"
1676 + elog "flag and re-emerge this ebuild. Optionally you can install"
1677 + elog "media-video/nvidia-settings"
1678 + elog
1679 + fi
1680 +}
1681 +
1682 +pkg_prerm() {
1683 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
1684 +}
1685 +
1686 +pkg_postrm() {
1687 + use driver && use kernel_linux && linux-mod_pkg_postrm
1688 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
1689 +}
1690
1691 diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-375.10-r1.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-375.10-r1.ebuild
1692 new file mode 100644
1693 index 00000000..7c86eb1
1694 --- /dev/null
1695 +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-375.10-r1.ebuild
1696 @@ -0,0 +1,560 @@
1697 +# Copyright 1999-2016 Gentoo Foundation
1698 +# Distributed under the terms of the GNU General Public License v2
1699 +# $Id$
1700 +
1701 +EAPI=6
1702 +
1703 +inherit eutils flag-o-matic linux-info linux-mod multilib nvidia-driver \
1704 + portability toolchain-funcs unpacker user udev
1705 +
1706 +NV_URI="http://us.download.nvidia.com/XFree86/"
1707 +X86_NV_PACKAGE="NVIDIA-Linux-x86-${PV}"
1708 +AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}"
1709 +ARM_NV_PACKAGE="NVIDIA-Linux-armv7l-gnueabihf-${PV}"
1710 +X86_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86-${PV}"
1711 +AMD64_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86_64-${PV}"
1712 +
1713 +DESCRIPTION="NVIDIA Accelerated Graphics Driver"
1714 +HOMEPAGE="http://www.nvidia.com/ http://www.nvidia.com/Download/Find.aspx"
1715 +SRC_URI="
1716 + amd64-fbsd? ( ${NV_URI}FreeBSD-x86_64/${PV}/${AMD64_FBSD_NV_PACKAGE}.tar.gz )
1717 + amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run )
1718 + arm? ( ${NV_URI}Linux-x86-ARM/${PV}/${ARM_NV_PACKAGE}.run )
1719 + x86-fbsd? ( ${NV_URI}FreeBSD-x86/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz )
1720 + x86? ( ${NV_URI}Linux-x86/${PV}/${X86_NV_PACKAGE}.run )
1721 + tools? (
1722 + ftp://download.nvidia.com/XFree86/nvidia-settings/nvidia-settings-${PV}.tar.bz2
1723 + https://raw.githubusercontent.com/NVIDIA/nvidia-settings/168e17f53098254b4a5ab93eeb2f23c80ca1d97f/src/nvml.h -> nvml.h-${PV}
1724 + )
1725 +"
1726 +
1727 +LICENSE="GPL-2 NVIDIA-r2"
1728 +SLOT="0/${PV%.*}"
1729 +KEYWORDS="-* ~amd64 ~x86 ~amd64-fbsd ~x86-fbsd"
1730 +RESTRICT="bindist mirror"
1731 +EMULTILIB_PKG="true"
1732 +
1733 +IUSE="acpi compat +driver gtk3 kernel_FreeBSD kernel_linux +kms multilib pax_kernel static-libs +tools uvm wayland +X"
1734 +REQUIRED_USE="
1735 + tools? ( X )
1736 + static-libs? ( tools )
1737 +"
1738 +
1739 +COMMON="
1740 + app-eselect/eselect-opencl
1741 + kernel_linux? ( >=sys-libs/glibc-2.6.1 )
1742 + tools? (
1743 + dev-libs/atk
1744 + dev-libs/glib:2
1745 + dev-libs/jansson
1746 + gtk3? ( x11-libs/gtk+:3 )
1747 + x11-libs/cairo
1748 + x11-libs/gdk-pixbuf[X]
1749 + x11-libs/gtk+:2
1750 + x11-libs/libX11
1751 + x11-libs/libXext
1752 + x11-libs/libXrandr
1753 + x11-libs/libXv
1754 + x11-libs/libXxf86vm
1755 + x11-libs/pango[X]
1756 + )
1757 + X? (
1758 + >=app-eselect/eselect-opengl-1.0.9
1759 + app-misc/pax-utils
1760 + )
1761 +"
1762 +DEPEND="
1763 + ${COMMON}
1764 + kernel_linux? ( virtual/linux-sources )
1765 +"
1766 +RDEPEND="
1767 + ${COMMON}
1768 + acpi? ( sys-power/acpid )
1769 + tools? ( !media-video/nvidia-settings )
1770 + wayland? ( dev-libs/wayland )
1771 + X? (
1772 + <x11-base/xorg-server-1.18.99:=
1773 + >=x11-libs/libvdpau-1.0
1774 + multilib? (
1775 + >=x11-libs/libX11-1.6.2[abi_x86_32]
1776 + >=x11-libs/libXext-1.3.2[abi_x86_32]
1777 + )
1778 + )
1779 +"
1780 +
1781 +QA_PREBUILT="opt/* usr/lib*"
1782 +
1783 +S=${WORKDIR}/
1784 +
1785 +pkg_pretend() {
1786 + if use amd64 && has_multilib_profile && \
1787 + [ "${DEFAULT_ABI}" != "amd64" ]; then
1788 + eerror "This ebuild doesn't currently support changing your default ABI"
1789 + die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
1790 + fi
1791 +
1792 + if use kernel_linux && kernel_is ge 4 8; then
1793 + ewarn "Gentoo supports kernels which are supported by NVIDIA"
1794 + ewarn "which are limited to the following kernels:"
1795 + ewarn "<sys-kernel/gentoo-sources-4.8"
1796 + ewarn "<sys-kernel/vanilla-sources-4.8"
1797 + ewarn ""
1798 + ewarn "You are free to utilize epatch_user to provide whatever"
1799 + ewarn "support you feel is appropriate, but will not receive"
1800 + ewarn "support as a result of those changes."
1801 + ewarn ""
1802 + ewarn "Do not file a bug report about this."
1803 + ewarn ""
1804 + fi
1805 +
1806 + # Since Nvidia ships many different series of drivers, we need to give the user
1807 + # some kind of guidance as to what version they should install. This tries
1808 + # to point the user in the right direction but can't be perfect. check
1809 + # nvidia-driver.eclass
1810 + nvidia-driver-check-warning
1811 +
1812 + # Kernel features/options to check for
1813 + CONFIG_CHECK="~ZONE_DMA ~MTRR ~SYSVIPC ~!LOCKDEP"
1814 + use x86 && CONFIG_CHECK+=" ~HIGHMEM"
1815 +
1816 + # Now do the above checks
1817 + use kernel_linux && check_extra_config
1818 +}
1819 +
1820 +pkg_setup() {
1821 + # try to turn off distcc and ccache for people that have a problem with it
1822 + export DISTCC_DISABLE=1
1823 + export CCACHE_DISABLE=1
1824 +
1825 + if use driver && use kernel_linux; then
1826 + MODULE_NAMES="nvidia(video:${S}/kernel)"
1827 + use uvm && MODULE_NAMES+=" nvidia-uvm(video:${S}/kernel)"
1828 + use kms && MODULE_NAMES+=" nvidia-modeset(video:${S}/kernel) nvidia-drm(video:${S}/kernel)"
1829 +
1830 + # This needs to run after MODULE_NAMES (so that the eclass checks
1831 + # whether the kernel supports loadable modules) but before BUILD_PARAMS
1832 + # is set (so that KV_DIR is populated).
1833 + linux-mod_pkg_setup
1834 +
1835 + BUILD_PARAMS="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \
1836 + SYSOUT=${KV_OUT_DIR} CC=$(tc-getBUILD_CC) NV_VERBOSE=1"
1837 +
1838 + # linux-mod_src_compile calls set_arch_to_kernel, which
1839 + # sets the ARCH to x86 but NVIDIA's wrapping Makefile
1840 + # expects x86_64 or i386 and then converts it to x86
1841 + # later on in the build process
1842 + BUILD_FIXES="ARCH=$(uname -m | sed -e 's/i.86/i386/')"
1843 + fi
1844 +
1845 + if use kernel_linux && kernel_is lt 2 6 9; then
1846 + eerror "You must build this against 2.6.9 or higher kernels."
1847 + fi
1848 +
1849 + # set variables to where files are in the package structure
1850 + if use kernel_FreeBSD; then
1851 + use x86-fbsd && S="${WORKDIR}/${X86_FBSD_NV_PACKAGE}"
1852 + use amd64-fbsd && S="${WORKDIR}/${AMD64_FBSD_NV_PACKAGE}"
1853 + NV_DOC="${S}/doc"
1854 + NV_OBJ="${S}/obj"
1855 + NV_SRC="${S}/src"
1856 + NV_MAN="${S}/x11/man"
1857 + NV_X11="${S}/obj"
1858 + NV_SOVER=1
1859 + elif use kernel_linux; then
1860 + NV_DOC="${S}"
1861 + NV_OBJ="${S}"
1862 + NV_SRC="${S}/kernel"
1863 + NV_MAN="${S}"
1864 + NV_X11="${S}"
1865 + NV_SOVER=${PV}
1866 + else
1867 + die "Could not determine proper NVIDIA package"
1868 + fi
1869 +}
1870 +
1871 +src_prepare() {
1872 + if use tools; then
1873 + cp "${DISTDIR}"/nvml.h-${PV} "${S}"/nvidia-settings-${PV}/src/nvml.h || die
1874 + sed -i -e 's|-lnvidia-ml|-L../../ &|g' nvidia-settings-${PV}/src/Makefile || die
1875 + fi
1876 +
1877 + eapply "${FILESDIR}"/${P}-profiles-rc.patch
1878 +
1879 + if use pax_kernel; then
1880 + ewarn "Using PAX patches is not supported. You will be asked to"
1881 + ewarn "use a standard kernel should you have issues. Should you"
1882 + ewarn "need support with these patches, contact the PaX team."
1883 + eapply "${FILESDIR}"/${PN}-364.12-pax.patch
1884 + fi
1885 +
1886 + # Allow user patches so they can support RC kernels and whatever else
1887 + eapply_user
1888 +}
1889 +
1890 +src_compile() {
1891 + # This is already the default on Linux, as there's no toplevel Makefile, but
1892 + # on FreeBSD there's one and triggers the kernel module build, as we install
1893 + # it by itself, pass this.
1894 +
1895 + cd "${NV_SRC}"
1896 + if use kernel_FreeBSD; then
1897 + MAKE="$(get_bmake)" CFLAGS="-Wno-sign-compare" emake CC="$(tc-getCC)" \
1898 + LD="$(tc-getLD)" LDFLAGS="$(raw-ldflags)" || die
1899 + elif use driver && use kernel_linux; then
1900 + MAKEOPTS=-j1 linux-mod_src_compile
1901 + fi
1902 +
1903 + if use tools; then
1904 + emake -C "${S}"/nvidia-settings-${PV}/src \
1905 + AR="$(tc-getAR)" \
1906 + CC="$(tc-getCC)" \
1907 + LIBDIR="$(get_libdir)" \
1908 + NV_VERBOSE=1 \
1909 + RANLIB="$(tc-getRANLIB)" \
1910 + DO_STRIP= \
1911 + build-xnvctrl
1912 +
1913 + emake -C "${S}"/nvidia-settings-${PV}/src \
1914 + CC="$(tc-getCC)" \
1915 + GTK3_AVAILABLE=$(usex gtk3 1 0) \
1916 + LD="$(tc-getCC)" \
1917 + LIBDIR="$(get_libdir)" \
1918 + NVML_ENABLED=0 \
1919 + NV_USE_BUNDLED_LIBJANSSON=0 \
1920 + NV_VERBOSE=1 \
1921 + DO_STRIP=
1922 + fi
1923 +}
1924 +
1925 +# Install nvidia library:
1926 +# the first parameter is the library to install
1927 +# the second parameter is the provided soversion
1928 +# the third parameter is the target directory if it is not /usr/lib
1929 +donvidia() {
1930 + # Full path to library
1931 + nv_LIB="${1}"
1932 +
1933 + # SOVER to use
1934 + nv_SOVER="$(scanelf -qF'%S#F' ${nv_LIB})"
1935 +
1936 + # Where to install
1937 + nv_DEST="${2}"
1938 +
1939 + # Get just the library name
1940 + nv_LIBNAME=$(basename "${nv_LIB}")
1941 +
1942 + if [[ "${nv_DEST}" ]]; then
1943 + exeinto ${nv_DEST}
1944 + action="doexe"
1945 + else
1946 + nv_DEST="/usr/$(get_libdir)"
1947 + action="dolib.so"
1948 + fi
1949 +
1950 + # Install the library
1951 + ${action} ${nv_LIB} || die "failed to install ${nv_LIBNAME}"
1952 +
1953 + # If the library has a SONAME and SONAME does not match the library name,
1954 + # then we need to create a symlink
1955 + if [[ ${nv_SOVER} ]] && ! [[ "${nv_SOVER}" = "${nv_LIBNAME}" ]]; then
1956 + dosym ${nv_LIBNAME} ${nv_DEST}/${nv_SOVER} \
1957 + || die "failed to create ${nv_DEST}/${nv_SOVER} symlink"
1958 + fi
1959 +
1960 + dosym ${nv_LIBNAME} ${nv_DEST}/${nv_LIBNAME/.so*/.so} \
1961 + || die "failed to create ${nv_LIBNAME/.so*/.so} symlink"
1962 +}
1963 +
1964 +src_install() {
1965 + if use driver && use kernel_linux; then
1966 + linux-mod_src_install
1967 +
1968 + # Add the aliases
1969 + # This file is tweaked with the appropriate video group in
1970 + # pkg_preinst, see bug #491414
1971 + insinto /etc/modprobe.d
1972 + newins "${FILESDIR}"/nvidia-169.07 nvidia.conf
1973 + doins "${FILESDIR}"/nvidia-rmmod.conf
1974 +
1975 + # Ensures that our device nodes are created when not using X
1976 + exeinto "$(get_udevdir)"
1977 + newexe "${FILESDIR}"/nvidia-udev.sh-r1 nvidia-udev.sh
1978 + udev_newrules "${FILESDIR}"/nvidia.udev-rule 99-nvidia.rules
1979 + elif use kernel_FreeBSD; then
1980 + if use x86-fbsd; then
1981 + insinto /boot/modules
1982 + doins "${S}/src/nvidia.kld"
1983 + fi
1984 +
1985 + exeinto /boot/modules
1986 + doexe "${S}/src/nvidia.ko"
1987 + fi
1988 +
1989 + # NVIDIA kernel <-> userspace driver config lib
1990 + donvidia ${NV_OBJ}/libnvidia-cfg.so.${NV_SOVER}
1991 +
1992 + # NVIDIA framebuffer capture library
1993 + donvidia ${NV_OBJ}/libnvidia-fbc.so.${NV_SOVER}
1994 +
1995 + # NVIDIA video encode/decode <-> CUDA
1996 + if use kernel_linux; then
1997 + donvidia ${NV_OBJ}/libnvcuvid.so.${NV_SOVER}
1998 + donvidia ${NV_OBJ}/libnvidia-encode.so.${NV_SOVER}
1999 + fi
2000 +
2001 + if use X; then
2002 + # Xorg DDX driver
2003 + insinto /usr/$(get_libdir)/xorg/modules/drivers
2004 + doins ${NV_X11}/nvidia_drv.so
2005 +
2006 + # Xorg GLX driver
2007 + donvidia ${NV_X11}/libglx.so.${NV_SOVER} \
2008 + /usr/$(get_libdir)/opengl/nvidia/extensions
2009 +
2010 + # Xorg nvidia.conf
2011 + if has_version '>=x11-base/xorg-server-1.16'; then
2012 + insinto /usr/share/X11/xorg.conf.d
2013 + newins {,50-}nvidia-drm-outputclass.conf
2014 + fi
2015 + fi
2016 +
2017 + # OpenCL ICD for NVIDIA
2018 + if use kernel_linux; then
2019 + insinto /etc/OpenCL/vendors
2020 + doins ${NV_OBJ}/nvidia.icd
2021 + fi
2022 +
2023 + # Documentation
2024 + dohtml ${NV_DOC}/html/*
2025 + if use kernel_FreeBSD; then
2026 + dodoc "${NV_DOC}/README"
2027 + use X && doman "${NV_MAN}/nvidia-xconfig.1"
2028 + use tools && doman "${NV_MAN}/nvidia-settings.1"
2029 + else
2030 + # Docs
2031 + newdoc "${NV_DOC}/README.txt" README
2032 + dodoc "${NV_DOC}/NVIDIA_Changelog"
2033 + doman "${NV_MAN}/nvidia-smi.1.gz"
2034 + use X && doman "${NV_MAN}/nvidia-xconfig.1.gz"
2035 + use tools && doman "${NV_MAN}/nvidia-settings.1.gz"
2036 + doman "${NV_MAN}/nvidia-cuda-mps-control.1.gz"
2037 + fi
2038 +
2039 + # Helper Apps
2040 + exeinto /opt/bin/
2041 +
2042 + if use X; then
2043 + doexe ${NV_OBJ}/nvidia-xconfig
2044 +
2045 + insinto /etc/vulkan/icd.d
2046 + doins nvidia_icd.json
2047 + fi
2048 +
2049 + if use kernel_linux; then
2050 + doexe ${NV_OBJ}/nvidia-cuda-mps-control
2051 + doexe ${NV_OBJ}/nvidia-cuda-mps-server
2052 + doexe ${NV_OBJ}/nvidia-debugdump
2053 + doexe ${NV_OBJ}/nvidia-persistenced
2054 + doexe ${NV_OBJ}/nvidia-smi
2055 +
2056 + # install nvidia-modprobe setuid and symlink in /usr/bin (bug #505092)
2057 + doexe ${NV_OBJ}/nvidia-modprobe
2058 + fowners root:video /opt/bin/nvidia-modprobe
2059 + fperms 4710 /opt/bin/nvidia-modprobe
2060 + dosym /{opt,usr}/bin/nvidia-modprobe
2061 +
2062 + doman nvidia-cuda-mps-control.1.gz
2063 + doman nvidia-modprobe.1.gz
2064 + doman nvidia-persistenced.1.gz
2065 + newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi
2066 + newconfd "${FILESDIR}/nvidia-persistenced.conf" nvidia-persistenced
2067 + newinitd "${FILESDIR}/nvidia-persistenced.init" nvidia-persistenced
2068 + fi
2069 +
2070 + if use tools; then
2071 + emake -C "${S}"/nvidia-settings-${PV}/src/ \
2072 + DESTDIR="${D}" \
2073 + GTK3_AVAILABLE=$(usex gtk3 1 0) \
2074 + LIBDIR="${D}/usr/$(get_libdir)" \
2075 + NV_USE_BUNDLED_LIBJANSSON=0 \
2076 + NV_VERBOSE=1 \
2077 + PREFIX=/usr \
2078 + DO_STRIP= \
2079 + install
2080 +
2081 + if use static-libs; then
2082 + dolib.a "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/libXNVCtrl.a
2083 +
2084 + insinto /usr/include/NVCtrl
2085 + doins "${S}"/nvidia-settings-${PV}/src/libXNVCtrl/*.h
2086 + fi
2087 +
2088 + insinto /usr/share/nvidia/
2089 + doins nvidia-application-profiles-${PV}-key-documentation
2090 +
2091 + insinto /etc/nvidia
2092 + newins \
2093 + nvidia-application-profiles-${PV}-rc nvidia-application-profiles-rc
2094 +
2095 + # There is no icon in the FreeBSD tarball.
2096 + use kernel_FreeBSD || \
2097 + doicon ${NV_OBJ}/nvidia-settings.png
2098 +
2099 + domenu "${FILESDIR}"/nvidia-settings.desktop
2100 +
2101 + exeinto /etc/X11/xinit/xinitrc.d
2102 + newexe "${FILESDIR}"/95-nvidia-settings-r1 95-nvidia-settings
2103 + fi
2104 +
2105 + dobin ${NV_OBJ}/nvidia-bug-report.sh
2106 +
2107 + if has_multilib_profile && use multilib; then
2108 + local OABI=${ABI}
2109 + for ABI in $(get_install_abis); do
2110 + src_install-libs
2111 + done
2112 + ABI=${OABI}
2113 + unset OABI
2114 + else
2115 + src_install-libs
2116 + fi
2117 +
2118 + is_final_abi || die "failed to iterate through all ABIs"
2119 +
2120 + readme.gentoo_create_doc
2121 +}
2122 +
2123 +src_install-libs() {
2124 + local inslibdir=$(get_libdir)
2125 + local GL_ROOT="/usr/$(get_libdir)/opengl/nvidia/lib"
2126 + local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia"
2127 + local libdir=${NV_OBJ}
2128 +
2129 + if use kernel_linux && has_multilib_profile && [[ ${ABI} == "x86" ]]; then
2130 + libdir=${NV_OBJ}/32
2131 + fi
2132 +
2133 + if use X; then
2134 + NV_GLX_LIBRARIES=(
2135 + "libEGL.so.1 ${GL_ROOT}"
2136 + "libEGL_nvidia.so.${NV_SOVER} ${GL_ROOT}"
2137 + "libGL.so.$(usex compat ${NV_SOVER} 1.0.0) ${GL_ROOT}"
2138 + "libGLESv1_CM.so.1 ${GL_ROOT}"
2139 + "libGLESv1_CM_nvidia.so.${NV_SOVER} ${GL_ROOT}"
2140 + "libGLESv2.so.2 ${GL_ROOT}"
2141 + "libGLESv2_nvidia.so.${NV_SOVER} ${GL_ROOT}"
2142 + "libGLX.so.0 ${GL_ROOT}"
2143 + "libGLX_nvidia.so.${NV_SOVER} ${GL_ROOT}"
2144 + "libGLdispatch.so.0 ${GL_ROOT}"
2145 + "libOpenCL.so.1.0.0 ${CL_ROOT}"
2146 + "libOpenGL.so.0 ${GL_ROOT}"
2147 + "libcuda.so.${NV_SOVER}"
2148 + "libnvcuvid.so.${NV_SOVER}"
2149 + "libnvidia-compiler.so.${NV_SOVER}"
2150 + "libnvidia-eglcore.so.${NV_SOVER}"
2151 + "libnvidia-encode.so.${NV_SOVER}"
2152 + "libnvidia-fatbinaryloader.so.${NV_SOVER}"
2153 + "libnvidia-fbc.so.${NV_SOVER}"
2154 + "libnvidia-glcore.so.${NV_SOVER}"
2155 + "libnvidia-glsi.so.${NV_SOVER}"
2156 + "libnvidia-ifr.so.${NV_SOVER}"
2157 + "libnvidia-opencl.so.${NV_SOVER}"
2158 + "libnvidia-ptxjitcompiler.so.${NV_SOVER}"
2159 + "libvdpau_nvidia.so.${NV_SOVER}"
2160 + )
2161 +
2162 + if use wayland && has_multilib_profile && [[ ${ABI} == "amd64" ]];
2163 + then
2164 + NV_GLX_LIBRARIES+=(
2165 + "libnvidia-egl-wayland.so.${NV_SOVER}"
2166 + )
2167 + fi
2168 +
2169 + if use kernel_linux && has_multilib_profile && [[ ${ABI} == "amd64" ]];
2170 + then
2171 + NV_GLX_LIBRARIES+=(
2172 + "libnvidia-wfb.so.${NV_SOVER}"
2173 + )
2174 + fi
2175 +
2176 + if use kernel_FreeBSD; then
2177 + NV_GLX_LIBRARIES+=(
2178 + "libnvidia-tls.so.${NV_SOVER}"
2179 + )
2180 + fi
2181 +
2182 + if use kernel_linux; then
2183 + NV_GLX_LIBRARIES+=(
2184 + "libnvidia-ml.so.${NV_SOVER}"
2185 + "tls/libnvidia-tls.so.${NV_SOVER}"
2186 + )
2187 + fi
2188 +
2189 + for NV_LIB in "${NV_GLX_LIBRARIES[@]}"; do
2190 + donvidia ${libdir}/${NV_LIB}
2191 + done
2192 + fi
2193 +}
2194 +
2195 +pkg_preinst() {
2196 + if use driver && use kernel_linux; then
2197 + linux-mod_pkg_preinst
2198 +
2199 + local videogroup="$(egetent group video | cut -d ':' -f 3)"
2200 + if [ -z "${videogroup}" ]; then
2201 + eerror "Failed to determine the video group gid"
2202 + die "Failed to determine the video group gid"
2203 + else
2204 + sed -i \
2205 + -e "s:PACKAGE:${PF}:g" \
2206 + -e "s:VIDEOGID:${videogroup}:" \
2207 + "${D}"/etc/modprobe.d/nvidia.conf || die
2208 + fi
2209 + fi
2210 +
2211 + # Clean the dynamic libGL stuff's home to ensure
2212 + # we dont have stale libs floating around
2213 + if [ -d "${ROOT}"/usr/lib/opengl/nvidia ]; then
2214 + rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
2215 + fi
2216 + # Make sure we nuke the old nvidia-glx's env.d file
2217 + if [ -e "${ROOT}"/etc/env.d/09nvidia ]; then
2218 + rm -f "${ROOT}"/etc/env.d/09nvidia
2219 + fi
2220 +}
2221 +
2222 +pkg_postinst() {
2223 + use driver && use kernel_linux && linux-mod_pkg_postinst
2224 +
2225 + # Switch to the nvidia implementation
2226 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old nvidia
2227 + "${ROOT}"/usr/bin/eselect opencl set --use-old nvidia
2228 +
2229 + readme.gentoo_print_elog
2230 +
2231 + if ! use X; then
2232 + elog "You have elected to not install the X.org driver. Along with"
2233 + elog "this the OpenGL libraries and VDPAU libraries were not"
2234 + elog "installed. Additionally, once the driver is loaded your card"
2235 + elog "and fan will run at max speed which may not be desirable."
2236 + elog "Use the 'nvidia-smi' init script to have your card and fan"
2237 + elog "speed scale appropriately."
2238 + elog
2239 + fi
2240 + if ! use tools; then
2241 + elog "USE=tools controls whether the nvidia-settings application"
2242 + elog "is installed. If you would like to use it, enable that"
2243 + elog "flag and re-emerge this ebuild. Optionally you can install"
2244 + elog "media-video/nvidia-settings"
2245 + elog
2246 + fi
2247 +}
2248 +
2249 +pkg_prerm() {
2250 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
2251 +}
2252 +
2253 +pkg_postrm() {
2254 + use driver && use kernel_linux && linux-mod_pkg_postrm
2255 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
2256 +}