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)
# constants
readonly EXIT_GENERICERROR=1
readonly EXIT_ENODRIVER=10
readonly EXIT_ENOGPU=20
readonly EXIT_ENOCOMMONDRIVER=30
@ -218,7 +219,7 @@ _cli_get_gpus(){
arch="$(rpm -E "%_arch")"
if [ -z "$arch" ]; then
_echo_err "Error getting architecture of the host machine"
return 1
return $EXIT_GENERICERROR
fi
local big_file
big_file="$(_mktemp)"
@ -230,7 +231,6 @@ _cli_get_gpus(){
_echo_err "No NVIDIA GPUs found"
return $EXIT_ENOGPU
fi
local r=""
while read -r line
do
local device_id
@ -243,35 +243,22 @@ _cli_get_gpus(){
human_name="$(_line2name "$line")"
if [ -z "$human_name" ]; then
_echo_err "Error converting to human readable name"
return 1
return $EXIT_GENERICERROR
fi
local available_drivers
available_drivers="$(_get_available_drivers "$device_id" "$KROKO_TMPDIR")"
if [ -z "$available_drivers" ]; then
_echo_err "No drivers found for device $device_id"
continue
return $EXIT_ENODRIVER
fi
local best_driver
best_driver="$(_get_best_driver "$device_id" "$KROKO_TMPDIR")"
if [ -z "$best_driver" ]; then
_echo_err "Error getting the best driver"
continue
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"
return $EXIT_GENERICERROR
fi
echo "${line};${device_id};${human_name};${available_drivers};${best_driver}"
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