Skip to content

The agent that grows with you

termux: stamp the deb as a self-contained runtime, not a bundled payload

ethernet6a6771e5e795
diff --git a/hermes_cli/source_check.py b/hermes_cli/source_check.py
index 238d1b999a1..ab7036c0468 100644
--- a/hermes_cli/source_check.py
+++ b/hermes_cli/source_check.py
@@ -162,7 +162,7 @@ def check_for_updates(*, install_root: Path | None = None, home: Path | None = N
result = {"supported": False, "hermesRoot": str(root), "behind": None, "commits": []}
if stamp.get("source") == "commit-build":
return {**result, "reason": "commit-build", "message": COMMIT_BUILD_UPDATE_MESSAGE}
- if stamp.get("payload") in {"bundled", "light"} or (install_root is None and detect_install_method(root) in {"docker", "apt"}):
+ if stamp.get("payload") in {"bundled", "light", "runtime"} or (install_root is None and detect_install_method(root) in {"docker", "apt"}):
return {**result, "reason": "not-a-git-checkout"}
if not embedded and not (root / ".git").exists():
return {**result, "reason": "not-a-git-checkout",
diff --git a/hermes_cli/update_channel.py b/hermes_cli/update_channel.py
index d70074e9146..7eebbf99114 100644
--- a/hermes_cli/update_channel.py
+++ b/hermes_cli/update_channel.py
@@ -111,7 +111,7 @@ def channel_record(config: Optional[dict], project_root: Optional[Path] = None)
def _package_channel(stamp: dict) -> bool:
- return stamp.get("payload") in ("bundled", "light") or stamp.get("updateMechanism") in (
+ return stamp.get("payload") in ("bundled", "light", "runtime") or stamp.get("updateMechanism") in (
"electron-updater", "app-installer", "microsoft-store"
)
diff --git a/scripts/termux/build_deb.sh b/scripts/termux/build_deb.sh
index 62c0bd62f8a..aa4d8a5f7be 100644
--- a/scripts/termux/build_deb.sh
+++ b/scripts/termux/build_deb.sh
@@ -186,9 +186,11 @@ printf 'apt\n' > "$PAYLOAD_ABS/app/.install_method"
# The shared stamp writer records the apt-termux update owner.
# Commit mode exports HERMES_BUILD_COMMIT and leaves the tag empty.
+# 'runtime', not 'bundled': the deb ships a runtime but no Electron app,
+# and 'bundled' readers (data cleanup) go looking for the enclosing app.
log "Writing app/install-stamp.json"
HERMES_PAYLOAD_TAG="$TAG" \
-HERMES_DESKTOP_VARIANT=bundled \
+HERMES_DESKTOP_VARIANT=runtime \
python3 "$REPO_ABS/scripts/write_install_stamp.py" \
--output "$PAYLOAD_ABS/app/install-stamp.json" \
--commit "$COMMIT" \
diff --git a/scripts/write_install_stamp.py b/scripts/write_install_stamp.py
index 549f32f4a58..085c1fb7595 100644
--- a/scripts/write_install_stamp.py
+++ b/scripts/write_install_stamp.py
@@ -249,12 +249,17 @@ def build_stamp(
# different MSIX packaging identity. Stamps as 'bundled'
# so the bundled shape logic (shared userData, steward-
# owned updates, no in-app updater) holds for it too.
+ # runtime — a self-contained CLI runtime with NO Electron app around
+ # it (the Termux .deb). It is sealed like 'bundled' but
+ # must not stamp as one: 'bundled' readers locate an
+ # enclosing desktop app (bundled_app.resolve_bundle_layout)
+ # and a tree without one is damage to them.
# Release artifacts pin a tag. Commit builds never enter an update channel.
variant = os.environ.get("HERMES_DESKTOP_VARIANT", "").strip()
- if variant not in ("", "bootstrap", "bundled", "light", "store"):
+ if variant not in ("", "bootstrap", "bundled", "light", "store", "runtime"):
raise SystemExit(
f"write_install_stamp: unknown HERMES_DESKTOP_VARIANT {variant!r} "
- "(expected unset, 'bootstrap', 'bundled', 'light', or 'store')"
+ "(expected unset, 'bootstrap', 'bundled', 'light', 'store', or 'runtime')"
)
payload = "bundled" if variant == "store" else (variant or "bootstrap")
tag = os.environ.get("HERMES_PAYLOAD_TAG") or None
diff --git a/tests/hermes_cli/test_data_uninstall.py b/tests/hermes_cli/test_data_uninstall.py
index ec1425abe16..3b53ecb6934 100644
--- a/tests/hermes_cli/test_data_uninstall.py
+++ b/tests/hermes_cli/test_data_uninstall.py
@@ -137,3 +137,22 @@ def test_data_only_preserves_the_containing_bundled_application(layout, monkeypa
assert shell.read_bytes() == b"retained app bytes"
assert manifest.is_file()
assert all(not path.exists() for path in data)
+
+
+def test_data_only_works_from_a_self_contained_runtime_without_an_app(layout, monkeypatch):
+ """A Termux-shaped runtime (sealed, APT-owned, no Electron app around it)
+ must plan a data-only removal instead of hunting for a desktop app."""
+ import json
+
+ home, _, data = layout
+ package = home.parent / "usr" / "lib" / "hermes-agent"
+ project = package / "app"
+ (project / "hermes_cli").mkdir(parents=True)
+ (project / "hermes_cli" / "__init__.py").write_text("", encoding="utf-8")
+ (project / "install-stamp.json").write_text(json.dumps(
+ {"payload": "runtime", "distribution": "apt-termux", "updateMechanism": "external"}), encoding="utf-8")
+ (package / "venv").mkdir()
+ monkeypatch.setattr(uninstall, "get_project_root", lambda: project)
+ uninstall.run_data_uninstall(SimpleNamespace(yes=True))
+ assert all(not path.exists() for path in data)
+ assert (project / "install-stamp.json").is_file() and (package / "venv").is_dir()
diff --git a/tests/scripts/test_termux_update_refusal.py b/tests/scripts/test_termux_update_refusal.py
index 77a5e9ac1bb..7047fbc36fd 100644
--- a/tests/scripts/test_termux_update_refusal.py
+++ b/tests/scripts/test_termux_update_refusal.py
@@ -36,7 +36,7 @@ def artifact(tmp_path, request):
(root / "install-stamp.json").write_text(json.dumps({
"source": request.param,
"distribution": "apt-termux",
- "payload": "bundled",
+ "payload": "runtime",
"updateMechanism": "external",
"commit": "a" * 40,
"tag": None if request.param == "commit-build" else "v1.2.3",
diff --git a/tests/scripts/test_write_install_stamp.py b/tests/scripts/test_write_install_stamp.py
index 720b2a03ce3..9230f8dfc23 100644
--- a/tests/scripts/test_write_install_stamp.py
+++ b/tests/scripts/test_write_install_stamp.py
@@ -16,6 +16,7 @@ import pytest
("bundled", "desktop-app", "microsoft-store", "bundled", "v0.18.0"),
("bundled", "desktop-app", "external", "bundled", "v0.18.0"),
("light", "desktop-app", "electron-updater", "light", "v0.18.0"),
+ ("runtime", "apt-termux", "external", "runtime", "v0.18.0"),
])
def test_cli_stamp_roundtrip(tmp_path, monkeypatch, variant, distribution, mechanism, payload, tag):
out = tmp_path / "install-stamp.json"