From 245f417b539760ccf4939630f2c6b826ce34a556 Mon Sep 17 00:00:00 2001 From: Jeroen Roovers Date: Wed, 27 Nov 2019 15:37:21 +0100 Subject: eclass/nvidia-driver.eclass: Add nvidia-driver_check(), various tweaks - Add nvidia-driver_check() to replace nvidia_drivers_versions_check() duplication in every ebuild - Use EAPI=7 ver_test() instead of versionator.eclass's version_compare() - Replace "video card" with "GPU" in various places. - epatch_user() => eapply_user() - Whitespace and formatting - Use nvidia-driver_* format for eclass functions Signed-off-by: Jeroen Roovers --- eclass/nvidia-driver.eclass | 87 +++++++++++++++++++++++++++++++-------------- 1 file changed, 60 insertions(+), 27 deletions(-) (limited to 'eclass') diff --git a/eclass/nvidia-driver.eclass b/eclass/nvidia-driver.eclass index a8631947748a..b71b7a769aeb 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,23 +173,22 @@ 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 w/ the installed video nvidia_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 ! ver_test "${NVIDIA_MASK##*-}" -eq "${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" else @@ -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 "