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
+82 -100
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,17 +1695,8 @@ Enter a number: "
### ${sourcetype} drivers will be used
"
fi
vga_conf
}
###################################################################################################
vga_conf() {
if [[ "${vgaconf}" == "y" ]]; then
if [[ "${vendor}" == "Intel" ]]; then
perf_stream="dev.i915.perf_stream_paranoid = 0"
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"
if [[ "${vendor}" == "AMD" ]]; then
sleep 0.2
YELLOW "
@@ -1765,26 +1735,7 @@ Enter a number ${bwhite}(empty to skip)${blue}: "
invalid
return 1 ;;
esac
elif [[ "${vendor}" == "Nvidia" ]]; then
if [[ "${swapmode}" =~ ^(1|2|3)$ ]]; then
sleep 0.2
RED "
----------------------------------------------------------------
### ${yellowl}WARNING: ${nc}${yellow}When ${nc}Hibernating ${red}###
### ${yellow}Nvidia's ${nc}'Preserve Video Memory after suspend' ${yellow}feature ${red}###
### ${yellow}is incompatible with ${nc}'Early KMS' ${yellow}use ${red}###
----------------------------------------------------------------"
NC "
${bwhite}Press any key to continue${nc}
"
read -r -s -n 1
fi
sleep 0.2
YELLOW "
> Select Nvidia architecture: "
@@ -1806,34 +1757,13 @@ Enter a number: "
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 "
@@ -1869,17 +1799,68 @@ Enter [y/n]: "
### ${vendor} Graphics will be automatically configured
"
elif [[ "${vgaconf}" == "n" ]]; then
if [[ "${vendor}" == "nvidia" ]]; then
vgapkgs="libva-mesa-driver vulkan-nouveau"
fi
skip
fi
vga_slct="yes"
local prompt="Graphics Setup"
ok
}
###################################################################################################
vgapkgs_set() {
if [[ "${vgaconf}" == "y" ]]; then
if [[ "${vendor}" == "Intel" ]]; then
perf_stream="dev.i915.perf_stream_paranoid = 0"
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"
elif [[ "${vendor}" == "Nvidia" ]]; then
if [[ "${swapmode}" =~ ^(1|2|3)$ ]]; then
sleep 0.2
RED "
----------------------------------------------------------------
### ${yellowl}WARNING: ${nc}${yellow}When ${nc}Hibernating ${red}###
### ${yellow}Nvidia's ${nc}'Preserve Video Memory after suspend' ${yellow}feature ${red}###
### ${yellow}is incompatible with ${nc}'Early KMS' ${yellow}use ${red}###
----------------------------------------------------------------"
NC "
${bwhite}Press any key to continue${nc}
"
read -r -s -n 1
fi
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
elif [[ "${vgaconf}" == "n" ]]; then
if [[ "${vendor}" == "Nvidia" ]]; then
vgapkgs="libva-mesa-driver vulkan-nouveau"
fi
fi
}
###################################################################################################
slct_dsktp() {
local prompt="Desktop Setup"
@@ -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}")"
@@ -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
@@ -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