mirror of
https://github.com/keylase/nvidia-patch.git
synced 2024-11-13 21:28:21 +00:00
linux: patch.sh: new opmode - list supported versions
This commit is contained in:
parent
1029bfb2a1
commit
a82e6112c9
29
patch.sh
29
patch.sh
@ -9,7 +9,7 @@ silent_flag=''
|
|||||||
|
|
||||||
print_usage() { printf '
|
print_usage() { printf '
|
||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
patch.sh [-s] [-r|-h|-c VERSION]
|
patch.sh [-s] [-r|-h|-c VERSION|-l]
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
The patch for Nvidia drivers to remove NVENC session limit
|
The patch for Nvidia drivers to remove NVENC session limit
|
||||||
@ -19,6 +19,7 @@ DESCRIPTION
|
|||||||
-h Print this help message
|
-h Print this help message
|
||||||
-c VERSION Check if version VERSION supported by this patch.
|
-c VERSION Check if version VERSION supported by this patch.
|
||||||
Returns true exit code (0) if version is supported.
|
Returns true exit code (0) if version is supported.
|
||||||
|
-l List supported driver versions
|
||||||
|
|
||||||
'
|
'
|
||||||
}
|
}
|
||||||
@ -26,12 +27,13 @@ DESCRIPTION
|
|||||||
# shellcheck disable=SC2209
|
# shellcheck disable=SC2209
|
||||||
opmode="patch"
|
opmode="patch"
|
||||||
|
|
||||||
while getopts 'rshc:' flag; do
|
while getopts 'rshc:l' flag; do
|
||||||
case "${flag}" in
|
case "${flag}" in
|
||||||
r) opmode="${opmode}rollback" ;;
|
r) opmode="${opmode}rollback" ;;
|
||||||
s) silent_flag='true' ;;
|
s) silent_flag='true' ;;
|
||||||
h) opmode="${opmode}help" ;;
|
h) opmode="${opmode}help" ;;
|
||||||
c) opmode="${opmode}checkversion" ; checked_version="$OPTARG" ;;
|
c) opmode="${opmode}checkversion" ; checked_version="$OPTARG" ;;
|
||||||
|
l) opmode="${opmode}listversions" ;;
|
||||||
*) echo "Incorrect option specified in command line" ; exit 2 ;;
|
*) echo "Incorrect option specified in command line" ; exit 2 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@ -115,6 +117,13 @@ check_version_supported () {
|
|||||||
[[ "${patch_list[$ver]+isset}" && "${object_list[$ver]+isset}" ]]
|
[[ "${patch_list[$ver]+isset}" && "${object_list[$ver]+isset}" ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_supported_versions () {
|
||||||
|
for drv in "${!patch_list[@]}"; do
|
||||||
|
[[ "${object_list[$drv]+isset}" ]] && echo "$drv"
|
||||||
|
done | sort -t. -n
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
patch_common () {
|
patch_common () {
|
||||||
NVIDIA_SMI="$(command -v nvidia-smi || true)"
|
NVIDIA_SMI="$(command -v nvidia-smi || true)"
|
||||||
if [[ ! "$NVIDIA_SMI" ]] ; then
|
if [[ ! "$NVIDIA_SMI" ]] ; then
|
||||||
@ -130,11 +139,9 @@ patch_common () {
|
|||||||
echo "Detected nvidia driver version: $driver_version"
|
echo "Detected nvidia driver version: $driver_version"
|
||||||
|
|
||||||
if ! check_version_supported "$driver_version" ; then
|
if ! check_version_supported "$driver_version" ; then
|
||||||
echo "Patch for this ($driver_version) nvidia driver not found." 1>&2
|
echo "Patch for this ($driver_version) nvidia driver not found."
|
||||||
echo "Available patches for: " 1>&2
|
echo "Patch is available for versions: "
|
||||||
for drv in "${!patch_list[@]}"; do
|
get_supported_versions
|
||||||
echo "$drv" 1>&2
|
|
||||||
done
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -198,10 +205,16 @@ query_version_support () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list_supported_versions () {
|
||||||
|
get_supported_versions
|
||||||
|
}
|
||||||
|
|
||||||
case "${opmode}" in
|
case "${opmode}" in
|
||||||
patch) patch ;;
|
patch) patch ;;
|
||||||
patchrollback) rollback ;;
|
patchrollback) rollback ;;
|
||||||
patchhelp) print_usage ; exit 2 ;;
|
patchhelp) print_usage ; exit 2 ;;
|
||||||
patchcheckversion) query_version_support ;;
|
patchcheckversion) query_version_support ;;
|
||||||
*) echo "Incorrect combination of flags"; exit 2 ;;
|
patchlistversions) list_supported_versions ;;
|
||||||
|
*) echo "Incorrect combination of flags. Use option -h to get help."
|
||||||
|
exit 2 ;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
Reference in New Issue
Block a user