Compare commits

...

2 Commits

2 changed files with 59 additions and 46 deletions

View File

@@ -229,6 +229,9 @@ main() {
log_info "Log file: $OMERON_LOG_FILE" log_info "Log file: $OMERON_LOG_FILE"
log_info "Project: $OMERON_ROOT" log_info "Project: $OMERON_ROOT"
sudo_init
trap 'sudo_cleanup' EXIT
detect_environment detect_environment
show_banner show_banner

View File

@@ -32,9 +32,39 @@ is_root() {
[[ "$EUID" -eq 0 ]] [[ "$EUID" -eq 0 ]]
} }
OMERON_SUDO_PID=""
OMERON_SUDO_PID=""
sudo_init() {
if is_root; then
return 0
fi
tui_info "Sudo access needed — enter your password once"
sudo -v || {
tui_error "Sudo authentication failed"
return 1
}
(
while true; do
sleep 240
sudo -v 2>/dev/null || break
done
) &
OMERON_SUDO_PID=$!
}
sudo_cleanup() {
[[ -n "$OMERON_SUDO_PID" ]] && kill "$OMERON_SUDO_PID" 2>/dev/null || true
}
sudo_run() { sudo_run() {
if is_root; then if is_root; then
"$@" "$@"
return
fi
if [[ -n "${OMERON_SUDO_PID:-}" ]] && kill -0 "$OMERON_SUDO_PID" 2>/dev/null; then
sudo -n "$@"
else else
sudo "$@" sudo "$@"
fi fi
@@ -260,21 +290,6 @@ install_aur_package() {
return $rc return $rc
} }
_install_paru_bin() {
local build_dir="$1"
git clone https://aur.archlinux.org/paru-bin.git "$build_dir/paru-bin" 2>/dev/null || return 1
(cd "$build_dir/paru-bin" && makepkg -si --needed --noconfirm) 2>/dev/null || return 1
return 0
}
_install_paru_source() {
local build_dir="$1"
sudo_run pacman -S --needed --noconfirm go
git clone https://aur.archlinux.org/paru.git "$build_dir/paru" 2>/dev/null || return 1
(cd "$build_dir/paru" && makepkg -si --needed --noconfirm) 2>/dev/null || return 1
return 0
}
install_aur_helper() { install_aur_helper() {
if have paru || have yay; then if have paru || have yay; then
return 0 return 0
@@ -282,9 +297,7 @@ install_aur_helper() {
if is_root; then if is_root; then
tui_warn "Running as root — makepkg refuses to run as root." tui_warn "Running as root — makepkg refuses to run as root."
tui_info "Switch to a normal user with sudo access and re-run, or install paru manually:" tui_info "Switch to a normal user with sudo access and re-run."
tui_info " pacman -S --needed git && git clone https://aur.archlinux.org/paru-bin.git"
tui_info " cd paru-bin && makepkg -si"
return 1 return 1
fi fi
@@ -294,39 +307,29 @@ install_aur_helper() {
local build_dir local build_dir
build_dir="$(mktemp -d)" build_dir="$(mktemp -d)"
tui_info "Installing paru-bin (binary AUR helper)..." tui_info "Installing yay-bin (statically linked, works on any libalpm)..."
if _install_paru_bin "$build_dir" && paru --version >/dev/null 2>&1; then if git clone https://aur.archlinux.org/yay-bin.git "$build_dir/yay-bin" &&
(cd "$build_dir/yay-bin" && makepkg -si --needed --noconfirm); then
tui_success "yay installed"
rm -rf "$build_dir"
return 0
fi
rm -rf "$build_dir"
mkdir -p "$build_dir"
tui_info "yay-bin failed. Trying paru-bin..."
if git clone https://aur.archlinux.org/paru-bin.git "$build_dir/paru-bin" &&
(cd "$build_dir/paru-bin" && makepkg -si --needed --noconfirm) &&
paru --version >/dev/null 2>&1; then
tui_success "paru works" tui_success "paru works"
rm -rf "$build_dir" rm -rf "$build_dir"
return 0 return 0
fi fi
tui_warn "paru-bin failed or has library mismatch. Building paru from source..."
rm -rf "$build_dir"/*
mkdir -p "$build_dir"
if _install_paru_source "$build_dir"; then
tui_success "paru built and installed from source"
rm -rf "$build_dir"
return 0
fi
tui_warn "paru source build failed. Trying yay as fallback..."
rm -rf "$build_dir"/*
if git clone https://aur.archlinux.org/yay-bin.git "$build_dir/yay-bin" 2>/dev/null; then
if (cd "$build_dir/yay-bin" && makepkg -si --needed --noconfirm) 2>/dev/null; then
tui_success "yay installed successfully"
rm -rf "$build_dir"
return 0
fi
fi
tui_warn "Could not install any AUR helper. Install manually:"
tui_info " sudo pacman -S go && git clone https://aur.archlinux.org/paru.git"
tui_info " cd paru && makepkg -si"
rm -rf "$build_dir" rm -rf "$build_dir"
return 1 tui_warn "No working AUR helper. Using direct git clone + makepkg for AUR packages."
return 0
} }
install_aur() { install_aur() {
@@ -339,7 +342,14 @@ install_aur() {
continue continue
fi fi
if have paru && paru --version >/dev/null 2>&1; then if have yay; then
tui_info "Installing $pkg from AUR (via yay)..."
if yay -S --needed --noconfirm "$pkg"; then
tui_success "$pkg installed"
continue
fi
tui_warn "yay failed for $pkg. Trying direct AUR install..."
elif have paru && paru --version >/dev/null 2>&1; then
tui_info "Installing $pkg from AUR (via paru)..." tui_info "Installing $pkg from AUR (via paru)..."
if paru -S --needed --noconfirm "$pkg"; then if paru -S --needed --noconfirm "$pkg"; then
tui_success "$pkg installed" tui_success "$pkg installed"