feat: added arch wiki local special script for nvidia drivers removed some packages

This commit is contained in:
Krzysztof Rudnicki 2025-08-14 12:46:26 +02:00
parent 7a4ebe2fac
commit 4f654c3326
4 changed files with 139 additions and 21 deletions

View File

@ -1,7 +1,8 @@
local-arch-wiki https://aur.archlinux.org/local-arch-wiki.git
visual-studio-code-bin https://aur.archlinux.org/visual-studio-code-bin.git visual-studio-code-bin https://aur.archlinux.org/visual-studio-code-bin.git
thorium-browser-bin https://aur.archlinux.org/thorium-browser-bin.git thorium-browser-bin https://aur.archlinux.org/thorium-browser-bin.git
mkinitcpio-git https://aur.archlinux.org/mkinitcpio-git.git mkinitcpio-git https://aur.archlinux.org/mkinitcpio-git.git
yay-git https://aur.archlinux.org/yay-git.git yay https://aur.archlinux.org/yay.git
http-parser-git https://aur.archlinux.org/http-parser-git.git http-parser-git https://aur.archlinux.org/http-parser-git.git
python310 https://aur.archlinux.org/python310.git python310 https://aur.archlinux.org/python310.git
slack-electron https://aur.archlinux.org/slack-electron.git slack-electron https://aur.archlinux.org/slack-electron.git

View File

@ -0,0 +1,51 @@
#!/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

View File

