nvidia-driver.eclass: Fix GPU vs version compatibility check
authorJeroen Roovers <jer@gentoo.org>
Mon, 2 Dec 2019 10:08:30 +0000 (11:08 +0100)
committerJeroen Roovers <jer@gentoo.org>
Mon, 2 Dec 2019 10:14:32 +0000 (11:14 +0100)
- In commit 245f417b539760ccf4939630f2c6b826ce34a556 I replaced
version_compare() with ver_test but failed to properly adjust the check
from the "is at least" return value to its ver_test equivalent. Invert
the test return value for clarity and check for a version mask less than
PV.
- Use lower case for local variable name.
- Fix a comment while there.

Fixes: https://bugs.gentoo.org/701734
Signed-off-by: Jeroen Roovers <jer@gentoo.org>
Tested-by: Kobboi
Signed-off-by: Jeroen Roovers <jer@gentoo.org>
eclass/nvidia-driver.eclass

index b71b7a769aeb27a3ac8ab7bfb400dc32ed7f9065..8c108a9c338e845d867fcbb826492b08d6d76814 100644 (file)
@@ -175,12 +175,12 @@ nvidia-driver_get_mask() {
 
 # @FUNCTION: nvidia-driver_check_gpu
 # @DESCRIPTION:
-# Prints out a warning if the driver does not work w/ the installed video nvidia_gpu
+# 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)"
+       local nvidia_mask="$(nvidia-driver_get_mask)"
 
-       if [ -n "${NVIDIA_MASK}" ]; then
-               if ! ver_test "${NVIDIA_MASK##*-}" -eq "${PV}" ; 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"
@@ -190,9 +190,9 @@ nvidia-driver_check_gpu() {
                        ewarn
                        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"