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 # Amelia Installer
# Source: https://gitlab.com/prism7/archery # Source: https://gitlab.com/prism7/archery
# Version: 8.8.1 # Version: 8.8.2
set -euo pipefail set -euo pipefail
################################################################################################### ###################################################################################################
@@ -445,10 +445,6 @@ ${magenta}###${nc}-----------------------------------${magenta}[ ${bwhite}System
dtct_hyper() { dtct_hyper() {
hypervisor="$(systemd-detect-virt)" hypervisor="$(systemd-detect-virt)"
if [[ "${hypervisor}" != "none" ]]; then
vendor="Virtual Machine"
vgaconf="n"
fi
case "${hypervisor}" in case "${hypervisor}" in
kvm) kvm)
vmpkgs="spice spice-vdagent spice-protocol spice-gtk qemu-guest-agent swtpm" ;; 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 if [[ "${hypervisor}" != "none" ]]; then
vm vm
vendor="Virtual Machine"
vgaconf="n"
fi fi
if [[ "${CPU}" == *"GenuineIntel"* ]]; then if [[ "${CPU}" == *"GenuineIntel"* ]]; then
@@ -1024,16 +1022,10 @@ Enter a number: "
### The ${kernelname} kernel has been selected ### The ${kernelname} kernel has been selected
" "
ok ok
if [[ "${vga_slct}" == "yes" ]]; then
local stage_prompt="Graphics Setup"
completion_err
until dtct_vga; do : ; done
fi
} }
################################################################################################### ###################################################################################################
ask_bootldr() { ask_bootldr() {
local prompt="Bootloader Selection"
sleep 0.2 sleep 0.2
NC " NC "
@@ -1084,6 +1076,7 @@ Enter a number: "
invalid invalid
return 1 ;; return 1 ;;
esac esac
local prompt="Bootloader Selection"
ok ok
} }
################################################################################################### ###################################################################################################
@@ -1381,7 +1374,7 @@ Enter a number: "
YELLOW " 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 " BLUE "
@@ -1407,11 +1400,6 @@ Enter [Y/n]: "
fi fi
ok ok
if [[ "${vga_slct}" == "yes" ]]; then
local stage_prompt="Graphics Setup"
completion_err
until dtct_vga; do : ; done
fi
} }
################################################################################################### ###################################################################################################
set_swapsize() { set_swapsize() {
@@ -1457,22 +1445,6 @@ dtct_vga() {
--> Graphics Setup skipped --> Graphics Setup skipped
" "
return 0 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 fi
sleep 0.2 sleep 0.2
NC " 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]//')" 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')" 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]//')" 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 if [[ "${vgacount}" == "1" ]]; then
dtct_single_vga dtct_single_vga
@@ -1514,8 +1487,6 @@ dtct_single_vga() {
nvidia nvidia
fi fi
YELLOW "
### ${sourcetype} drivers will be used "
if [[ "${vendor}" == "Nvidia" ]]; then if [[ "${vendor}" == "Nvidia" ]]; then
sleep 0.2 sleep 0.2
RED " RED "
@@ -1525,7 +1496,6 @@ dtct_single_vga() {
fi fi
YELLOW " YELLOW "
> Configure the Graphics subsystem and enable HW acceleration ? [Y/n] > Configure the Graphics subsystem and enable HW acceleration ? [Y/n]
" "
if [[ "${vendor}" == "Nvidia" ]]; then if [[ "${vendor}" == "Nvidia" ]]; then
@@ -1543,8 +1513,12 @@ Enter [Y/n]: "
vgaconf="${vgaconf:-y}" vgaconf="${vgaconf:-y}"
vgaconf="${vgaconf,,}" vgaconf="${vgaconf,,}"
if [[ "${vgaconf}" == "y" || "${vgaconf}" == "n" ]]; then if [[ "${vgaconf}" == "y" ]]; then
vga_conf vga_conf
elif [[ "${vgaconf}" == "n" ]]; then
local prompt="Graphics Setup"
skip
ok
else else
invalid invalid
return 1 return 1
@@ -1602,7 +1576,6 @@ ${nvidiacards}
YELLOW " YELLOW "
> Configure the Graphics subsystem and enable HW acceleration for : " > Configure the Graphics subsystem and enable HW acceleration for : "
if [[ -n "${vendor1}" && -n "${vendor2}" ]]; then if [[ -n "${vendor1}" && -n "${vendor2}" ]]; then
@@ -1698,9 +1671,11 @@ Enter a number: "
if [[ "${vendor}" == "Intel" || "${vendor}" == "AMD" ]]; then if [[ "${vendor}" == "Intel" || "${vendor}" == "AMD" ]]; then
sourcetype="Open-source" sourcetype="Open-source"
vgaconf="y" vgaconf="y"
vga_conf
elif [[ "${vendor}" == "Nvidia" ]]; then elif [[ "${vendor}" == "Nvidia" ]]; then
sourcetype="Proprietary" sourcetype="Proprietary"
vgaconf="y" vgaconf="y"
vga_conf
elif [[ "${vendor}" == "none" ]]; then elif [[ "${vendor}" == "none" ]]; then
local prompt="Graphics Setup" local prompt="Graphics Setup"
vgaconf="n" vgaconf="n"
@@ -1708,6 +1683,10 @@ Enter a number: "
ok ok
return 0 return 0
fi fi
}
###################################################################################################
vga_conf() {
if [[ "${vendor}" != "none" ]]; then if [[ "${vendor}" != "none" ]]; then
sleep 0.2 sleep 0.2
YELLOW " YELLOW "
@@ -1716,10 +1695,115 @@ Enter a number: "
### ${sourcetype} drivers will be used ### ${sourcetype} drivers will be used
" "
fi 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 [[ "${vgaconf}" == "y" ]]; then
if [[ "${vendor}" == "Intel" ]]; 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" 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 elif [[ "${vendor}" == "AMD" ]]; then
vgapkgs="libva-mesa-driver mesa-utils mesa-vdpau opencl-headers rocm-opencl-runtime vkd3d vulkan-mesa-layers vulkan-radeon" 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 elif [[ "${vendor}" == "Nvidia" ]]; then
if [[ "${swapmode}" =~ ^(1|2|3)$ ]]; then if [[ "${swapmode}" =~ ^(1|2|3)$ ]]; then
sleep 0.2 sleep 0.2
@@ -1785,99 +1830,35 @@ Enter a number ${bwhite}(empty to skip)${blue}: "
" "
read -r -s -n 1 read -r -s -n 1
fi fi
sleep 0.2 if [[ "${family}" == "1" ]]; then
YELLOW " # Linux Kernel
> Select Nvidia architecture: " if [[ "${kernelnmbr}" == "1" ]]; then
NC " nvname="nvidia-open"
vgapkgs="libva-mesa-driver libva-nvidia-driver libvdpau-va-gl nvidia-open nvidia-settings nvidia-utils opencl-nvidia opencl-headers vkd3d"
[1] Turing (NV160) Graphics or newer [Nvidia Open] # Other Kernels
else
[2] Maxwell (NV110) Graphics or newer [Nvidia Proprietary / Disabling GSP Firmware available] " vgapkgs="libva-mesa-driver libva-nvidia-driver libvdpau-va-gl nvidia-open-dkms nvidia-settings nvidia-utils opencl-nvidia opencl-headers vkd3d"
BLUE " fi
elif [[ "${family}" == "2" ]]; then
# Linux Kernel
Enter a number: " if [[ "${kernelnmbr}" == "1" ]]; then
read -r -p " nvname="nvidia"
==> " family vgapkgs="libva-mesa-driver libva-nvidia-driver libvdpau-va-gl nvidia nvidia-settings nvidia-utils opencl-nvidia opencl-headers vkd3d"
# Linux LTS Kernel
case "${family}" in elif [[ "${kernelnmbr}" == "2" ]]; then
1) # Turing+ Family nvname="nvidia-lts"
sleep 0.2 vgapkgs="libva-mesa-driver libva-nvidia-driver libvdpau-va-gl nvidia-lts nvidia-settings nvidia-utils opencl-nvidia opencl-headers vkd3d"
NC " # Other Kernels
else
==> [${green}Turing+ OK${nc}] vgapkgs="libva-mesa-driver libva-nvidia-driver libvdpau-va-gl nvidia-dkms nvidia-settings nvidia-utils opencl-nvidia opencl-headers vkd3d"
" fi
# Linux Kernel fi
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
fi fi
sleep 0.2
YELLOW "
### ${vendor} Graphics will be automatically configured
"
elif [[ "${vgaconf}" == "n" ]]; then elif [[ "${vgaconf}" == "n" ]]; then
if [[ "${vendor}" == "nvidia" ]]; then if [[ "${vendor}" == "Nvidia" ]]; then
vgapkgs="libva-mesa-driver vulkan-nouveau" vgapkgs="libva-mesa-driver vulkan-nouveau"
fi fi
skip
fi fi
vga_slct="yes"
local prompt="Graphics Setup"
ok
} }
################################################################################################### ###################################################################################################
slct_dsktp() { slct_dsktp() {
@@ -3015,7 +2996,7 @@ Enter a disk number: "
### ${yellow}Root Privileges Missing.. ${red}### ### ${yellow}Root Privileges Missing.. ${red}###
-----------------------------------" -----------------------------------"
reload reload
until dsks_submn; do : ; done until main_menu; do : ; done
fi fi
volumes="$(fdisk -l | grep '^/dev' | cat --number)" volumes="$(fdisk -l | grep '^/dev' | cat --number)"
rota="$(lsblk "${instl_drive}" --nodeps --noheadings --output=rota | awk "{print \$1}")" 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 (*) ${nc}Please complete ${yellowl}'Locale & Keyboard Layout Selection'${nc} to continue
" "
fi fi
until slct_locale; do : ; done until slct_locale; do : ; done
until slct_kbd; do : ; done until slct_kbd; do : ; done
fi fi
if [[ -z "${USERNAME}" ]]; then if [[ -z "${USERNAME}" ]]; then
@@ -3953,7 +3934,7 @@ instl() {
until ask_swap; do : ; done until ask_swap; do : ; done
fi fi
if [[ "${hypervisor}" == "none" ]]; then if [[ "${hypervisor}" == "none" && "${vga_slct}" != "yes" ]]; then
local stage_prompt="Graphics Setup" local stage_prompt="Graphics Setup"
completion_err completion_err
until dtct_vga; do : ; done until dtct_vga; do : ; done
@@ -4924,10 +4905,10 @@ revise() {
export "${reset[@]}" export "${reset[@]}"
if [[ "${hypervisor}" != "none" ]]; then if [[ "${hypervisor}" != "none" ]]; then
vm
vendor="Virtual Machine" vendor="Virtual Machine"
vgaconf="n" vgaconf="n"
fi fi
until slct_krnl; do : ; done until slct_krnl; do : ; done
until ask_bootldr; do : ; done until ask_bootldr; do : ; done
until slct_espmnt; do : ; done until slct_espmnt; do : ; done
@@ -4955,12 +4936,12 @@ revise() {
until luks; do : ; done until luks; do : ; done
until opt_pcmn; do : ; done until opt_pcmn; do : ; done
until pacstrap_system; do : ; done until pacstrap_system; do : ; done
if [[ "${swapmode}" == "2" ]]; then if [[ "${swapmode}" == "2" ]]; then
until "${swaptype}"; do : ; done until "${swaptype}"; do : ; done
fi fi
if [[ -n "${REGDOM}" ]]; then if [[ -n "${REGDOM}" ]]; then
until wireless_regdom; do : ; done until wireless_regdom; do : ; done
fi fi
set_vars set_vars
chroot_conf chroot_conf
fi fi
@@ -5316,7 +5297,6 @@ Enter [Y/n]: "
################################################################################################### ###################################################################################################
pacstrap_system() { pacstrap_system() {
local prompt="Pacstrap System"
sleep 0.2 sleep 0.2
NC " NC "
@@ -5324,6 +5304,7 @@ pacstrap_system() {
${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Pacstrap System${nc} ${magenta}]${nc}-------------------------------------${magenta}### ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Pacstrap System${nc} ${magenta}]${nc}-------------------------------------${magenta}###
" "
cnfg cnfg
vgapkgs_set
if [[ "${bootloader}" == "2" ]]; then if [[ "${bootloader}" == "2" ]]; then
if [[ "${fs}" == "1" ]]; then if [[ "${fs}" == "1" ]]; then
@@ -5471,6 +5452,7 @@ ${magenta}###${nc}-------------------------------------${magenta}[ ${bwhite}Pacs
==> [${green}Fstab OK${nc}] " ==> [${green}Fstab OK${nc}] "
fi fi
local prompt="Pacstrap System"
ok ok
else else
failure failure