From 7bc9c63c9da678a7e6fceb095d56c634afd22c56 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Sun, 15 Dec 2019 18:09:03 +0000 Subject: gentoo resync : 15.12.2019 --- eclass/nvidia-driver.eclass | 93 ++++++++++++++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 30 deletions(-) (limited to 'eclass/nvidia-driver.eclass') diff --git a/eclass/nvidia-driver.eclass b/eclass/nvidia-driver.eclass index a8631947748a..8c108a9c338e 100644 --- a/eclass/nvidia-driver.eclass +++ b/eclass/nvidia-driver.eclass @@ -6,12 +6,12 @@ # Jeroen Roovers # @AUTHOR: # Original author: Doug Goldstein -# @BLURB: Provide useful messages for nvidia-drivers based on currently installed Nvidia card +# @BLURB: Provide useful messages for nvidia-drivers # @DESCRIPTION: -# Provide useful messages for nvidia-drivers based on currently installed Nvidia -# card. It inherits versionator. +# Provide useful messages for nvidia-drivers based on currently installed +# Nvidia GPU and Linux kernel. -inherit readme.gentoo-r1 versionator +inherit readme.gentoo-r1 DEPEND="sys-apps/pciutils" RESTRICT="bindist mirror test" @@ -105,10 +105,10 @@ mask_304x=">=x11-drivers/nvidia-drivers-305.0.0" mask_340x=">=x11-drivers/nvidia-drivers-341.0.0" mask_390x=">=x11-drivers/nvidia-drivers-391.0.0" -# @FUNCTION: nvidia-driver-get-card +# @FUNCTION: nvidia-driver_get_gpu # @DESCRIPTION: -# Retrieve the PCI device ID for each Nvidia video card you have -nvidia-driver-get-card() { +# Retrieve the PCI device ID for each Nvidia GPU you have +nvidia-driver_get_gpu() { local NVIDIA_CARD=$( [ -x /usr/sbin/lspci ] && /usr/sbin/lspci -d 10de: -n \ | awk -F'[: ]' '/ 03[0-9][0-9]: /{print $6}' @@ -121,48 +121,48 @@ nvidia-driver-get-card() { fi } -nvidia-driver-get-mask() { - local NVIDIA_CARDS="$(nvidia-driver-get-card)" - local card drv +nvidia-driver_get_mask() { + local nvidia_gpus="$(nvidia-driver_get_gpu)" + local nvidia_gpu drv - for card in ${NVIDIA_CARDS}; do + for nvidia_gpu in ${nvidia_gpus}; do for drv in ${drv_71xx}; do - if [ "x${card}" = "x${drv}" ]; then + if [ "x${nvidia_gpu}" = "x${drv}" ]; then echo "${mask_71xx}" return 0 fi done for drv in ${drv_96xx}; do - if [ "x${card}" = "x${drv}" ]; then + if [ "x${nvidia_gpu}" = "x${drv}" ]; then echo "${mask_96xx}" return 0 fi done for drv in ${drv_173x}; do - if [ "x${card}" = "x${drv}" ]; then + if [ "x${nvidia_gpu}" = "x${drv}" ]; then echo "${mask_173x}" return 0 fi done for drv in ${drv_304x}; do - if [ "x${card}" = "x${drv}" ]; then + if [ "x${nvidia_gpu}" = "x${drv}" ]; then echo "${mask_304x}" return 0 fi done for drv in ${drv_340x}; do - if [ "x${card}" = "x${drv}" ]; then + if [ "x${nvidia_gpu}" = "x${drv}" ]; then echo "${mask_340x}" return 0 fi done for drv in ${drv_390x}; do - if [ "x${card}" = "x${drv}" ]; then + if [ "x${nvidia_gpu}" = "x${drv}" ]; then echo "${mask_390x}" return 0 fi @@ -173,27 +173,26 @@ nvidia-driver-get-mask() { return 1 } -# @FUNCTION: nvidia-driver-check-warning +# @FUNCTION: nvidia-driver_check_gpu # @DESCRIPTION: -# Prints out a warning if the driver does not work w/ the installed video card -nvidia-driver-check-warning() { - local NVIDIA_MASK="$(nvidia-driver-get-mask)" +# Prints out a warning if the driver does not work with the installed GPU +nvidia-driver_check_gpu() { + local nvidia_mask="$(nvidia-driver_get_mask)" - if [ -n "${NVIDIA_MASK}" ]; then - version_compare "${NVIDIA_MASK##*-}" "${PV}" - if [ x"${?}" = x1 ]; then + if [ -n "${nvidia_mask}" ]; then + if ver_test "${nvidia_mask##*-}" -lt "${PV}" ; then ewarn "***** WARNING *****" ewarn ewarn "You are currently installing a version of nvidia-drivers that is" - ewarn "known not to work with a video card you have installed on your" - ewarn "system. If this is intentional, please ignore this. If it is not" - ewarn "please perform the following steps:" + ewarn "known not to work with a GPU you have installed on your system." + ewarn "If this is intentional, please ignore this. If it is not please" + ewarn "perform the following steps:" ewarn - ewarn "Add the following mask entry to /etc/portage/package.mask by" + ewarn "Add the following mask entry to the local package.mask file:" if [ -d "${ROOT}/etc/portage/package.mask" ]; then - ewarn "echo \"${NVIDIA_MASK}\" > /etc/portage/package.mask/nvidia-drivers" + ewarn "echo \"${nvidia_mask}\" > /etc/portage/package.mask/nvidia-drivers" else - ewarn "echo \"${NVIDIA_MASK}\" >> /etc/portage/package.mask" + ewarn "echo \"${nvidia_mask}\" >> /etc/portage/package.mask" fi ewarn ewarn "Failure to perform the steps above could result in a non-working" @@ -204,3 +203,37 @@ nvidia-driver-check-warning() { fi fi } + +nvidia-driver_check_kernel() { + if kernel_is ge $(ver_cut 1 ${NV_KV_MAX_PLUS}) $(ver_cut 2 ${NV_KV_MAX_PLUS}); then + ewarn "Gentoo supports kernels which are supported by NVIDIA" + ewarn "which are limited to the following kernels:" + ewarn "