From d6e94f5050fde362ce61cc5e82402060fe105c77 Mon Sep 17 00:00:00 2001 From: Pepe44DEV Date: Thu, 28 May 2026 23:43:35 +0200 Subject: [PATCH] fix: fallback to direct AUR install when paru fails, verify paru after build --- lib/utils.sh | 129 +++++++++++++++++++++++++++----------------- modules/core/ags.sh | 48 +++-------------- 2 files changed, 88 insertions(+), 89 deletions(-) diff --git a/lib/utils.sh b/lib/utils.sh index c2dbdf8..0981920 100755 --- a/lib/utils.sh +++ b/lib/utils.sh @@ -127,38 +127,6 @@ install_pacman() { fi } -install_aur() { - local packages=("$@") - local aur_helper="" - - if have paru; then - aur_helper="paru" - elif have yay; then - aur_helper="yay" - else - log_error "No AUR helper found (install paru or yay)" - return 1 - fi - - local pkg - local rc=0 - - for pkg in "${packages[@]}"; do - if is_package_installed "$pkg"; then - continue - fi - tui_info "Installing $pkg from AUR..." - if "$aur_helper" -S --needed --noconfirm "$pkg"; then - tui_success "$pkg installed" - else - tui_warn "$pkg could not be installed" - rc=1 - fi - done - - return $rc -} - replace_home_paths() { local dir="$1" local original_home="${2:-/home/pascal}" @@ -270,6 +238,28 @@ system_summary() { SUMMARY } +install_aur_package() { + local pkgname="$1" + local build_dir + build_dir="$(mktemp -d)" + + tui_info "Cloning $pkgname from AUR directly..." + if ! git clone "https://aur.archlinux.org/$pkgname.git" "$build_dir/$pkgname" 2>/dev/null; then + rm -rf "$build_dir" + return 1 + fi + + tui_info "Building $pkgname..." + if (cd "$build_dir/$pkgname" && makepkg -si --needed --noconfirm); then + rm -rf "$build_dir" + return 0 + fi + + local rc=$? + rm -rf "$build_dir" + return $rc +} + install_aur_helper() { if have paru || have yay; then return 0 @@ -300,24 +290,67 @@ install_aur_helper() { if (cd "$build_dir/paru-bin" && makepkg -si --needed --noconfirm); then tui_success "paru installed successfully" rm -rf "$build_dir" - return 0 - fi + else + local rc=$? + tui_warn "makepkg failed (exit $rc). Trying yay-bin..." + rm -rf "$build_dir/paru-bin" - local rc=$? - tui_warn "makepkg failed (exit $rc). Trying yay-bin..." - rm -rf "$build_dir/paru-bin" - - if git clone https://aur.archlinux.org/yay-bin.git "$build_dir/yay-bin"; then - if (cd "$build_dir/yay-bin" && makepkg -si --needed --noconfirm); then - tui_success "yay installed successfully" - rm -rf "$build_dir" - return 0 + if git clone https://aur.archlinux.org/yay-bin.git "$build_dir/yay-bin"; then + if (cd "$build_dir/yay-bin" && makepkg -si --needed --noconfirm); then + tui_success "yay installed successfully" + rm -rf "$build_dir" + else + tui_warn "Could not install AUR helper. Install manually:" + tui_info " cd /tmp && git clone https://aur.archlinux.org/paru-bin.git" + tui_info " cd paru-bin && makepkg -si" + rm -rf "$build_dir" + return 1 + fi fi fi - tui_warn "Could not install AUR helper. Install manually:" - tui_info " cd /tmp && git clone https://aur.archlinux.org/paru-bin.git" - tui_info " cd paru-bin && makepkg -si" - rm -rf "$build_dir" - return 1 + if have paru; then + tui_info "Verifying paru..." + if paru --version >/dev/null 2>&1; then + tui_success "paru works" + return 0 + else + tui_warn "paru binary installed but fails to run. Falling back to direct AUR installs." + tui_info "Will install AUR packages via git clone + makepkg instead." + fi + fi + + return 0 +} + +install_aur() { + local packages=("$@") + local pkg + local rc=0 + + for pkg in "${packages[@]}"; do + if is_package_installed "$pkg"; then + continue + fi + + if have paru && paru --version >/dev/null 2>&1; then + tui_info "Installing $pkg from AUR (via paru)..." + if paru -S --needed --noconfirm "$pkg"; then + tui_success "$pkg installed" + continue + fi + tui_warn "paru failed for $pkg. Trying direct AUR install..." + fi + + if install_aur_package "$pkg"; then + tui_success "$pkg installed" + else + tui_warn "$pkg could not be installed. Try manually:" + tui_info " cd /tmp && git clone https://aur.archlinux.org/$pkg.git" + tui_info " cd $pkg && makepkg -si" + rc=1 + fi + done + + return $rc } diff --git a/modules/core/ags.sh b/modules/core/ags.sh index f7a1f1b..b3f8a2b 100644 --- a/modules/core/ags.sh +++ b/modules/core/ags.sh @@ -1,7 +1,5 @@ #!/usr/bin/env bash -AGS_LOG_DIR="/tmp/omeron-ags-logs" - module_description() { printf "AGS (Aylur's Gtk Shell) - Widget system for Hyprland\n" } @@ -11,30 +9,6 @@ module_should_skip() { command -v ags >/dev/null 2>&1 } -_ags_build_deps() { - local deps=("libastal-io-git" "libastal-git" "libastal-4-git") - local all_ok=0 - - mkdir -p "$AGS_LOG_DIR" - - for dep in "${deps[@]}"; do - if is_package_installed "$dep"; then - tui_success "$dep already installed" - continue - fi - tui_info "Building $dep from AUR (dependency for AGS)..." - local log="$AGS_LOG_DIR/$dep.log" - if paru -S --needed --noconfirm "$dep" > "$log" 2>&1; then - tui_success "$dep built and installed" - else - tui_warn "$dep build failed — see $log" - all_ok=1 - fi - done - - return $all_ok -} - module_main() { log_section "AGS Installation" @@ -43,8 +17,8 @@ module_main() { return 0 fi - if ! have paru; then - tui_warn "paru not available. Install ags manually: paru -S aylurs-gtk-shell-git" + if ! have git; then + tui_warn "git not available. Install ags manually after installing git." return 0 fi @@ -54,27 +28,19 @@ module_main() { printf '\n' if ! tui_confirm "Install AGS now?"; then - tui_info "AGS installation skipped. Run later: paru -S aylurs-gtk-shell-git" + tui_info "AGS installation skipped." return 0 fi - if ! _ags_build_deps; then + local deps=("libastal-io-git" "libastal-git" "libastal-4-git") + if ! install_aur "${deps[@]}"; then tui_warn "Some AGS dependencies failed to build." - tui_info "Check logs in $AGS_LOG_DIR/ for details." if ! tui_confirm "Try to install AGS anyway?"; then - tui_info "AGS installation aborted. Fix deps manually, then run: paru -S aylurs-gtk-shell-git" + tui_info "AGS installation aborted." return 0 fi fi tui_info "Building aylurs-gtk-shell-git from AUR..." - mkdir -p "$AGS_LOG_DIR" - local log="$AGS_LOG_DIR/aylurs-gtk-shell-git.log" - if paru -S --needed --noconfirm aylurs-gtk-shell-git > "$log" 2>&1; then - tui_success "AGS installed" - else - tui_warn "AGS build failed — see $log" - tui_info "Check the last 30 lines: tail -30 $log" - tui_info "Try manually: paru -S aylurs-gtk-shell-git" - fi + install_aur "aylurs-gtk-shell-git" }