improved removal handling

This commit is contained in:
[yuri]
2025-12-10 20:45:48 +01:00
parent 4638e821c2
commit 6a68d5c382

View File

@@ -39,7 +39,26 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
##########################
install_packages() { sudo pacman -Sy; sudo pacman -S --noconfirm --needed "$@"; }
is_package_installed() { pacman -Qi "$@" &>/dev/null; }
remove_packages() { sudo pacman -Rs --noconfirm "$@"; }
remove_packages() {
local packages_to_remove=()
# 1. Identify which packages are actually installed
for pkg in "$@"; do
if is_package_installed "$pkg"; then
packages_to_remove+=("$pkg")
else
say_gray "Package '$pkg' not found. Skipping removal."
fi
done
# 2. Only run pacman if there are packages to remove
if [ ${#packages_to_remove[@]} -gt 0 ]; then
say_cyan "Removing packages: ${packages_to_remove[*]}"
sudo pacman -Rs --noconfirm "${packages_to_remove[@]}" || true
else
say_gray "No packages to remove from the list."
fi
}
say_yellow "Starting minimal setup..."