Suggested solution for #30, only update if newer driver (#31)

* Suggested solution for #30, only update if newer driver

* Removed dependency on nvidia-smi, now uses pacman and 'nvidia-utils' as search string
pull/33/head
flindeberg 3 years ago committed by GitHub
parent de1cbc5f4b
commit 5ccee5d449
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -28,7 +28,7 @@ source "$where"/customization.cfg
# Load external configuration file if present. Available variable values will overwrite customization.cfg ones.
if [ -e "$_EXT_CONFIG_PATH" ]; then
source "$_EXT_CONFIG_PATH" && msg2 "External configuration file $_EXT_CONFIG_PATH will be used to override customization.cfg values." && msg2 ""
source "$_EXT_CONFIG_PATH" && msg2 "External configuration file '$_EXT_CONFIG_PATH' will be used to override customization.cfg values." && plain ""
fi
# Auto-add kernel userpatches to source
@ -126,6 +126,42 @@ if [ -e options ]; then
source options
fi
# Check if the version we are going for is newer or not if enabled
if [[ "$_only_update_if_newer" == "true" ]]; then
# Check current version, if possible
if pacman -Qs "nvidia-utils" >/dev/null; then
# We have enough packages installed to get the version
# returns a string, like "460.39" or "455.45.01"
# HACK Checks the first nvidia-utils match, does not catch potential missmatches and other stuff
_current_version=$(pacman -Q "nvidia-utils" | grep -oP '\d+(\.\d+)+' | head -n 1)
_current_package_example=$(pacman -Q "nvidia-utils" | grep -oP '[a-z]+(\-[a-z]+)+' | head -n 1)
msg2 "Found version $_current_version installed (from package '$_current_package_example')"
## HACK Stupid string compare
## TODO Ensure that nvidia versions do not differ from this format
if [[ $_driver_version > $_current_version ]]; then
# We have a newer version to install, do nothing
msg2 "Selected version ($_driver_version, $_driver_branch) is newer than installed version, continuing."
else
# Older version, or at least not newer version
msg2 "Selected version ($_driver_version, $_driver_branch) is not newer than installed version, exiting."
plain ""
if [ -e "$_EXT_CONFIG_PATH" ]; then
plain "If this is not intended, have a look at '$_EXT_CONFIG_PATH'"
else
plain "If this is not intended, have a look at '"$where"/customization.cfg'"
fi
# We shouldn't have done anything yet, so no cleanup needed?
exit 0
fi
else
warning "'\$_only_update_if_newer' is enabled, but no installed driver found."
warning "Continuing on as if '\$_only_update_if_newer' was not enabled."
plain ""
fi
fi
msg2 "Building driver version $_driver_version on branch $_driver_branch."
# Skip header check for dkms-only builds with explicit target kernel version

@ -31,6 +31,11 @@ _driver_branch=""
# Set to "latest" to use the latest driver on the selected branch.
_driver_version=""
# Only updates if there is a newer version available
# Semi-hack, compares version-strings as strings, i.e. if "460.39" > "455.45.01" update etc
# Set to "true" to enable
_only_update_if_newer=""
# Set to "true" to use DKMS or "false" to use regular modules. You can also use "full" to build both dkms and regular packages (don't use it if you don't know you need it!).
_dkms=""

Loading…
Cancel
Save