fix: fallback to direct AUR install when paru fails, verify paru after build
This commit is contained in:
129
lib/utils.sh
129
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user