Do not suggest to install a proprietary driver if there is another GPU supported only by Nouveau (e.g. an old one)

This commit is contained in:
Mikhail Novosyolov 2022-07-01 12:38:28 +03:00
parent 8758add5fc
commit 26d46613ec

View file

@ -8,6 +8,7 @@ set -o pipefail
# 01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GF108 [GeForce GT 440] [10de:0de0] (rev a1) # 01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GF108 [GeForce GT 440] [10de:0de0] (rev a1)
# constants # constants
readonly EXIT_GENERICERROR=1
readonly EXIT_ENODRIVER=10 readonly EXIT_ENODRIVER=10
readonly EXIT_ENOGPU=20 readonly EXIT_ENOGPU=20
readonly EXIT_ENOCOMMONDRIVER=30 readonly EXIT_ENOCOMMONDRIVER=30
@ -218,7 +219,7 @@ _cli_get_gpus(){
arch="$(rpm -E "%_arch")" arch="$(rpm -E "%_arch")"
if [ -z "$arch" ]; then if [ -z "$arch" ]; then
_echo_err "Error getting architecture of the host machine" _echo_err "Error getting architecture of the host machine"
return 1 return $EXIT_GENERICERROR
fi fi
local big_file local big_file
big_file="$(_mktemp)" big_file="$(_mktemp)"
@ -230,7 +231,6 @@ _cli_get_gpus(){
_echo_err "No NVIDIA GPUs found" _echo_err "No NVIDIA GPUs found"
return $EXIT_ENOGPU return $EXIT_ENOGPU
fi fi
local r=""
while read -r line while read -r line
do do
local device_id local device_id
@ -243,35 +243,22 @@ _cli_get_gpus(){
human_name="$(_line2name "$line")" human_name="$(_line2name "$line")"
if [ -z "$human_name" ]; then if [ -z "$human_name" ]; then
_echo_err "Error converting to human readable name" _echo_err "Error converting to human readable name"
return 1 return $EXIT_GENERICERROR
fi fi
local available_drivers local available_drivers
available_drivers="$(_get_available_drivers "$device_id" "$KROKO_TMPDIR")" available_drivers="$(_get_available_drivers "$device_id" "$KROKO_TMPDIR")"
if [ -z "$available_drivers" ]; then if [ -z "$available_drivers" ]; then
_echo_err "No drivers found for device $device_id" _echo_err "No drivers found for device $device_id"
continue return $EXIT_ENODRIVER
fi fi
local best_driver local best_driver
best_driver="$(_get_best_driver "$device_id" "$KROKO_TMPDIR")" best_driver="$(_get_best_driver "$device_id" "$KROKO_TMPDIR")"
if [ -z "$best_driver" ]; then if [ -z "$best_driver" ]; then
_echo_err "Error getting the best driver" _echo_err "Error getting the best driver"
continue return $EXIT_GENERICERROR
fi
local e
e="${line};${device_id};${human_name};${available_drivers};${best_driver}"
if [ -z "$r" ]
then
r="$e"
else
# https://stackoverflow.com/a/9139891
r="$r"$'\n'"$e"
fi fi
echo "${line};${device_id};${human_name};${available_drivers};${best_driver}"
done <<< "$o" done <<< "$o"
# if nothing found for any of the GPUs
if [ -z "$r" ]; then
return $EXIT_ENODRIVER
fi
echo "$r"
} }
# If there are multiple GPUs, select a driver which will fit all of them # If there are multiple GPUs, select a driver which will fit all of them