mirror of
https://github.com/kuhyx/scripts.git
synced 2026-07-04 13:03:05 +02:00
feat: added scripts to install different graphics
This commit is contained in:
parent
4f654c3326
commit
952ebb5ab9
@ -11,12 +11,11 @@ cython-git https://aur.archlinux.org/cython-git.git
|
||||
patchelf-git https://aur.archlinux.org/patchelf-git.git
|
||||
utf8cpp-git https://aur.archlinux.org/utf8cpp-git.git
|
||||
valgrind-git https://aur.archlinux.org/valgrind-git.git
|
||||
sdl12-compat-git https://aur.archlinux.org/sdl12-compat-git.git
|
||||
sdl12-compat https://aur.archlinux.org/sdl12-compat.git
|
||||
libvisual https://aur.archlinux.org/libvisual.git
|
||||
wayland-protocols-git https://aur.archlinux.org/wayland-protocols-git.git
|
||||
libshout-git https://aur.archlinux.org/libshout-git.git
|
||||
taglib-git https://aur.archlinux.org/taglib-git.git
|
||||
wavpack-git https://aur.archlinux.org/wavpack-git.git
|
||||
libshout https://aur.archlinux.org/libshout.git
|
||||
taglib https://aur.archlinux.org/taglib.git
|
||||
wavpack https://aur.archlinux.org/wavpack.git
|
||||
autoconf-archive-git https://aur.archlinux.org/autoconf-archive-git.git
|
||||
vulkan-utility-libraries-git https://aur.archlinux.org/vulkan-utility-libraries-git.git
|
||||
chromaprint-git https://aur.archlinux.org/chromaprint-git.git
|
||||
|
||||
46
fresh-install/detect_gpu.sh
Normal file
46
fresh-install/detect_gpu.sh
Normal file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
# Lightweight GPU detection script.
|
||||
# Detects GPU vendor and invokes the corresponding vendor install/management script.
|
||||
# Exports: GPU_VENDOR
|
||||
set -e
|
||||
|
||||
GPU_VENDOR="unknown"
|
||||
PCI_GPU_INFO=$(lspci -nn | grep -Ei 'vga|3d|display' || true)
|
||||
|
||||
if echo "$PCI_GPU_INFO" | grep -qi nvidia; then
|
||||
GPU_VENDOR="nvidia"
|
||||
elif echo "$PCI_GPU_INFO" | grep -Eqi '\b(amd|advanced micro devices|ati)\b'; then
|
||||
GPU_VENDOR="amd"
|
||||
elif echo "$PCI_GPU_INFO" | grep -qi intel; then
|
||||
GPU_VENDOR="intel"
|
||||
fi
|
||||
|
||||
export GPU_VENDOR
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
case "$GPU_VENDOR" in
|
||||
nvidia)
|
||||
if [ -x "$SCRIPT_DIR/install_nvidia_driver.sh" ]; then
|
||||
. "$SCRIPT_DIR/install_nvidia_driver.sh"
|
||||
else
|
||||
echo "NVIDIA installer script missing: $SCRIPT_DIR/install_nvidia_driver.sh"
|
||||
fi
|
||||
;;
|
||||
amd)
|
||||
if [ -x "$SCRIPT_DIR/install_amd_driver.sh" ]; then
|
||||
. "$SCRIPT_DIR/install_amd_driver.sh"
|
||||
else
|
||||
echo "AMD installer script missing: $SCRIPT_DIR/install_amd_driver.sh (placeholder)"
|
||||
fi
|
||||
;;
|
||||
intel)
|
||||
if [ -x "$SCRIPT_DIR/install_intel_driver.sh" ]; then
|
||||
. "$SCRIPT_DIR/install_intel_driver.sh"
|
||||
else
|
||||
echo "Intel installer script missing: $SCRIPT_DIR/install_intel_driver.sh"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unknown / no discrete GPU detected."
|
||||
;;
|
||||
esac
|
||||
@ -1,51 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Detect GPU vendor and (if NVIDIA) install required driver packages.
|
||||
# Exports GPU_VENDOR and SKIP_NVIDIA_PACKAGES variables for caller scripts.
|
||||
set -e
|
||||
|
||||
GPU_VENDOR="unknown"
|
||||
|
||||
# Get all display / 3D / VGA controllers
|
||||
PCI_GPU_INFO=$(lspci -nn | grep -Ei 'vga|3d|display' || true)
|
||||
|
||||
if echo "$PCI_GPU_INFO" | grep -qi nvidia; then
|
||||
GPU_VENDOR="nvidia"
|
||||
elif echo "$PCI_GPU_INFO" | grep -Eqi 'amd|advanced micro devices|ati'; then
|
||||
GPU_VENDOR="amd"
|
||||
elif echo "$PCI_GPU_INFO" | grep -qi intel; then
|
||||
GPU_VENDOR="intel"
|
||||
fi
|
||||
|
||||
export GPU_VENDOR
|
||||
|
||||
NVIDIA_PACKAGES=(nvidia nvidia-utils lib32-nvidia-utils)
|
||||
|
||||
if [ "$GPU_VENDOR" = "nvidia" ]; then
|
||||
echo "Detected NVIDIA GPU. Ensuring NVIDIA packages are installed."
|
||||
for pkg in "${NVIDIA_PACKAGES[@]}"; do
|
||||
if pacman -Qi "$pkg" >/dev/null 2>&1; then
|
||||
echo " $pkg already installed"
|
||||
else
|
||||
echo " Installing $pkg"
|
||||
yes | sudo pacman -Sy --noconfirm "$pkg"
|
||||
fi
|
||||
done
|
||||
export SKIP_NVIDIA_PACKAGES="false"
|
||||
else
|
||||
echo "Detected GPU vendor: $GPU_VENDOR (not NVIDIA). Skipping NVIDIA driver installation."
|
||||
# If any NVIDIA packages are present, remove them.
|
||||
to_remove=()
|
||||
for pkg in "${NVIDIA_PACKAGES[@]}"; do
|
||||
if pacman -Qi "$pkg" >/dev/null 2>&1; then
|
||||
to_remove+=("$pkg")
|
||||
fi
|
||||
done
|
||||
if [ ${#to_remove[@]} -gt 0 ]; then
|
||||
echo "Removing NVIDIA specific packages: ${to_remove[*]}"
|
||||
# Use --noconfirm and Rns to remove packages with their unused deps.
|
||||
yes | sudo pacman -Rns --noconfirm "${to_remove[@]}" || true
|
||||
else
|
||||
echo "No NVIDIA packages installed to remove."
|
||||
fi
|
||||
export SKIP_NVIDIA_PACKAGES="true"
|
||||
fi
|
||||
# Backwards compatibility wrapper; prefer using detect_gpu.sh directly.
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
. "$SCRIPT_DIR/detect_gpu.sh"
|
||||
|
||||
147
fresh-install/install_amd_driver.sh
Executable file
147
fresh-install/install_amd_driver.sh
Executable file
@ -0,0 +1,147 @@
|
||||
#!/usr/bin/env bash
|
||||
# AMD GPU installation & configuration script (Open source focus per Arch Wiki)
|
||||
# Expects GPU_VENDOR=amd (set by detect_gpu.sh)
|
||||
# Environment overrides:
|
||||
# AMD_INSTALL_XF86=1 # install xf86-video-amdgpu (default 0)
|
||||
# AMD_INSTALL_AMDVLK=1 # also install amdvlk (default 0)
|
||||
# AMD_INSTALL_LIB32=1 # force install 32-bit libs even if multilib not detected (default 0)
|
||||
# AMD_USE_MESA_GIT=1 # use mesa-git / lib32-mesa-git (AUR) instead of repo mesa
|
||||
# AMD_USE_VULKAN_GIT=1 # use vulkan-radeon-git instead of vulkan-radeon
|
||||
# AMD_ENABLE_SI_CIK=auto|1|0 # auto (default) enable amdgpu for SI/CIK if detected
|
||||
# AMD_SKIP_INITRAMFS=1 # do not regenerate initramfs automatically
|
||||
# AMD_VERBOSE=1 # verbose output
|
||||
set -e
|
||||
|
||||
[ "${GPU_VENDOR}" = "amd" ] || { echo "AMD installer invoked but GPU_VENDOR=${GPU_VENDOR}"; exit 0; }
|
||||
|
||||
AMD_INSTALL_XF86=${AMD_INSTALL_XF86:-0}
|
||||
AMD_INSTALL_AMDVLK=${AMD_INSTALL_AMDVLK:-0}
|
||||
AMD_INSTALL_LIB32=${AMD_INSTALL_LIB32:-0}
|
||||
AMD_USE_MESA_GIT=${AMD_USE_MESA_GIT:-0}
|
||||
AMD_USE_VULKAN_GIT=${AMD_USE_VULKAN_GIT:-0}
|
||||
AMD_ENABLE_SI_CIK=${AMD_ENABLE_SI_CIK:-auto}
|
||||
AMD_SKIP_INITRAMFS=${AMD_SKIP_INITRAMFS:-0}
|
||||
AMD_VERBOSE=${AMD_VERBOSE:-0}
|
||||
|
||||
vlog() { [ "$AMD_VERBOSE" = 1 ] && echo "[amd] $*" || true; }
|
||||
info() { echo "[amd] $*"; }
|
||||
warn() { echo "[amd][warn] $*" >&2; }
|
||||
|
||||
# Detect multilib enabled
|
||||
if grep -q '^\[multilib\]' /etc/pacman.conf; then
|
||||
MULTILIB_ENABLED=1
|
||||
else
|
||||
MULTILIB_ENABLED=0
|
||||
fi
|
||||
|
||||
# Basic packages
|
||||
BASE_PKGS=(mesa)
|
||||
[ "$AMD_USE_MESA_GIT" = 1 ] && BASE_PKGS=(mesa-git)
|
||||
|
||||
VULKAN_PKG="vulkan-radeon"
|
||||
[ "$AMD_USE_VULKAN_GIT" = 1 ] && VULKAN_PKG="vulkan-radeon-git"
|
||||
|
||||
XF86_PKG="xf86-video-amdgpu"
|
||||
|
||||
# 32-bit packages
|
||||
LIB32_BASE=(lib32-mesa)
|
||||
[ "$AMD_USE_MESA_GIT" = 1 ] && LIB32_BASE=(lib32-mesa-git)
|
||||
LIB32_VULKAN_PKG="lib32-vulkan-radeon"
|
||||
[ "$AMD_USE_VULKAN_GIT" = 1 ] && LIB32_VULKAN_PKG="lib32-vulkan-radeon-git"
|
||||
|
||||
# Optional AMDVLK packages
|
||||
AMDVLK_PKG="amdvlk"
|
||||
LIB32_AMDVLK_PKG="lib32-amdvlk"
|
||||
|
||||
# Simple AUR builder (reused from NVIDIA script style)
|
||||
_build_aur_pkg() {
|
||||
local pkg="$1" url="https://aur.archlinux.org/${pkg}.git"
|
||||
mkdir -p "$HOME/aur"; cd "$HOME/aur"
|
||||
if [ ! -d "$pkg" ]; then git clone "$url"; else (cd "$pkg" && git fetch -q --all && git reset -q --hard origin/HEAD || git pull --ff-only || true); fi
|
||||
cd "$pkg"; rm -f -- *.pkg.tar.* 2>/dev/null || true
|
||||
yes | makepkg -s -c -C --noconfirm --needed
|
||||
local built=( *.pkg.tar.zst )
|
||||
yes | sudo pacman -U --noconfirm "${built[@]}"
|
||||
}
|
||||
|
||||
_install_repo_or_aur() {
|
||||
local pkg="$1"
|
||||
if pacman -Si "$pkg" >/dev/null 2>&1; then
|
||||
if pacman -Qi "$pkg" >/dev/null 2>&1; then
|
||||
vlog "$pkg already installed"
|
||||
else
|
||||
yes | sudo pacman -Sy --noconfirm "$pkg"
|
||||
fi
|
||||
else
|
||||
info "Building AUR package: $pkg"
|
||||
_build_aur_pkg "$pkg"
|
||||
fi
|
||||
}
|
||||
|
||||
info "Installing AMD GPU stack"
|
||||
for p in "${BASE_PKGS[@]}" "$VULKAN_PKG"; do _install_repo_or_aur "$p"; done
|
||||
|
||||
if [ "$AMD_INSTALL_XF86" = 1 ]; then
|
||||
_install_repo_or_aur "$XF86_PKG"
|
||||
fi
|
||||
|
||||
# AMDVLK optional (install after vulkan-radeon if requested)
|
||||
if [ "$AMD_INSTALL_AMDVLK" = 1 ]; then
|
||||
_install_repo_or_aur "$AMDVLK_PKG"
|
||||
fi
|
||||
|
||||
if [ $MULTILIB_ENABLED = 1 ] || [ "$AMD_INSTALL_LIB32" = 1 ]; then
|
||||
for p in "${LIB32_BASE[@]}" "$LIB32_VULKAN_PKG"; do _install_repo_or_aur "$p"; done
|
||||
if [ "$AMD_INSTALL_AMDVLK" = 1 ]; then _install_repo_or_aur "$LIB32_AMDVLK_PKG"; fi
|
||||
else
|
||||
vlog "Skipping 32-bit packages (multilib disabled)"
|
||||
fi
|
||||
|
||||
# Detect SI / CIK codename presence for optional amdgpu enablement
|
||||
GPU_LINES=$(lspci -nn | grep -Ei 'vga|3d|display' | grep -iE 'amd|ati' || true)
|
||||
SI_NAMES=(Tahiti Pitcairn Cape Verde Oland Hainan Curacao)
|
||||
CIK_NAMES=(Bonaire Hawaii Kabini Kaveri Mullins Temash Spectre Spooky)
|
||||
IS_SI=0; IS_CIK=0
|
||||
for n in "${SI_NAMES[@]}"; do echo "$GPU_LINES" | grep -q "$n" && IS_SI=1 && break; done
|
||||
for n in "${CIK_NAMES[@]}"; do echo "$GPU_LINES" | grep -q "$n" && IS_CIK=1 && break; done
|
||||
|
||||
if [ "$AMD_ENABLE_SI_CIK" = "1" ] || { [ "$AMD_ENABLE_SI_CIK" = "auto" ] && { [ $IS_SI = 1 ] || [ $IS_CIK = 1 ]; }; }; then
|
||||
info "Configuring amdgpu for SI/CIK (IS_SI=$IS_SI IS_CIK=$IS_CIK)"
|
||||
TMP_CONF=$(mktemp)
|
||||
printf 'options amdgpu si_support=1\noptions amdgpu cik_support=1\n' > "$TMP_CONF"
|
||||
printf 'options radeon si_support=0\noptions radeon cik_support=0\n' >> "$TMP_CONF"
|
||||
sudo mkdir -p /etc/modprobe.d
|
||||
sudo cp "$TMP_CONF" /etc/modprobe.d/10-amdgpu-si-cik.conf
|
||||
rm -f "$TMP_CONF"
|
||||
# Ensure amdgpu early in MODULES
|
||||
if [ -f /etc/mkinitcpio.conf ]; then
|
||||
if ! grep -q '^MODULES=.*amdgpu' /etc/mkinitcpio.conf; then
|
||||
sudo sed -i 's/^MODULES=\(.*\)/MODULES=(amdgpu radeon)/' /etc/mkinitcpio.conf || true
|
||||
fi
|
||||
if ! grep -q 'modconf' /etc/mkinitcpio.conf; then
|
||||
warn "modconf hook not found in mkinitcpio.conf (needed for module options)"
|
||||
fi
|
||||
if [ "$AMD_SKIP_INITRAMFS" != 1 ]; then
|
||||
info "Regenerating initramfs (mkinitcpio -P)"
|
||||
sudo mkinitcpio -P || warn "mkinitcpio failed; review manually"
|
||||
else
|
||||
info "Skipping initramfs regeneration per AMD_SKIP_INITRAMFS=1"
|
||||
fi
|
||||
else
|
||||
warn "/etc/mkinitcpio.conf not found; skipping MODULES update"
|
||||
fi
|
||||
else
|
||||
vlog "SI/CIK enablement not required (AMD_ENABLE_SI_CIK=$AMD_ENABLE_SI_CIK IS_SI=$IS_SI IS_CIK=$IS_CIK)"
|
||||
fi
|
||||
|
||||
# Check active kernel driver
|
||||
KDRV=$(lspci -k -d ::0300 2>/dev/null | awk '/Kernel driver in use:/ {print $5; exit}')
|
||||
[ -z "$KDRV" ] && KDRV=$(lsmod | grep -E 'amdgpu|radeon' | head -n1 | awk '{print $1}')
|
||||
info "Kernel driver in use: ${KDRV:-unknown}"
|
||||
|
||||
if [ "$KDRV" = "radeon" ] && { [ $IS_SI = 1 ] || [ $IS_CIK = 1 ]; }; then
|
||||
warn "radeon driver still active for SI/CIK; reboot may be required to switch to amdgpu"
|
||||
fi
|
||||
|
||||
export AMD_STACK_DONE=1
|
||||
info "AMD GPU stack installation complete"
|
||||
105
fresh-install/install_intel_driver.sh
Executable file
105
fresh-install/install_intel_driver.sh
Executable file
@ -0,0 +1,105 @@
|
||||
#!/usr/bin/env bash
|
||||
# Intel GPU installation & configuration script (open source stack)
|
||||
# Expects GPU_VENDOR=intel
|
||||
# Environment overrides:
|
||||
# INTEL_USE_AMBER=0/1 # use mesa-amber instead of mesa (legacy Gen2-11 classic drivers)
|
||||
# INTEL_INSTALL_LIB32=auto/1/0 # install 32-bit libs (auto: only if multilib enabled) default auto
|
||||
# INTEL_INSTALL_VULKAN=1/0 # install vulkan-intel (default 1)
|
||||
# INTEL_INSTALL_LIB32_VK=auto/1/0 # 32-bit vulkan driver (auto: if 32-bit mesa installed) default auto
|
||||
# INTEL_INSTALL_XF86=0/1 # install xf86-video-intel legacy DDX (default 0, not recommended)
|
||||
# INTEL_ENABLE_GUC= # empty (do nothing) or 0/1/2/3 value to set enable_guc= kernel param
|
||||
# INTEL_SKIP_INITRAMFS=0/1 # skip mkinitcpio regeneration (default 0)
|
||||
# INTEL_VERBOSE=0/1 # verbose logging
|
||||
set -e
|
||||
|
||||
[ "$GPU_VENDOR" = "intel" ] || { echo "Intel installer invoked but GPU_VENDOR=$GPU_VENDOR"; exit 0; }
|
||||
|
||||
INTEL_USE_AMBER=${INTEL_USE_AMBER:-0}
|
||||
INTEL_INSTALL_LIB32=${INTEL_INSTALL_LIB32:-auto}
|
||||
INTEL_INSTALL_VULKAN=${INTEL_INSTALL_VULKAN:-1}
|
||||
INTEL_INSTALL_LIB32_VK=${INTEL_INSTALL_LIB32_VK:-auto}
|
||||
INTEL_INSTALL_XF86=${INTEL_INSTALL_XF86:-0}
|
||||
INTEL_ENABLE_GUC=${INTEL_ENABLE_GUC:-}
|
||||
INTEL_SKIP_INITRAMFS=${INTEL_SKIP_INITRAMFS:-0}
|
||||
INTEL_VERBOSE=${INTEL_VERBOSE:-1}
|
||||
|
||||
vlog() { [ "$INTEL_VERBOSE" = 1 ] && echo "[intel] $*" || true; }
|
||||
info() { echo "[intel] $*"; }
|
||||
warn() { echo "[intel][warn] $*" >&2; }
|
||||
|
||||
# Detect multilib
|
||||
if grep -q '^\[multilib\]' /etc/pacman.conf; then MULTILIB=1; else MULTILIB=0; fi
|
||||
|
||||
# Base mesa package
|
||||
if [ "$INTEL_USE_AMBER" = 1 ]; then
|
||||
BASE_MESA=mesa-amber
|
||||
LIB32_BASE=lib32-mesa-amber
|
||||
else
|
||||
BASE_MESA=mesa
|
||||
LIB32_BASE=lib32-mesa
|
||||
fi
|
||||
|
||||
install_pkg() {
|
||||
local pkg="$1"
|
||||
if pacman -Qi "$pkg" >/dev/null 2>&1; then
|
||||
vlog "$pkg already installed"
|
||||
else
|
||||
if pacman -Si "$pkg" >/dev/null 2>&1; then
|
||||
yes | sudo pacman -Sy --noconfirm "$pkg"
|
||||
else
|
||||
warn "Package $pkg not found in repos (not handling AUR here)"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
info "Installing Intel GPU stack"
|
||||
install_pkg "$BASE_MESA"
|
||||
|
||||
# 32-bit mesa
|
||||
if { [ "$INTEL_INSTALL_LIB32" = auto ] && [ $MULTILIB = 1 ]; } || [ "$INTEL_INSTALL_LIB32" = 1 ]; then
|
||||
install_pkg "$LIB32_BASE"
|
||||
else
|
||||
vlog "Skipping 32-bit mesa (INTEL_INSTALL_LIB32=$INTEL_INSTALL_LIB32 MULTILIB=$MULTILIB)"
|
||||
fi
|
||||
|
||||
# Vulkan
|
||||
if [ "$INTEL_INSTALL_VULKAN" = 1 ]; then
|
||||
install_pkg vulkan-intel
|
||||
if { [ "$INTEL_INSTALL_LIB32_VK" = auto ] && [ $MULTILIB = 1 ]; } || [ "$INTEL_INSTALL_LIB32_VK" = 1 ]; then
|
||||
install_pkg lib32-vulkan-intel
|
||||
else
|
||||
vlog "Skipping 32-bit vulkan (INTEL_INSTALL_LIB32_VK=$INTEL_INSTALL_LIB32_VK MULTILIB=$MULTILIB)"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Legacy xf86-video-intel (not recommended)
|
||||
if [ "$INTEL_INSTALL_XF86" = 1 ]; then
|
||||
install_pkg xf86-video-intel
|
||||
else
|
||||
vlog "Not installing xf86-video-intel (INTEL_INSTALL_XF86=$INTEL_INSTALL_XF86)"
|
||||
fi
|
||||
|
||||
# GuC / HuC enablement
|
||||
if [ -n "$INTEL_ENABLE_GUC" ]; then
|
||||
if ! echo "$INTEL_ENABLE_GUC" | grep -Eq '^[0-3]$'; then
|
||||
warn "INTEL_ENABLE_GUC must be 0..3; ignoring"
|
||||
else
|
||||
info "Configuring enable_guc=$INTEL_ENABLE_GUC"
|
||||
sudo mkdir -p /etc/modprobe.d
|
||||
echo "options i915 enable_guc=$INTEL_ENABLE_GUC" | sudo tee /etc/modprobe.d/i915-guc.conf >/dev/null
|
||||
if [ "$INTEL_SKIP_INITRAMFS" != 1 ] && [ -f /etc/mkinitcpio.conf ]; then
|
||||
info "Regenerating initramfs (mkinitcpio -P) for GuC/HuC change"
|
||||
sudo mkinitcpio -P || warn "mkinitcpio failed; continue manually"
|
||||
else
|
||||
info "Skipping initramfs regeneration (INTEL_SKIP_INITRAMFS=$INTEL_SKIP_INITRAMFS)"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Report kernel driver
|
||||
KDRV=$(lspci -k -d ::0300 2>/dev/null | awk '/Kernel driver in use:/ {print $5; exit}')
|
||||
[ -z "$KDRV" ] && KDRV=$(lsmod | grep -E 'i915|xe' | head -n1 | awk '{print $1}')
|
||||
info "Kernel driver in use: ${KDRV:-unknown}"
|
||||
|
||||
info "Intel GPU stack installation complete"
|
||||
export INTEL_STACK_DONE=1
|
||||
69
fresh-install/install_nvidia_driver.sh
Executable file
69
fresh-install/install_nvidia_driver.sh
Executable file
@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env bash
|
||||
# NVIDIA driver selection & installation (split from detect script)
|
||||
# Expects GPU_VENDOR=nvidia
|
||||
# Outputs: NVIDIA_DRIVER_PACKAGE
|
||||
set -e
|
||||
|
||||
[ "$GPU_VENDOR" = "nvidia" ] || { echo "NVIDIA installer invoked but GPU_VENDOR=$GPU_VENDOR"; exit 0; }
|
||||
|
||||
_build_aur_pkg() {
|
||||
local pkg="$1"; local repo_url="https://aur.archlinux.org/${pkg}.git";
|
||||
mkdir -p "$HOME/aur"; cd "$HOME/aur";
|
||||
if [ ! -d "$pkg" ]; then git clone "$repo_url"; else (cd "$pkg" && git fetch -q --all && git reset -q --hard origin/HEAD || git pull --ff-only || true); fi
|
||||
cd "$pkg"; rm -f -- *.pkg.tar.* 2>/dev/null || true
|
||||
yes | makepkg -s -c -C --noconfirm --needed || return 1
|
||||
local built=( *.pkg.tar.zst ); yes | sudo pacman -U --noconfirm "${built[@]}"
|
||||
}
|
||||
|
||||
_choose_nvidia_pkg() {
|
||||
local have_linux have_linux_lts multiple_kernels driver_pkg prefer_open
|
||||
prefer_open=${NVIDIA_PREFER_OPEN:-1}
|
||||
pacman -Qq | grep -qx linux && have_linux=1 || have_linux=0
|
||||
pacman -Qq | grep -qx linux-lts && have_linux_lts=1 || have_linux_lts=0
|
||||
if [ $((have_linux + have_linux_lts)) -gt 1 ]; then multiple_kernels=1; else multiple_kernels=0; fi
|
||||
if ! command -v nvidia-detect >/dev/null 2>&1; then yes | sudo pacman -Sy --noconfirm nvidia-detect || true; fi
|
||||
local detect_out="$(nvidia-detect 2>/dev/null || true)"
|
||||
if echo "$detect_out" | grep -q '470'; then driver_pkg='nvidia-470xx-dkms';
|
||||
elif echo "$detect_out" | grep -q '390'; then driver_pkg='nvidia-390xx-dkms';
|
||||
elif echo "$detect_out" | grep -q '340'; then driver_pkg='nvidia-340xx-dkms';
|
||||
else
|
||||
if [ "$multiple_kernels" = 1 ]; then
|
||||
if [ "$prefer_open" = 1 ] && pacman -Si nvidia-open-dkms >/dev/null 2>&1; then driver_pkg='nvidia-open-dkms'; else driver_pkg='nvidia-dkms'; fi
|
||||
else
|
||||
if [ "$have_linux_lts" = 1 ] && [ "$have_linux" = 0 ]; then
|
||||
if [ "$prefer_open" = 1 ] && pacman -Si nvidia-open-lts >/dev/null 2>&1; then driver_pkg='nvidia-open-lts'; else driver_pkg='nvidia-lts'; fi
|
||||
else
|
||||
if [ "$prefer_open" = 1 ] && pacman -Si nvidia-open >/dev/null 2>&1; then driver_pkg='nvidia-open'; else driver_pkg='nvidia'; fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
echo "$driver_pkg"
|
||||
}
|
||||
|
||||
_remove_conflicting_nvidia_pkgs() {
|
||||
local keep="$1"; local candidates=(nvidia nvidia-lts nvidia-dkms nvidia-open nvidia-open-lts nvidia-open-dkms nvidia-470xx-dkms nvidia-390xx-dkms nvidia-340xx-dkms)
|
||||
local to_remove=()
|
||||
for p in "${candidates[@]}"; do
|
||||
if pacman -Qi "$p" >/dev/null 2>&1 && [ "$p" != "$keep" ]; then to_remove+=("$p"); fi
|
||||
done
|
||||
if [ ${#to_remove[@]} -gt 0 ]; then yes | sudo pacman -Rns --noconfirm "${to_remove[@]}" || true; fi
|
||||
}
|
||||
|
||||
_install_nvidia_stack() {
|
||||
local driver_pkg="$1"
|
||||
if [[ "$driver_pkg" == nvidia-*xx-dkms ]]; then _build_aur_pkg "$driver_pkg"; else yes | sudo pacman -Sy --noconfirm "$driver_pkg"; fi
|
||||
local utils_pkg="nvidia-utils" utils32_pkg="lib32-nvidia-utils"
|
||||
if ! pacman -Qi "$utils_pkg" >/dev/null 2>&1; then yes | sudo pacman -Sy --noconfirm "$utils_pkg"; fi
|
||||
if grep -q '^\[multilib\]' /etc/pacman.conf; then
|
||||
if ! pacman -Qi "$utils32_pkg" >/dev/null 2>&1; then yes | sudo pacman -Sy --noconfirm "$utils32_pkg" || true; fi
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Detected NVIDIA GPU. Selecting driver..."
|
||||
NVIDIA_DRIVER_PACKAGE=$(_choose_nvidia_pkg)
|
||||
export NVIDIA_DRIVER_PACKAGE
|
||||
_remove_conflicting_nvidia_pkgs "$NVIDIA_DRIVER_PACKAGE"
|
||||
_install_nvidia_stack "$NVIDIA_DRIVER_PACKAGE"
|
||||
export SKIP_NVIDIA_PACKAGES="false"
|
||||
echo "NVIDIA driver installation finished (package: $NVIDIA_DRIVER_PACKAGE)"
|
||||
echo "Optional: adjust /etc/mkinitcpio.conf (remove kms) then: sudo mkinitcpio -P"
|
||||
@ -17,11 +17,13 @@ trap 'play_error_sound' ERR
|
||||
sudo -v
|
||||
git config --global init.defaultBranch main
|
||||
|
||||
# GPU detection and conditional NVIDIA driver installation
|
||||
if [ -f "./detect_gpu_and_install.sh" ]; then
|
||||
# GPU detection (now split vendor-specific logic)
|
||||
if [ -f "./detect_gpu.sh" ]; then
|
||||
. ./detect_gpu.sh
|
||||
elif [ -f "./detect_gpu_and_install.sh" ]; then
|
||||
. ./detect_gpu_and_install.sh
|
||||
else
|
||||
echo "GPU detection script not found; continuing without conditional NVIDIA install."
|
||||
echo "GPU detection scripts not found; continuing without GPU specific installation."
|
||||
fi
|
||||
|
||||
install_from_aur() {
|
||||
|
||||
@ -298,3 +298,4 @@ yasm
|
||||
a52dec
|
||||
deluge
|
||||
screengrab
|
||||
python-poetry
|
||||
Loading…
Reference in New Issue
Block a user