@ -17,25 +17,56 @@ trap 'play_error_sound' ERR
sudo -v sudo -v
git config --global init.defaultBranch main git config --global init.defaultBranch main
# GPU detection and conditional NVIDIA driver installation
if [ -f "./detect_gpu_and_install.sh" ]; then
. ./detect_gpu_and_install.sh
else
echo "GPU detection script not found; continuing without conditional NVIDIA install."
fi
install_from_aur() { install_from_aur() {
if [ ! -d "$HOME/aur" ]; then if [ ! -d "$HOME/aur" ]; then
mkdir ~/aur mkdir -p "$HOME/aur"
fi fi
cd ~/aur cd "$HOME/aur"
local repo_url=$1 local repo_url=$1
local pkg_name=$2 local pkg_name=$2
local repo_dir="$(basename "$repo_url" .git)"
if [ ! -d "$(basename $repo_url .git)" ]; then if [ ! -d "$repo_dir" ]; then
git clone $repo_url git clone "$repo_url"
else else
echo "Repository $(basename $repo_url .git) already cloned" echo "Repository $repo_dir already cloned; updating"
(cd "$repo_dir" && git fetch --all -q && git reset --hard origin/HEAD -q || git pull --ff-only || true)
fi fi
cd $(basename $repo_url .git) cd "$repo_dir"
if ! pacman -Qi $pkg_name > /dev/null 2>&1; then
yes | makepkg -s --nocheck --skipchecksums --skipinteg --skippgpcheck --noconfirm --needed if pacman -Qi "$pkg_name" >/dev/null 2>&1; then
yes | sudo pacman -U *.pkg.tar.zst
else
echo "$pkg_name is already installed" echo "$pkg_name is already installed"
return 0
fi
echo "Cleaning old package artifacts to avoid duplicate -U targets"
find . -maxdepth 1 -type f -name '*.pkg.tar.*' -delete 2>/dev/null || true
echo "Building $pkg_name (clean build)"
# -c (clean up work dirs after) -C (clean build - remove src/ and pkg/ first)
if ! yes | makepkg -s -c -C --noconfirm --nocheck --skipchecksums --skipinteg --skippgpcheck --needed; then
echo "Build failed for $pkg_name" >&2
return 1
fi
# Collect only the freshly built packages (should now be only current version)
mapfile -t built_pkgs < <(ls -1 *.pkg.tar.zst 2>/dev/null || true)
if [ ${#built_pkgs[@]} -eq 0 ]; then
echo "No package files produced for $pkg_name" >&2
return 1
fi
echo "Installing built package(s): ${built_pkgs[*]}"
if ! yes | sudo pacman -U --noconfirm "${built_pkgs[@]}"; then
echo "Installation failed for $pkg_name" >&2
return 1
fi fi
} }
@ -90,9 +121,42 @@ sudo cp ./pacman.conf /etc/pacman.conf
# sudo cp /etc/mkinitcpio.conf /etc/mkinitcpio.conf.bak # sudo cp /etc/mkinitcpio.conf /etc/mkinitcpio.conf.bak
# sudo cp ./mkinitcpio.conf /etc/mkinitcpio.conf # sudo cp ./mkinitcpio.conf /etc/mkinitcpio.conf
# mkinitcpio -P # mkinitcpio -P
yes | sudo pacman -Sy --noconfirm reflector # Reflector install / service management (idempotent & resilient)
sudo systemctl enable reflector.service if pacman -Qi reflector >/dev/null 2>&1; then
sudo systemctl start reflector.service echo "reflector already installed"
else
yes | sudo pacman -Sy --noconfirm reflector || echo "Warning: reflector install failed (continuing)"
fi
# Prefer timer over service (Arch default)
if systemctl list-unit-files | grep -q '^reflector.timer'; then
if systemctl is-enabled reflector.timer >/dev/null 2>&1; then
echo "reflector.timer already enabled"
else
sudo systemctl enable reflector.timer || echo "Warning: could not enable reflector.timer"
fi
if systemctl is-active reflector.timer >/dev/null 2>&1; then
echo "reflector.timer already active"
else
if ! sudo systemctl start reflector.timer; then
echo "Warning: failed to start reflector.timer (check: systemctl status reflector.timer; journalctl -xeu reflector.timer)"
fi
fi
elif systemctl list-unit-files | grep -q '^reflector.service'; then
if systemctl is-enabled reflector.service >/dev/null 2>&1; then
echo "reflector.service already enabled"
else
sudo systemctl enable reflector.service || echo "Warning: could not enable reflector.service"
fi
if systemctl is-active reflector.service >/dev/null 2>&1; then
echo "reflector.service already running"
else
if ! sudo systemctl start reflector.service; then
echo "Warning: failed to start reflector.service (check: systemctl status reflector.service; journalctl -xeu reflector.service)"
fi
fi
else
echo "reflector systemd unit not found (neither timer nor service)"
fi
# Read pacman packages from file # Read pacman packages from file
declare -a pacman_packages declare -a pacman_packages
while IFS= read -r line; do while IFS= read -r line; do
@ -103,6 +167,11 @@ while IFS= read -r line; do
done < "pacman_packages.txt" done < "pacman_packages.txt"
for pkg in "${pacman_packages[@]}"; do for pkg in "${pacman_packages[@]}"; do
# Skip NVIDIA packages if GPU is not NVIDIA
if [ "$GPU_VENDOR" != "nvidia" ] && { [ "$pkg" = "nvidia" ] || [ "$pkg" = "nvidia-utils" ] || [ "$pkg" = "lib32-nvidia-utils" ]; }; then
echo "Skipping $pkg (GPU vendor: $GPU_VENDOR)"
continue
fi
# Check for texlive subpackages # Check for texlive subpackages
if [ "$pkg" == "texlive" ]; then if [ "$pkg" == "texlive" ]; then
sub_pkgs=( sub_pkgs=(

View File

@ -1,3 +1,4 @@
arch-wiki-docs
# duh - using default linux for most compatibility # duh - using default linux for most compatibility
linux linux
# needed for compiling basically anything # needed for compiling basically anything
@ -140,7 +141,6 @@ gst-plugins-base
libgphoto2 libgphoto2
lapacke lapacke
opencv opencv
cuda
vulkan-validation-layers vulkan-validation-layers
libltc libltc
libavtp libavtp
@ -196,9 +196,6 @@ lib32-libvpx
libsoup libsoup
lib32-libsoup lib32-libsoup
lib32-speex lib32-speex
nvidia
nvidia-utils
lib32-nvidia-utils
steam steam
steam-native-runtime steam-native-runtime
fontforge fontforge
@ -223,9 +220,9 @@ pyside6
python-pyaml python-pyaml
python-zstandard python-zstandard
zip zip
virtualbox #virtualbox
virtualbox-guest-iso #virtualbox-guest-iso
virtualbox-ext-vnc #virtualbox-ext-vnc
imath imath
embree embree
jdk-openjdk jdk-openjdk