tools: register the updater in the normal command path
agent-review agent review: pass

Install the container updater under /usr/local/bin so shells without sbin can discover it. Print the absolute installed path as a fallback for custom environments and retain existing managed links. Reproduce command discovery through a real Bash lookup before fixing registration.

Refs #23
This commit is contained in:
Florian Schmidt
2026-11-15 15:05:16 +01:00
parent 43caf1e412
commit afa6d83f2a
8 changed files with 52 additions and 7 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ APP = Path("/opt/finaltoken")
BUILD = Path("/var/cache/finaltoken-build")
SERVER_HOME = Path("/var/lib/finaltoken-server")
WORKER_HOME = Path("/var/lib/finaltoken-worker")
UPDATER = Path("/usr/local/sbin/finaltoken-update")
UPDATER = Path("/usr/local/bin/finaltoken-update")
SYSTEMD = Path("/etc/systemd/system")
+31
View File
@@ -299,6 +299,37 @@ class GuestTests(unittest.TestCase):
guest.install_updater()
self.assertEqual(b"operator file", path.read_bytes())
def test_updater_is_discoverable_without_sbin_in_shell_path(self):
git = shutil.which("git")
windows_bash = Path(git).resolve().parents[1] / "bin/bash.exe" if git else Path("missing")
bash = str(windows_bash) if os.name == "nt" and windows_bash.is_file() else shutil.which("bash")
self.assertIsNotNone(bash, "Bash is required for container command lookup verification")
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
app = root / "app"
target = app / "current/finaltoken-update"
target.parent.mkdir(parents=True)
target.write_bytes(b"#!/bin/sh\nprintf 'synthetic updater executed\\n'\n")
target.chmod(0o755)
registered = root / guest.UPDATER.as_posix().lstrip("/")
searched = root / "usr/local/bin"
searched.mkdir(parents=True)
with contextlib.ExitStack() as stack:
stack.enter_context(patch.object(guest, "APP", app))
stack.enter_context(patch.object(guest, "UPDATER", registered))
if os.name == "nt":
# Windows may deny symlink creation; only substitute that OS operation.
# The real Bash lookup/execution still uses the actual installed path.
stack.enter_context(patch.object(Path, "symlink_to", lambda path, destination: shutil.copy2(destination, path)))
guest.install_updater()
env = dict(os.environ, PATH=str(searched))
env.pop("BASH_ENV", None)
result = subprocess.run([bash, "--noprofile", "--norc", "-c",
"command -v finaltoken-update && finaltoken-update"], env=env,
text=True, capture_output=True, timeout=10)
self.assertEqual(0, result.returncode, result.stderr)
self.assertIn("synthetic updater executed", result.stdout)
def test_codex_npm_install_creates_the_configured_launcher(self):
node, npm = shutil.which("node"), shutil.which("npm")
if not node or not npm:
+1 -1
View File
@@ -63,7 +63,7 @@ class ContainerUpdateTests(unittest.TestCase):
text=True, capture_output=True, check=True)
def publish(self, version, failure=False):
code = "import hashlib, json, tarfile\nfrom pathlib import Path\n"
code = "import hashlib, json, tarfile\nfrom pathlib import Path\nUPDATER = Path('/usr/local/bin/finaltoken-update')\n"
code += "def provision(manifest, archive):\n"
code += " assert hashlib.sha256(archive.read_bytes()).hexdigest() == manifest['sourceSha256']\n"
if failure: