summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen Roovers <jer@gentoo.org>2019-11-27 15:37:21 +0100
committerJeroen Roovers <jer@gentoo.org>2019-11-27 16:07:00 +0100
commit245f417b539760ccf4939630f2c6b826ce34a556 (patch)
treeab7efdc8d1c3f3be26b10833bc8e050f3c6d90bb /eclass/nvidia-driver.eclass
parentapp-arch/ncompress: drop old EAPI (diff)
downloadgentoo-245f417b539760ccf4939630f2c6b826ce34a556.tar.gz
gentoo-245f417b539760ccf4939630f2c6b826ce34a556.tar.bz2
gentoo-245f417b539760ccf4939630f2c6b826ce34a556.zip
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 <jer@gentoo.org>
Diffstat (limited to 'eclass/nvidia-driver.eclass')
-rw-r--r--eclass/nvidia-driver.eclass87
1 files changed, 60 insertions, 27 deletions
diff --git a/eclass/nvidia-driver.eclass b/eclass/nvidia-driver.eclass
index a8631947748..b71b7a769ae 100644
--- a/eclass/nvidia-driver.eclass
+++ b/eclass/nvidia-driver.eclass
@@ -6,12 +6,12 @@
# Jeroen Roovers <jer@gentoo.org>
# @AUTHOR:
# Original author: Doug Goldstein <cardoe@gentoo.org>
-# @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 "<sys-kernel/gentoo-sources-${NV_KV_MAX_PLUS}"
+ ewarn "<sys-kernel/vanilla-sources-${NV_KV_MAX_PLUS}"
+ ewarn ""
+ ewarn "You are free to utilize eapply_user to provide whatever"
+ ewarn "support you feel is appropriate, but will not receive"
+ ewarn "support as a result of those changes."
+ ewarn ""
+ ewarn "Do not file a bug report about this."
+ ewarn ""
+ fi
+
+ check_extra_config
+}
+
+nvidia-driver_check() {
+ if use amd64 && has_multilib_profile && \
+ [ "${DEFAULT_ABI}" != "amd64" ]; then
+ eerror "This ebuild doesn't currently support changing your default ABI"
+ die "Unexpected \${DEFAULT_ABI} = ${DEFAULT_ABI}"
+ fi
+
+ # Since Nvidia ships many different series of drivers, we need to give the user
+ # some kind of guidance as to what version they should install. This tries
+ # to point the user in the right direction but can't be perfect. check
+ # nvidia-driver.eclass
+ nvidia-driver_check_gpu
+
+ use kernel_linux && nvidia-driver_check_kernel
+}