From 4c56e1bb96b0b0bd90fe11169c684fc6754ec0e2 Mon Sep 17 00:00:00 2001 From: ssmithx Date: Mon, 29 Jun 2026 01:41:36 +0000 Subject: [PATCH] fix(openwrt): detect opkg silent failure and show disk space error BusyBox opkg exits 0 even when 'Cannot install' due to insufficient space, causing the fallback to silently report success. Now captures stderr and checks for the failure string explicitly. Adds user-visible error for the common case where the router flash is too small for the TollGate package (~19 MB needed vs ~9 MB available on typical budget routers). Adds error prefixes to the RPC sanitizer allowlist so the message reaches the UI instead of showing 'Check server logs'. Co-Authored-By: Claude Sonnet 4.6 --- core/archipelago/src/api/rpc/middleware.rs | 3 +++ core/openwrt/src/tollgate/install.rs | 21 ++++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/core/archipelago/src/api/rpc/middleware.rs b/core/archipelago/src/api/rpc/middleware.rs index 7489f51b..ac029f36 100644 --- a/core/archipelago/src/api/rpc/middleware.rs +++ b/core/archipelago/src/api/rpc/middleware.rs @@ -66,6 +66,9 @@ pub(super) fn sanitize_error_message(msg: &str) -> String { "Bitcoin address", "No router", "No OpenWrt", + "No space left", + "TollGate installation failed", + "No pre-built TollGate", ]; for prefix in &user_facing_prefixes { if msg.starts_with(prefix) { diff --git a/core/openwrt/src/tollgate/install.rs b/core/openwrt/src/tollgate/install.rs index 4b1beb81..64b9a5e6 100644 --- a/core/openwrt/src/tollgate/install.rs +++ b/core/openwrt/src/tollgate/install.rs @@ -48,8 +48,27 @@ pub fn install_tollgate(router: &Router) -> Result<()> { info!("[{}] Downloading TollGate for {} from GitHub releases", router.host, arch); router.run_ok(&format!("wget -O /tmp/tollgate.ipk '{}'", url))?; - router.run_ok("opkg install --force-depends /tmp/tollgate.ipk")?; + + // Capture stderr too — BusyBox opkg exits 0 even on "Cannot install" failures. + let (out, _code) = router.run("opkg install --force-depends /tmp/tollgate.ipk 2>&1")?; router.run_ok("rm -f /tmp/tollgate.ipk")?; + if out.contains("Cannot install") || out.contains("errors encountered") { + if out.contains("Only have") && out.contains("available on filesystem") { + // Extract the sizes from the error for a user-readable message. + // Example: "Only have 8884kb available on filesystem /overlay, pkg tollgate-wrt needs 18750" + anyhow::bail!( + "No space left on router for TollGate ({}). \ + This router has insufficient flash storage. \ + Consider a router with ≥32 MB flash or add an extroot USB drive.", + out.lines() + .find(|l| l.contains("Only have")) + .unwrap_or("check router disk space") + .trim() + ); + } + anyhow::bail!("TollGate installation failed: {}", out.trim()); + } + Ok(()) }