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: Fri, 29 Jan 2016 06:23:03
Message-Id: 1454048550.260e654c09b73f5f309f437c13185b541d98c501.jer@gentoo
1 commit: 260e654c09b73f5f309f437c13185b541d98c501
2 Author: Jeroen Roovers <jer <AT> gentoo <DOT> org>
3 AuthorDate: Fri Jan 29 06:22:30 2016 +0000
4 Commit: Jeroen Roovers <jer <AT> gentoo <DOT> org>
5 CommitDate: Fri Jan 29 06:22:30 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=260e654c
7
8 x11-drivers/nvidia-drivers: Raise x11-base/xorg-server compatibility (bug #572730 by Martijn Schmidt).
9
10 Package-Manager: portage-2.2.27
11
12 .../nvidia-drivers/nvidia-drivers-346.96-r2.ebuild | 489 +++++++++++++++++++++
13 1 file changed, 489 insertions(+)
14
15 diff --git a/x11-drivers/nvidia-drivers/nvidia-drivers-346.96-r2.ebuild b/x11-drivers/nvidia-drivers/nvidia-drivers-346.96-r2.ebuild
16 new file mode 100644
17 index 0000000..9a45b18
18 --- /dev/null
19 +++ b/x11-drivers/nvidia-drivers/nvidia-drivers-346.96-r2.ebuild
20 @@ -0,0 +1,489 @@
21 +# Copyright 1999-2015 Gentoo Foundation
22 +# Distributed under the terms of the GNU General Public License v2
23 +# $Id$
24 +
25 +EAPI=5
26 +
27 +inherit eutils flag-o-matic linux-info linux-mod multilib nvidia-driver \
28 + portability toolchain-funcs unpacker user udev
29 +
30 +NV_URI="http://us.download.nvidia.com/XFree86/"
31 +X86_NV_PACKAGE="NVIDIA-Linux-x86-${PV}"
32 +AMD64_NV_PACKAGE="NVIDIA-Linux-x86_64-${PV}"
33 +X86_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86-${PV}"
34 +AMD64_FBSD_NV_PACKAGE="NVIDIA-FreeBSD-x86_64-${PV}"
35 +
36 +DESCRIPTION="NVIDIA Accelerated Graphics Driver"
37 +HOMEPAGE="http://www.nvidia.com/"
38 +SRC_URI="
39 + amd64-fbsd? ( ${NV_URI}FreeBSD-x86_64/${PV}/${AMD64_FBSD_NV_PACKAGE}.tar.gz )
40 + amd64? ( ${NV_URI}Linux-x86_64/${PV}/${AMD64_NV_PACKAGE}.run )
41 + x86-fbsd? ( ${NV_URI}FreeBSD-x86/${PV}/${X86_FBSD_NV_PACKAGE}.tar.gz )
42 + x86? ( ${NV_URI}Linux-x86/${PV}/${X86_NV_PACKAGE}.run )
43 +"
44 +
45 +LICENSE="GPL-2 NVIDIA-r2"
46 +SLOT="0/${PV%.*}"
47 +KEYWORDS="-* ~amd64 ~x86 ~amd64-fbsd ~x86-fbsd"
48 +RESTRICT="bindist mirror strip"
49 +EMULTILIB_PKG="true"
50 +
51 +IUSE="acpi multilib kernel_FreeBSD kernel_linux pax_kernel +tools gtk2 gtk3 +X uvm"
52 +REQUIRED_USE="
53 + tools? ( X || ( gtk2 gtk3 ) )
54 +"
55 +
56 +COMMON="
57 + app-eselect/eselect-opencl
58 + kernel_linux? ( >=sys-libs/glibc-2.6.1 )
59 + X? (
60 + >=app-eselect/eselect-opengl-1.0.9
61 + )
62 +"
63 +DEPEND="
64 + ${COMMON}
65 + app-arch/xz-utils
66 + kernel_linux? ( virtual/linux-sources )
67 +"
68 +RDEPEND="
69 + ${COMMON}
70 + acpi? ( sys-power/acpid )
71 + tools? (
72 + dev-libs/atk
73 + dev-libs/glib:2
74 + x11-libs/gdk-pixbuf
75 + gtk2? ( >=x11-libs/gtk+-2.4:2 )
76 + gtk3? ( x11-libs/gtk+:3 )
77 + x11-libs/libX11
78 + x11-libs/libXext
79 + x11-libs/pango[X]
80 + )
81 + X? (
82 + <x11-base/xorg-server-1.18.99:=
83 + >=x11-libs/libvdpau-0.3-r1
84 + multilib? (
85 + >=x11-libs/libX11-1.6.2[abi_x86_32]
86 + >=x11-libs/libXext-1.3.2[abi_x86_32]
87 + )
88 + )
89 +"
90 +
91 +QA_PREBUILT="opt/* usr/lib*"
92 +
93 +S=${WORKDIR}/
94 +
95 +pkg_pretend() {
96 + if use amd64 && has_multilib_profile && \
97 + [ "${DEFAULT_ABI}" != "amd64" ]; then
98 + eerror "This ebuild doesn't currently support changing your default ABI"
99 + die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
100 + fi
101 +
102 + if use kernel_linux && kernel_is ge 4 3; then
103 + ewarn "Gentoo supports kernels which are supported by NVIDIA"
104 + ewarn "which are limited to the following kernels:"
105 + ewarn "<sys-kernel/gentoo-sources-4.3"
106 + ewarn "<sys-kernel/vanilla-sources-4.3"
107 + ewarn ""
108 + ewarn "You are free to utilize epatch_user to provide whatever"
109 + ewarn "support you feel is appropriate, but will not receive"
110 + ewarn "support as a result of those changes."
111 + ewarn ""
112 + ewarn "Do not file a bug report about this."
113 + fi
114 +
115 + # Since Nvidia ships many different series of drivers, we need to give the user
116 + # some kind of guidance as to what version they should install. This tries
117 + # to point the user in the right direction but can't be perfect. check
118 + # nvidia-driver.eclass
119 + nvidia-driver-check-warning
120 +
121 + # Kernel features/options to check for
122 + CONFIG_CHECK="~ZONE_DMA ~MTRR ~SYSVIPC ~!LOCKDEP"
123 + use x86 && CONFIG_CHECK+=" ~HIGHMEM"
124 +
125 + # Now do the above checks
126 + use kernel_linux && check_extra_config
127 +}
128 +
129 +pkg_setup() {
130 + # try to turn off distcc and ccache for people that have a problem with it
131 + export DISTCC_DISABLE=1
132 + export CCACHE_DISABLE=1
133 +
134 + if use kernel_linux; then
135 + MODULE_NAMES="nvidia(video:${S}/kernel)"
136 + use uvm && MODULE_NAMES+=" nvidia-uvm(video:${S}/kernel/uvm)"
137 +
138 + # This needs to run after MODULE_NAMES (so that the eclass checks
139 + # whether the kernel supports loadable modules) but before BUILD_PARAMS
140 + # is set (so that KV_DIR is populated).
141 + linux-mod_pkg_setup
142 +
143 + BUILD_PARAMS="IGNORE_CC_MISMATCH=yes V=1 SYSSRC=${KV_DIR} \
144 + SYSOUT=${KV_OUT_DIR} CC=$(tc-getBUILD_CC)"
145 +
146 + # linux-mod_src_compile calls set_arch_to_kernel, which
147 + # sets the ARCH to x86 but NVIDIA's wrapping Makefile
148 + # expects x86_64 or i386 and then converts it to x86
149 + # later on in the build process
150 + BUILD_FIXES="ARCH=$(uname -m | sed -e 's/i.86/i386/')"
151 + fi
152 +
153 + # set variables to where files are in the package structure
154 + if use kernel_FreeBSD; then
155 + use x86-fbsd && S="${WORKDIR}/${X86_FBSD_NV_PACKAGE}"
156 + use amd64-fbsd && S="${WORKDIR}/${AMD64_FBSD_NV_PACKAGE}"
157 + NV_DOC="${S}/doc"
158 + NV_OBJ="${S}/obj"
159 + NV_SRC="${S}/src"
160 + NV_MAN="${S}/x11/man"
161 + NV_X11="${S}/obj"
162 + NV_SOVER=1
163 + elif use kernel_linux; then
164 + NV_DOC="${S}"
165 + NV_OBJ="${S}"
166 + NV_SRC="${S}/kernel"
167 + NV_MAN="${S}"
168 + NV_X11="${S}"
169 + NV_SOVER=${PV}
170 + else
171 + die "Could not determine proper NVIDIA package"
172 + fi
173 +}
174 +
175 +src_prepare() {
176 + # Please add a brief description for every added patch
177 +
178 + if use kernel_linux; then
179 + if kernel_is lt 2 6 9 ; then
180 + eerror "You must build this against 2.6.9 or higher kernels."
181 + fi
182 +
183 + # If greater than 2.6.5 use M= instead of SUBDIR=
184 +# convert_to_m "${NV_SRC}"/Makefile.kbuild
185 + fi
186 +
187 + if use pax_kernel; then
188 + ewarn "Using PAX patches is not supported. You will be asked to"
189 + ewarn "use a standard kernel should you have issues. Should you"
190 + ewarn "need support with these patches, contact the PaX team."
191 + epatch "${FILESDIR}"/${PN}-346.16-pax-usercopy.patch
192 + epatch "${FILESDIR}"/${PN}-346.16-pax-constify.patch
193 + fi
194 +
195 + # Allow user patches so they can support RC kernels and whatever else
196 + epatch_user
197 +}
198 +
199 +src_compile() {
200 + # This is already the default on Linux, as there's no toplevel Makefile, but
201 + # on FreeBSD there's one and triggers the kernel module build, as we install
202 + # it by itself, pass this.
203 +
204 + cd "${NV_SRC}"
205 + if use kernel_FreeBSD; then
206 + MAKE="$(get_bmake)" CFLAGS="-Wno-sign-compare" emake CC="$(tc-getCC)" \
207 + LD="$(tc-getLD)" LDFLAGS="$(raw-ldflags)" || die
208 + elif use kernel_linux; then
209 + MAKEOPTS=-j1
210 + linux-mod_src_compile
211 + fi
212 +}
213 +
214 +# Install nvidia library:
215 +# the first parameter is the library to install
216 +# the second parameter is the provided soversion
217 +# the third parameter is the target directory if its not /usr/lib
218 +donvidia() {
219 + # Full path to library minus SOVER
220 + MY_LIB="$1"
221 +
222 + # SOVER to use
223 + MY_SOVER="$2"
224 +
225 + # Where to install
226 + MY_DEST="$3"
227 +
228 + if [[ -z "${MY_DEST}" ]]; then
229 + MY_DEST="/usr/$(get_libdir)"
230 + action="dolib.so"
231 + else
232 + exeinto ${MY_DEST}
233 + action="doexe"
234 + fi
235 +
236 + # Get just the library name
237 + libname=$(basename $1)
238 +
239 + # Install the library with the correct SOVER
240 + ${action} ${MY_LIB}.${MY_SOVER} || \
241 + die "failed to install ${libname}"
242 +
243 + # If SOVER wasn't 1, then we need to create a .1 symlink
244 + if [[ "${MY_SOVER}" != "1" ]]; then
245 + dosym ${libname}.${MY_SOVER} \
246 + ${MY_DEST}/${libname}.1 || \
247 + die "failed to create ${libname} symlink"
248 + fi
249 +
250 + # Always create the symlink from the raw lib to the .1
251 + dosym ${libname}.1 \
252 + ${MY_DEST}/${libname} || \
253 + die "failed to create ${libname} symlink"
254 +}
255 +
256 +src_install() {
257 + if use kernel_linux; then
258 + linux-mod_src_install
259 +
260 + # Add the aliases
261 + # This file is tweaked with the appropriate video group in
262 + # pkg_preinst, see bug #491414
263 + insinto /etc/modprobe.d
264 + newins "${FILESDIR}"/nvidia-169.07 nvidia.conf
265 + use uvm && doins "${FILESDIR}"/nvidia-uvm.conf
266 +
267 + # Ensures that our device nodes are created when not using X
268 + exeinto "$(get_udevdir)"
269 + newexe "${FILESDIR}"/nvidia-udev.sh-r1 nvidia-udev.sh
270 + udev_newrules "${FILESDIR}"/nvidia.udev-rule 99-nvidia.rules
271 + elif use kernel_FreeBSD; then
272 + if use x86-fbsd; then
273 + insinto /boot/modules
274 + doins "${S}/src/nvidia.kld"
275 + fi
276 +
277 + exeinto /boot/modules
278 + doexe "${S}/src/nvidia.ko"
279 + fi
280 +
281 + # NVIDIA kernel <-> userspace driver config lib
282 + donvidia ${NV_OBJ}/libnvidia-cfg.so ${NV_SOVER}
283 +
284 + # NVIDIA framebuffer capture library
285 + donvidia ${NV_OBJ}/libnvidia-fbc.so ${NV_SOVER}
286 +
287 + # NVIDIA video encode/decode <-> CUDA
288 + if use kernel_linux; then
289 + donvidia ${NV_OBJ}/libnvcuvid.so ${NV_SOVER}
290 + donvidia ${NV_OBJ}/libnvidia-encode.so ${NV_SOVER}
291 + fi
292 +
293 + if use X; then
294 + # Xorg DDX driver
295 + insinto /usr/$(get_libdir)/xorg/modules/drivers
296 + doins ${NV_X11}/nvidia_drv.so
297 +
298 + # Xorg GLX driver
299 + donvidia ${NV_X11}/libglx.so ${NV_SOVER} \
300 + /usr/$(get_libdir)/opengl/nvidia/extensions
301 +
302 + # Xorg nvidia.conf
303 + if has_version '>=x11-base/xorg-server-1.16'; then
304 + insinto /usr/share/X11/xorg.conf.d
305 + newins {,50-}nvidia-drm-outputclass.conf
306 + fi
307 + fi
308 +
309 + # OpenCL ICD for NVIDIA
310 + if use kernel_linux; then
311 + insinto /etc/OpenCL/vendors
312 + doins ${NV_OBJ}/nvidia.icd
313 + fi
314 +
315 + # Documentation
316 + dohtml ${NV_DOC}/html/*
317 + if use kernel_FreeBSD; then
318 + dodoc "${NV_DOC}/README"
319 + use X && doman "${NV_MAN}/nvidia-xconfig.1"
320 + use tools && doman "${NV_MAN}/nvidia-settings.1"
321 + else
322 + # Docs
323 + newdoc "${NV_DOC}/README.txt" README
324 + dodoc "${NV_DOC}/NVIDIA_Changelog"
325 + doman "${NV_MAN}/nvidia-smi.1.gz"
326 + use X && doman "${NV_MAN}/nvidia-xconfig.1.gz"
327 + use tools && doman "${NV_MAN}/nvidia-settings.1.gz"
328 + doman "${NV_MAN}/nvidia-cuda-mps-control.1.gz"
329 + fi
330 +
331 + # Helper Apps
332 + exeinto /opt/bin/
333 +
334 + if use X; then
335 + doexe ${NV_OBJ}/nvidia-xconfig
336 + fi
337 +
338 + if use kernel_linux ; then
339 + doexe ${NV_OBJ}/nvidia-cuda-mps-control
340 + doexe ${NV_OBJ}/nvidia-cuda-mps-server
341 + doexe ${NV_OBJ}/nvidia-debugdump
342 + doexe ${NV_OBJ}/nvidia-persistenced
343 + doexe ${NV_OBJ}/nvidia-smi
344 +
345 + # install nvidia-modprobe setuid and symlink in /usr/bin (bug #505092)
346 + doexe ${NV_OBJ}/nvidia-modprobe
347 + fowners root:video /opt/bin/nvidia-modprobe
348 + fperms 4710 /opt/bin/nvidia-modprobe
349 + dosym /{opt,usr}/bin/nvidia-modprobe
350 +
351 + doman nvidia-cuda-mps-control.1.gz
352 + doman nvidia-modprobe.1.gz
353 + doman nvidia-persistenced.1.gz
354 + newinitd "${FILESDIR}/nvidia-smi.init" nvidia-smi
355 + newconfd "${FILESDIR}/nvidia-persistenced.conf" nvidia-persistenced
356 + newinitd "${FILESDIR}/nvidia-persistenced.init" nvidia-persistenced
357 + fi
358 +
359 + if use tools; then
360 + doexe ${NV_OBJ}/nvidia-settings
361 + use gtk2 && donvidia libnvidia-gtk2.so ${PV}
362 + use gtk3 && donvidia libnvidia-gtk3.so ${PV}
363 + insinto /usr/share/nvidia/
364 + doins nvidia-application-profiles-${PV}-key-documentation
365 + insinto /etc/nvidia
366 + newins nvidia-application-profiles-${PV}-rc nvidia-application-profiles-rc
367 + fi
368 +
369 + dobin ${NV_OBJ}/nvidia-bug-report.sh
370 +
371 + # Desktop entries for nvidia-settings
372 + if use tools ; then
373 + # There is no icon in the FreeBSD tarball.
374 + use kernel_FreeBSD || newicon ${NV_OBJ}/nvidia-settings.png ${PN}-settings.png
375 + domenu "${FILESDIR}"/${PN}-settings.desktop
376 + exeinto /etc/X11/xinit/xinitrc.d
377 + doexe "${FILESDIR}"/95-nvidia-settings
378 + fi
379 +
380 + #doenvd "${FILESDIR}"/50nvidia-prelink-blacklist
381 +
382 + if has_multilib_profile && use multilib ; then
383 + local OABI=${ABI}
384 + for ABI in $(get_install_abis) ; do
385 + src_install-libs
386 + done
387 + ABI=${OABI}
388 + unset OABI
389 + else
390 + src_install-libs
391 + fi
392 +
393 + is_final_abi || die "failed to iterate through all ABIs"
394 +
395 + readme.gentoo_create_doc
396 +}
397 +
398 +src_install-libs() {
399 + local inslibdir=$(get_libdir)
400 + local GL_ROOT="/usr/$(get_libdir)/opengl/nvidia/lib"
401 + local CL_ROOT="/usr/$(get_libdir)/OpenCL/vendors/nvidia"
402 + local libdir=${NV_OBJ}
403 +
404 + if use kernel_linux && has_multilib_profile && \
405 + [[ ${ABI} == "x86" ]] ; then
406 + libdir=${NV_OBJ}/32
407 + fi
408 +
409 + if use X; then
410 + # The GLX libraries
411 + donvidia ${libdir}/libEGL.so ${NV_SOVER} ${GL_ROOT}
412 + donvidia ${libdir}/libGL.so ${NV_SOVER} ${GL_ROOT}
413 + donvidia ${libdir}/libGLESv1_CM.so ${NV_SOVER} ${GL_ROOT}
414 + donvidia ${libdir}/libnvidia-eglcore.so ${NV_SOVER}
415 + donvidia ${libdir}/libnvidia-glcore.so ${NV_SOVER}
416 + donvidia ${libdir}/libnvidia-glsi.so ${NV_SOVER}
417 + donvidia ${libdir}/libnvidia-ifr.so ${NV_SOVER}
418 + if use kernel_FreeBSD; then
419 + donvidia ${libdir}/libnvidia-tls.so ${NV_SOVER}
420 + else
421 + donvidia ${libdir}/tls/libnvidia-tls.so ${NV_SOVER}
422 + fi
423 +
424 + # VDPAU
425 + donvidia ${libdir}/libvdpau_nvidia.so ${NV_SOVER}
426 +
427 + # GLES v2 libraries
428 + insinto ${GL_ROOT}
429 + doexe ${libdir}/libGLESv2.so.${PV}
430 + dosym libGLESv2.so.${PV} ${GL_ROOT}/libGLESv2.so.2
431 + dosym libGLESv2.so.2 ${GL_ROOT}/libGLESv2.so
432 + fi
433 +
434 + # NVIDIA monitoring library
435 + if use kernel_linux ; then
436 + donvidia ${libdir}/libnvidia-ml.so ${NV_SOVER}
437 + fi
438 +
439 + # CUDA & OpenCL
440 + if use kernel_linux; then
441 + donvidia ${libdir}/libcuda.so ${NV_SOVER}
442 + donvidia ${libdir}/libnvidia-compiler.so ${NV_SOVER}
443 + donvidia ${libdir}/libOpenCL.so 1.0.0 ${CL_ROOT}
444 + donvidia ${libdir}/libnvidia-opencl.so ${NV_SOVER}
445 + fi
446 +}
447 +
448 +pkg_preinst() {
449 + if use kernel_linux; then
450 + linux-mod_pkg_preinst
451 +
452 + local videogroup="$(egetent group video | cut -d ':' -f 3)"
453 + if [ -z "${videogroup}" ]; then
454 + eerror "Failed to determine the video group gid"
455 + die "Failed to determine the video group gid"
456 + else
457 + sed -i \
458 + -e "s:PACKAGE:${PF}:g" \
459 + -e "s:VIDEOGID:${videogroup}:" \
460 + "${D}"/etc/modprobe.d/nvidia.conf || die
461 + fi
462 + fi
463 +
464 + # Clean the dynamic libGL stuff's home to ensure
465 + # we dont have stale libs floating around
466 + if [ -d "${ROOT}"/usr/lib/opengl/nvidia ] ; then
467 + rm -rf "${ROOT}"/usr/lib/opengl/nvidia/*
468 + fi
469 + # Make sure we nuke the old nvidia-glx's env.d file
470 + if [ -e "${ROOT}"/etc/env.d/09nvidia ] ; then
471 + rm -f "${ROOT}"/etc/env.d/09nvidia
472 + fi
473 +}
474 +
475 +pkg_postinst() {
476 + use kernel_linux && linux-mod_pkg_postinst
477 +
478 + # Switch to the nvidia implementation
479 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old nvidia
480 + "${ROOT}"/usr/bin/eselect opencl set --use-old nvidia
481 +
482 + readme.gentoo_print_elog
483 +
484 + if ! use X; then
485 + elog "You have elected to not install the X.org driver. Along with"
486 + elog "this the OpenGL libraries and VDPAU libraries were not"
487 + elog "installed. Additionally, once the driver is loaded your card"
488 + elog "and fan will run at max speed which may not be desirable."
489 + elog "Use the 'nvidia-smi' init script to have your card and fan"
490 + elog "speed scale appropriately."
491 + elog
492 + fi
493 + if ! use tools; then
494 + elog "USE=tools controls whether the nvidia-settings application"
495 + elog "is installed. If you would like to use it, enable that"
496 + elog "flag and re-emerge this ebuild. Optionally you can install"
497 + elog "media-video/nvidia-settings"
498 + elog
499 + fi
500 +}
501 +
502 +pkg_prerm() {
503 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
504 +}
505 +
506 +pkg_postrm() {
507 + use kernel_linux && linux-mod_pkg_postrm
508 + use X && "${ROOT}"/usr/bin/eselect opengl set --use-old xorg-x11
509 +}