From 4b282fa0e3c7b6caa104962ba48051edcd33f922 Mon Sep 17 00:00:00 2001 From: Brajesh <138358890+Brajesh2022@users.noreply.github.com> Date: Thu, 28 May 2026 12:00:08 +0530 Subject: [PATCH 1/5] feat: add dependency auto-repair system on execution failure --- install.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 9eb1eb159..a6b9b161f 100755 --- a/install.sh +++ b/install.sh @@ -362,8 +362,20 @@ if VERSION=$("$INSTALL_BIN_DIR/agy" --version 2>/dev/null); then [[ -n "$AGY_BAK" && -f "$AGY_BAK" ]] && rm -f "$AGY_BAK" [[ -n "$AGY_VA39_BAK" && -f "$AGY_VA39_BAK" ]] && rm -f "$AGY_VA39_BAK" else - rm -f "$INSTALL_BIN_DIR/agy" "$INSTALL_BIN_DIR/agy.va39" - die "Binaries failed to execute locally. Check dependencies." + info "Binary failed. Attempting dependency repair..." + pkg reinstall -y proot glibc ca-certificates >/dev/null 2>&1 || true + rm -f ~/.local/bin/agy ~/.local/bin/agy.va39 + rm -rf ~/.local/agy + hash -r + + if VERSION=$("$INSTALL_BIN_DIR/agy" --version 2>/dev/null); then + ok "Engine online ($VERSION verified)" + [[ -n "$AGY_BAK" && -f "$AGY_BAK" ]] && rm -f "$AGY_BAK" + [[ -n "$AGY_VA39_BAK" && -f "$AGY_VA39_BAK" ]] && rm -f "$AGY_VA39_BAK" + else + rm -f "$INSTALL_BIN_DIR/agy" "$INSTALL_BIN_DIR/agy.va39" + die "Binaries failed to execute locally. Check dependencies." + fi fi # ── Done ────────────────────────────────────────────────────────────────────── From b39f73f6a0d9b5fec9b1344262a416a0f15d09e5 Mon Sep 17 00:00:00 2001 From: Brajesh <138358890+Brajesh2022@users.noreply.github.com> Date: Thu, 28 May 2026 12:16:19 +0530 Subject: [PATCH 2/5] feat: add pkg upgrade fallback to auto-repair --- install.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index a6b9b161f..32590ce62 100755 --- a/install.sh +++ b/install.sh @@ -373,8 +373,18 @@ else [[ -n "$AGY_BAK" && -f "$AGY_BAK" ]] && rm -f "$AGY_BAK" [[ -n "$AGY_VA39_BAK" && -f "$AGY_VA39_BAK" ]] && rm -f "$AGY_VA39_BAK" else - rm -f "$INSTALL_BIN_DIR/agy" "$INSTALL_BIN_DIR/agy.va39" - die "Binaries failed to execute locally. Check dependencies." + info "Repair failed. Attempting full package update..." + pkg upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" >/dev/null 2>&1 || true + pkg reinstall -y proot glibc ca-certificates >/dev/null 2>&1 || true + + if VERSION=$("$INSTALL_BIN_DIR/agy" --version 2>/dev/null); then + ok "Engine online ($VERSION verified)" + [[ -n "$AGY_BAK" && -f "$AGY_BAK" ]] && rm -f "$AGY_BAK" + [[ -n "$AGY_VA39_BAK" && -f "$AGY_VA39_BAK" ]] && rm -f "$AGY_VA39_BAK" + else + rm -f "$INSTALL_BIN_DIR/agy" "$INSTALL_BIN_DIR/agy.va39" + die "Binaries failed to execute locally. Check dependencies." + fi fi fi From 0db0c7eea2a7ad6af337a83edce43948291fedb7 Mon Sep 17 00:00:00 2001 From: Brajesh <138358890+Brajesh2022@users.noreply.github.com> Date: Tue, 2 Jun 2026 23:54:24 +0530 Subject: [PATCH 3/5] fix: skip pkg repair logic in PRoot environments --- install.sh | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/install.sh b/install.sh index 32590ce62..fcd5edf52 100755 --- a/install.sh +++ b/install.sh @@ -362,29 +362,34 @@ if VERSION=$("$INSTALL_BIN_DIR/agy" --version 2>/dev/null); then [[ -n "$AGY_BAK" && -f "$AGY_BAK" ]] && rm -f "$AGY_BAK" [[ -n "$AGY_VA39_BAK" && -f "$AGY_VA39_BAK" ]] && rm -f "$AGY_VA39_BAK" else - info "Binary failed. Attempting dependency repair..." - pkg reinstall -y proot glibc ca-certificates >/dev/null 2>&1 || true - rm -f ~/.local/bin/agy ~/.local/bin/agy.va39 - rm -rf ~/.local/agy - hash -r - - if VERSION=$("$INSTALL_BIN_DIR/agy" --version 2>/dev/null); then - ok "Engine online ($VERSION verified)" - [[ -n "$AGY_BAK" && -f "$AGY_BAK" ]] && rm -f "$AGY_BAK" - [[ -n "$AGY_VA39_BAK" && -f "$AGY_VA39_BAK" ]] && rm -f "$AGY_VA39_BAK" - else - info "Repair failed. Attempting full package update..." - pkg upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" >/dev/null 2>&1 || true + if [[ "$ENV_TYPE" == "termux" ]]; then + info "Binary failed. Attempting dependency repair..." pkg reinstall -y proot glibc ca-certificates >/dev/null 2>&1 || true + rm -f "$HOME/.local/bin/agy" "$HOME/.local/bin/agy.va39" + rm -rf "$HOME/.local/agy" + hash -r if VERSION=$("$INSTALL_BIN_DIR/agy" --version 2>/dev/null); then ok "Engine online ($VERSION verified)" [[ -n "$AGY_BAK" && -f "$AGY_BAK" ]] && rm -f "$AGY_BAK" [[ -n "$AGY_VA39_BAK" && -f "$AGY_VA39_BAK" ]] && rm -f "$AGY_VA39_BAK" else - rm -f "$INSTALL_BIN_DIR/agy" "$INSTALL_BIN_DIR/agy.va39" - die "Binaries failed to execute locally. Check dependencies." + info "Repair failed. Attempting full package update..." + pkg upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" >/dev/null 2>&1 || true + pkg reinstall -y proot glibc ca-certificates >/dev/null 2>&1 || true + + if VERSION=$("$INSTALL_BIN_DIR/agy" --version 2>/dev/null); then + ok "Engine online ($VERSION verified)" + [[ -n "$AGY_BAK" && -f "$AGY_BAK" ]] && rm -f "$AGY_BAK" + [[ -n "$AGY_VA39_BAK" && -f "$AGY_VA39_BAK" ]] && rm -f "$AGY_VA39_BAK" + else + rm -f "$INSTALL_BIN_DIR/agy" "$INSTALL_BIN_DIR/agy.va39" + die "Binaries failed to execute locally. Check dependencies." + fi fi + else + rm -f "$INSTALL_BIN_DIR/agy" "$INSTALL_BIN_DIR/agy.va39" + die "Binaries failed to execute locally. Check dependencies." fi fi From 9d36e7041c62139564899e2d727098c2c693858d Mon Sep 17 00:00:00 2001 From: Brajesh <138358890+Brajesh2022@users.noreply.github.com> Date: Wed, 3 Jun 2026 00:14:47 +0530 Subject: [PATCH 4/5] feat: extract finish_ok helper and add repair progress spinner --- install.sh | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/install.sh b/install.sh index fcd5edf52..f89d2ed36 100755 --- a/install.sh +++ b/install.sh @@ -146,6 +146,34 @@ progress_spinner() { return $exit_status } +finish_ok() { + local version="$1" + ok "Engine online ($version verified)" + [[ -n "$AGY_BAK" && -f "$AGY_BAK" ]] && rm -f "$AGY_BAK" + [[ -n "$AGY_VA39_BAK" && -f "$AGY_VA39_BAK" ]] && rm -f "$AGY_VA39_BAK" +} + +run_pkg_with_spinner() { + local msg="$1" + shift + local pct_file="${TMP}.pct" + echo "0" > "$pct_file" + { + "$@" -o APT::Status-Fd=1 2>&1 | awk ' + /^dlstatus:[0-9]+:([0-9.]+):/ || /^pmstatus:[^:]+:([0-9.]+):/ { + split($0, a, ":") + pct = int(a[3]) + if (pct < 0) pct = 0 + if (pct > 100) pct = 100 + print pct > "'"${pct_file}"'" + close("'"${pct_file}"'") + fflush() + }' + } & + progress_spinner $! "$msg" "$pct_file" || true + rm -f "$pct_file" +} + download_with_progress() { local url=$1 local dest=$2 @@ -358,30 +386,24 @@ ok "Binary found" # ── Test & Extract Version ──────────────────────────────────────────────────── VERSION="" if VERSION=$("$INSTALL_BIN_DIR/agy" --version 2>/dev/null); then - ok "Engine online ($VERSION verified)" - [[ -n "$AGY_BAK" && -f "$AGY_BAK" ]] && rm -f "$AGY_BAK" - [[ -n "$AGY_VA39_BAK" && -f "$AGY_VA39_BAK" ]] && rm -f "$AGY_VA39_BAK" + finish_ok "$VERSION" else if [[ "$ENV_TYPE" == "termux" ]]; then info "Binary failed. Attempting dependency repair..." - pkg reinstall -y proot glibc ca-certificates >/dev/null 2>&1 || true + run_pkg_with_spinner "Repairing Termux dependencies..." pkg reinstall -y proot glibc ca-certificates rm -f "$HOME/.local/bin/agy" "$HOME/.local/bin/agy.va39" rm -rf "$HOME/.local/agy" hash -r if VERSION=$("$INSTALL_BIN_DIR/agy" --version 2>/dev/null); then - ok "Engine online ($VERSION verified)" - [[ -n "$AGY_BAK" && -f "$AGY_BAK" ]] && rm -f "$AGY_BAK" - [[ -n "$AGY_VA39_BAK" && -f "$AGY_VA39_BAK" ]] && rm -f "$AGY_VA39_BAK" + finish_ok "$VERSION" else info "Repair failed. Attempting full package update..." - pkg upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" >/dev/null 2>&1 || true - pkg reinstall -y proot glibc ca-certificates >/dev/null 2>&1 || true + run_pkg_with_spinner "Upgrading package definitions..." pkg upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" + run_pkg_with_spinner "Deep reinstalling dependencies..." pkg reinstall -y proot glibc ca-certificates if VERSION=$("$INSTALL_BIN_DIR/agy" --version 2>/dev/null); then - ok "Engine online ($VERSION verified)" - [[ -n "$AGY_BAK" && -f "$AGY_BAK" ]] && rm -f "$AGY_BAK" - [[ -n "$AGY_VA39_BAK" && -f "$AGY_VA39_BAK" ]] && rm -f "$AGY_VA39_BAK" + finish_ok "$VERSION" else rm -f "$INSTALL_BIN_DIR/agy" "$INSTALL_BIN_DIR/agy.va39" die "Binaries failed to execute locally. Check dependencies." From 478c59c119c6cb2aa69dbc5dc655393cb51c6fd9 Mon Sep 17 00:00:00 2001 From: Brajesh <138358890+Brajesh2022@users.noreply.github.com> Date: Wed, 3 Jun 2026 00:34:33 +0530 Subject: [PATCH 5/5] fix: apply AI review suggestions for safety and performance --- install.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index f89d2ed36..87193f50f 100755 --- a/install.sh +++ b/install.sh @@ -156,22 +156,23 @@ finish_ok() { run_pkg_with_spinner() { local msg="$1" shift - local pct_file="${TMP}.pct" - echo "0" > "$pct_file" + GLIBC_PCT="${TMP}.pct" + echo "0" > "$GLIBC_PCT" { - "$@" -o APT::Status-Fd=1 2>&1 | awk ' + "$@" -o APT::Status-Fd=1 2>&1 | awk -v pct_file="$GLIBC_PCT" ' /^dlstatus:[0-9]+:([0-9.]+):/ || /^pmstatus:[^:]+:([0-9.]+):/ { split($0, a, ":") pct = int(a[3]) if (pct < 0) pct = 0 if (pct > 100) pct = 100 - print pct > "'"${pct_file}"'" - close("'"${pct_file}"'") + print pct > pct_file + close(pct_file) fflush() }' } & - progress_spinner $! "$msg" "$pct_file" || true - rm -f "$pct_file" + progress_spinner $! "$msg" "$GLIBC_PCT" || true + rm -f "$GLIBC_PCT" + GLIBC_PCT="" } download_with_progress() { @@ -399,7 +400,7 @@ else finish_ok "$VERSION" else info "Repair failed. Attempting full package update..." - run_pkg_with_spinner "Upgrading package definitions..." pkg upgrade -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" + run_pkg_with_spinner "Updating package definitions..." apt update run_pkg_with_spinner "Deep reinstalling dependencies..." pkg reinstall -y proot glibc ca-certificates if VERSION=$("$INSTALL_BIN_DIR/agy" --version 2>/dev/null); then