Change: 'Graphics Setup' stage > 'vga_conf' function: Major code re-write for simplification and efficiency

Remove: Parts of code throughout the script have been removed as a consequence of the above action
Change: Code indentation/Minor prompts editing for aesthetic purposes
This commit is contained in:
Jane Doe
2025-03-01 11:42:11 +00:00
parent 510a06f745
commit 106c69f642
+161 -179
View File
@@ -2,7 +2,7 @@
# Amelia Installer
# Source: https://gitlab.com/prism7/archery
# Version: 8.8.1
# Version: 8.8.2
set -euo pipefail
###################################################################################################
@@ -445,10 +445,6 @@ ${magenta}###${nc}-----------------------------------${magenta}[ ${bwhite}System
dtct_hyper() {
hypervisor="$(systemd-detect-virt)"
if [[ "${hypervisor}" != "none" ]]; then
vendor="Virtual Machine"
vgaconf="n"
fi
case "${hypervisor}" in
kvm)
vmpkgs="spice spice-vdagent spice-protocol spice-gtk qemu-guest-agent swtpm" ;;
@@ -481,6 +477,8 @@ ${magenta}###${nc}------------------------------------${magenta}[ ${bwhite}Machi
if [[ "${hypervisor}" != "none" ]]; then
vm
vendor="Virtual Machine"
vgaconf="n"
fi
if [[ "${CPU}" == *"GenuineIntel"* ]]; then
@@ -1024,16 +1022,10 @@ Enter a number: "
### The ${kernelname} kernel has been selected
"
ok
if [[ "${vga_slct}" == "yes" ]]; then
local stage_prompt="Graphics Setup"
completion_err
until dtct_vga; do : ; done
fi
}
###################################################################################################
ask_bootldr() {
local prompt="Bootloader Selection"
sleep 0.2
NC "
@@ -1084,6 +1076,7 @@ Enter a number: "
invalid
return 1 ;;
esac
local prompt="Bootloader Selection"
ok
}
###################################################################################################
@@ -1381,7 +1374,7 @@ Enter a number: "
YELLOW "
> Enable ${nc}systemd-oomd ${yellow}for enhanced 'OOM' management efficiency? [Y/n]"
> Enable ${nc}systemd-oomd ${yellow}for enhanced 'OOM' management ? [Y/n]"
BLUE "
@@ -1407,11 +1400,6 @@ Enter [Y/n]: "
fi
ok
if [[ "${vga_slct}" == "yes" ]]; then
local stage_prompt="Graphics Setup"
completion_err
until dtct_vga; do : ; done
fi
}
###################################################################################################
set_swapsize() {
@@ -1457,22 +1445,6 @@ dtct_vga() {
--> Graphics Setup skipped
"
return 0
fi
if [[ -z "${kernelnmbr}" ]]; then
local stage_prompt="Kernel, Bootloader, ESP Mountpoint & Secure Signing"
completion_err
until slct_krnl; do : ; done
until ask_bootldr; do : ; done
until slct_espmnt; do : ; done
until ask_sign; do : ; done
return 1
fi
if [[ -z "${fs}" ]]; then
local stage_prompt="Filesystem & Swap Setup"
completion_err
until ask_fs; do : ; done
until ask_swap; do : ; done
return 1
fi
sleep 0.2
NC "
@@ -1488,6 +1460,7 @@ ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Grap
amdcards="$(lspci | grep -E 'VGA|Display|3D' | grep -E 'Advanced Micro Devices' | sed 's/.*\[AMD\/ATI\] //g' | cat --number | sed 's/.[0-9]//')"
nvidiacount="$(lspci | grep -E 'VGA|Display|3D' | grep -E -c 'NVIDIA Corporation')"
nvidiacards="$(lspci | grep -E 'VGA|Display|3D' | grep -E 'NVIDIA Corporation'| sed 's/.*Corporation //g' | cat --number | sed 's/.[0-9]//')"
vga_slct="yes"
if [[ "${vgacount}" == "1" ]]; then
dtct_single_vga
@@ -1514,8 +1487,6 @@ dtct_single_vga() {
nvidia
fi
YELLOW "
### ${sourcetype} drivers will be used "
if [[ "${vendor}" == "Nvidia" ]]; then
sleep 0.2
RED "
@@ -1525,7 +1496,6 @@ dtct_single_vga() {
fi
YELLOW "
> Configure the Graphics subsystem and enable HW acceleration ? [Y/n]
"
if [[ "${vendor}" == "Nvidia" ]]; then
@@ -1543,8 +1513,12 @@ Enter [Y/n]: "
vgaconf="${vgaconf:-y}"
vgaconf="${vgaconf,,}"
if [[ "${vgaconf}" == "y" || "${vgaconf}" == "n" ]]; then
if [[ "${vgaconf}" == "y" ]]; then
vga_conf
elif [[ "${vgaconf}" == "n" ]]; then
local prompt="Graphics Setup"
skip
ok
else
invalid
return 1
@@ -1602,7 +1576,6 @@ ${nvidiacards}
YELLOW "
> Configure the Graphics subsystem and enable HW acceleration for : "
if [[ -n "${vendor1}" && -n "${vendor2}" ]]; then
@@ -1698,9 +1671,11 @@ Enter a number: "
if [[ "${vendor}" == "Intel" || "${vendor}" == "AMD" ]]; then
sourcetype="Open-source"
vgaconf="y"
vga_conf
elif [[ "${vendor}" == "Nvidia" ]]; then
sourcetype="Proprietary"
vgaconf="y"
vga_conf
elif [[ "${vendor}" == "none" ]]; then
local prompt="Graphics Setup"
vgaconf="n"
@@ -1708,6 +1683,10 @@ Enter a number: "
ok
return 0
fi
}
###################################################################################################
vga_conf() {
if [[ "${vendor}" != "none" ]]; then
sleep 0.2
YELLOW "
@@ -1716,10 +1695,115 @@ Enter a number: "
### ${sourcetype} drivers will be used
"
fi
vga_conf
if [[ "${vendor}" == "AMD" ]]; then
sleep 0.2
YELLOW "
> Enable 'amdgpu' driver support for: "
NC "
[1] 'Southern Islands' Graphics
[2] 'Sea Islands' Graphics "
BLUE "
Enter a number ${bwhite}(empty to skip)${blue}: "
read -r -p "
==> " islands
case "${islands}" in
1)
sleep 0.2
NC "
==> [${green}Southern Islands OK${nc}]
" ;;
2)
sleep 0.2
NC "
==> [${green}Sea Islands OK${nc}]
" ;;
"")
skip
echo ;;
*)
invalid
return 1 ;;
esac
elif [[ "${vendor}" == "Nvidia" ]]; then
sleep 0.2
YELLOW "
> Select Nvidia architecture: "
NC "
[1] Turing (NV160) Graphics or newer [Nvidia Open]
[2] Maxwell (NV110) Graphics or newer [Nvidia Proprietary / Disabling GSP Firmware available] "
BLUE "
Enter a number: "
read -r -p "
==> " family
case "${family}" in
1) # Turing+ Family
sleep 0.2
NC "
==> [${green}Turing+ OK${nc}]
" ;;
2) # Maxwell+ Family
sleep 0.2
NC "
==> [${green}Maxwell+ OK${nc}]
"
local prompt="GSP Firmware Disabled"
sleep 0.2
YELLOW "
> Disable 'GSP' firmware (for troubleshooting) ? [y/n] "
BLUE "
Enter [y/n]: "
read -r -p "
==> " nogsp
if [[ "${nogsp}" == "n" ]]; then
skip
echo
elif [[ "${nogsp}" == "y" ]]; then
ok
echo
else
y_n
return 1
fi ;;
"")
choice
return 1 ;;
*)
invalid
return 1 ;;
esac
fi
sleep 0.2
YELLOW "
### ${vendor} Graphics will be automatically configured
"
local prompt="Graphics Setup"
ok
}
###################################################################################################
vga_conf() {
vgapkgs_set() {
if [[ "${vgaconf}" == "y" ]]; then
if [[ "${vendor}" == "Intel" ]]; then
@@ -1727,45 +1811,6 @@ vga_conf() {
vgapkgs="intel-compute-runtime intel-media-driver intel-media-sdk libva-intel-driver opencl-headers vpl-gpu-rt vkd3d vulkan-intel vulkan-mesa-layers"
elif [[ "${vendor}" == "AMD" ]]; then
vgapkgs="libva-mesa-driver mesa-utils mesa-vdpau opencl-headers rocm-opencl-runtime vkd3d vulkan-mesa-layers vulkan-radeon"
sleep 0.2
YELLOW "
> Enable 'amdgpu' driver support for: "
NC "
[1] 'Southern Islands' Graphics
[2] 'Sea Islands' Graphics "
BLUE "
Enter a number ${bwhite}(empty to skip)${blue}: "
read -r -p "
==> " islands
case "${islands}" in
1)
sleep 0.2
NC "
==> [${green}Southern Islands OK${nc}]
" ;;
2)
sleep 0.2
NC "
==> [${green}Sea Islands OK${nc}]
" ;;
"")
skip
echo ;;
*)
invalid
return 1 ;;
esac
elif [[ "${vendor}" == "Nvidia" ]]; then
if [[ "${swapmode}" =~ ^(1|2|3)$ ]]; then
sleep 0.2
@@ -1785,99 +1830,35 @@ Enter a number ${bwhite}(empty to skip)${blue}: "
"
read -r -s -n 1
fi
sleep 0.2
YELLOW "
> Select Nvidia architecture: "
NC "
[1] Turing (NV160) Graphics or newer [Nvidia Open]
[2] Maxwell (NV110) Graphics or newer [Nvidia Proprietary / Disabling GSP Firmware available] "
BLUE "
Enter a number: "
read -r -p "
==> " family
case "${family}" in
1) # Turing+ Family
sleep 0.2
NC "
==> [${green}Turing+ OK${nc}]
"
# Linux Kernel
if [[ "${kernelnmbr}" == "1" ]]; then
nvname="nvidia-open"
vgapkgs="libva-mesa-driver libva-nvidia-driver libvdpau-va-gl nvidia-open nvidia-settings nvidia-utils opencl-nvidia opencl-headers vkd3d"
# Other Kernels
else
vgapkgs="libva-mesa-driver libva-nvidia-driver libvdpau-va-gl nvidia-open-dkms nvidia-settings nvidia-utils opencl-nvidia opencl-headers vkd3d"
fi ;;
2) # Maxwell+ Family
sleep 0.2
NC "
==> [${green}Maxwell+ OK${nc}]
"
# Linux Kernel
if [[ "${kernelnmbr}" == "1" ]]; then
nvname="nvidia"
vgapkgs="libva-mesa-driver libva-nvidia-driver libvdpau-va-gl nvidia nvidia-settings nvidia-utils opencl-nvidia opencl-headers vkd3d"
# Linux LTS Kernel
elif [[ "${kernelnmbr}" == "2" ]]; then
nvname="nvidia-lts"
vgapkgs="libva-mesa-driver libva-nvidia-driver libvdpau-va-gl nvidia-lts nvidia-settings nvidia-utils opencl-nvidia opencl-headers vkd3d"
# Other Kernels
else
vgapkgs="libva-mesa-driver libva-nvidia-driver libvdpau-va-gl nvidia-dkms nvidia-settings nvidia-utils opencl-nvidia opencl-headers vkd3d"
fi
local prompt="GSP Firmware Disabled"
sleep 0.2
YELLOW "
> Disable 'GSP' firmware (for troubleshooting) ? [y/n] "
BLUE "
Enter [y/n]: "
read -r -p "
==> " nogsp
if [[ "${nogsp}" == "n" ]]; then
skip
echo
elif [[ "${nogsp}" == "y" ]]; then
ok
echo
else
y_n
return 1
fi ;;
"")
choice
return 1 ;;
*)
invalid
return 1 ;;
esac
if [[ "${family}" == "1" ]]; then
# Linux Kernel
if [[ "${kernelnmbr}" == "1" ]]; then
nvname="nvidia-open"
vgapkgs="libva-mesa-driver libva-nvidia-driver libvdpau-va-gl nvidia-open nvidia-settings nvidia-utils opencl-nvidia opencl-headers vkd3d"
# Other Kernels
else
vgapkgs="libva-mesa-driver libva-nvidia-driver libvdpau-va-gl nvidia-open-dkms nvidia-settings nvidia-utils opencl-nvidia opencl-headers vkd3d"
fi
elif [[ "${family}" == "2" ]]; then
# Linux Kernel
if [[ "${kernelnmbr}" == "1" ]]; then
nvname="nvidia"
vgapkgs="libva-mesa-driver libva-nvidia-driver libvdpau-va-gl nvidia nvidia-settings nvidia-utils opencl-nvidia opencl-headers vkd3d"
# Linux LTS Kernel
elif [[ "${kernelnmbr}" == "2" ]]; then
nvname="nvidia-lts"
vgapkgs="libva-mesa-driver libva-nvidia-driver libvdpau-va-gl nvidia-lts nvidia-settings nvidia-utils opencl-nvidia opencl-headers vkd3d"
# Other Kernels
else
vgapkgs="libva-mesa-driver libva-nvidia-driver libvdpau-va-gl nvidia-dkms nvidia-settings nvidia-utils opencl-nvidia opencl-headers vkd3d"
fi
fi
fi
sleep 0.2
YELLOW "
### ${vendor} Graphics will be automatically configured
"
elif [[ "${vgaconf}" == "n" ]]; then
if [[ "${vendor}" == "nvidia" ]]; then
if [[ "${vendor}" == "Nvidia" ]]; then
vgapkgs="libva-mesa-driver vulkan-nouveau"
fi
skip
fi
vga_slct="yes"
local prompt="Graphics Setup"
ok
}
###################################################################################################
slct_dsktp() {
@@ -3015,7 +2996,7 @@ Enter a disk number: "
### ${yellow}Root Privileges Missing.. ${red}###
-----------------------------------"
reload
until dsks_submn; do : ; done
until main_menu; do : ; done
fi
volumes="$(fdisk -l | grep '^/dev' | cat --number)"
rota="$(lsblk "${instl_drive}" --nodeps --noheadings --output=rota | awk "{print \$1}")"
@@ -3925,8 +3906,8 @@ instl() {
(*) ${nc}Please complete ${yellowl}'Locale & Keyboard Layout Selection'${nc} to continue
"
fi
until slct_locale; do : ; done
until slct_kbd; do : ; done
until slct_locale; do : ; done
until slct_kbd; do : ; done
fi
if [[ -z "${USERNAME}" ]]; then
@@ -3953,7 +3934,7 @@ instl() {
until ask_swap; do : ; done
fi
if [[ "${hypervisor}" == "none" ]]; then
if [[ "${hypervisor}" == "none" && "${vga_slct}" != "yes" ]]; then
local stage_prompt="Graphics Setup"
completion_err
until dtct_vga; do : ; done
@@ -4924,10 +4905,10 @@ revise() {
export "${reset[@]}"
if [[ "${hypervisor}" != "none" ]]; then
vm
vendor="Virtual Machine"
vgaconf="n"
fi
until slct_krnl; do : ; done
until ask_bootldr; do : ; done
until slct_espmnt; do : ; done
@@ -4955,12 +4936,12 @@ revise() {
until luks; do : ; done
until opt_pcmn; do : ; done
until pacstrap_system; do : ; done
if [[ "${swapmode}" == "2" ]]; then
until "${swaptype}"; do : ; done
fi
if [[ -n "${REGDOM}" ]]; then
until wireless_regdom; do : ; done
fi
if [[ "${swapmode}" == "2" ]]; then
until "${swaptype}"; do : ; done
fi
if [[ -n "${REGDOM}" ]]; then
until wireless_regdom; do : ; done
fi
set_vars
chroot_conf
fi
@@ -5316,7 +5297,6 @@ Enter [Y/n]: "
###################################################################################################
pacstrap_system() {
local prompt="Pacstrap System"
sleep 0.2
NC "
@@ -5324,6 +5304,7 @@ pacstrap_system() {
${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Pacstrap System${nc} ${magenta}]${nc}-------------------------------------${magenta}###
"
cnfg
vgapkgs_set
if [[ "${bootloader}" == "2" ]]; then
if [[ "${fs}" == "1" ]]; then
@@ -5471,6 +5452,7 @@ ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Pacs
==> [${green}Fstab OK${nc}] "
fi
local prompt="Pacstrap System"
ok
else
failure