feat: Refactor AUR package installation and improve logging in setup scripts

This commit is contained in:
Marco Gallegos
2025-11-15 16:03:12 -06:00
parent 26eb8f5774
commit bb0f7357c6
7 changed files with 295 additions and 90 deletions

View File

@@ -67,10 +67,16 @@ check_and_install_pkg() {
# pacman -Q es más fiable para paquetes individuales.
if ! pacman -Q "$pkg_name" &>/dev/null; then
log_info "Instalando ${pkg_name}..."
sudo pacman -S --noconfirm --needed "$pkg_name" || log_warning "No se pudo instalar ${pkg_name}."
if sudo pacman -S --noconfirm --needed "$pkg_name"; then
return 0
else
log_warning "No se pudo instalar ${pkg_name}."
return 1
fi
else
log_info "${pkg_name} ya está instalado."
fi
return 0
}
@@ -93,6 +99,42 @@ ensure_aur_helper() {
fi
}
aur_install_packages() {
local packages=("$@")
if [[ ${#packages[@]} -eq 0 ]]; then
return 0
fi
local helper="${AUR_HELPER_CMD:-}"
if [[ -z "$helper" ]]; then
helper="$(ensure_aur_helper)" || helper=""
fi
if [[ -z "$helper" ]]; then
log_error "No se pudo determinar un helper de AUR disponible."
return 1
fi
local -a base_flags=(--noconfirm --needed --noeditmenu --nodiffmenu --nocleanmenu)
AUR_HELPER_CMD="$helper"
local status=0
case "$helper" in
yay)
"$helper" -S "${base_flags[@]}" --answerdiff None --answerclean All --answeredit None --mflags "--noconfirm" --cleanafter "${packages[@]}"
status=$?
;;
paru)
"$helper" -S "${base_flags[@]}" --skipreview --cleanafter --mflags "--noconfirm" "${packages[@]}"
status=$?
;;
*)
log_error "Helper AUR desconocido: ${helper}"
return 1
;;
esac
return $status
}
# Función para actualizar sistema
update_system() {
log_step "Actualizando sistema"