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