From d8491e239a84d650e3621d7dd2002c2860f057ec Mon Sep 17 00:00:00 2001 From: firestar5683 <168790843+firestar5683@users.noreply.github.com> Date: Sun, 15 Nov 2026 22:59:08 -0600 Subject: [PATCH] Launch AGNOS updater with compatible UI --- launch_chffrplus.sh | 10 +++- .../updated/tests/test_retained_agnos.py | 47 +++++++++++++++++++ prebuilt.json | 2 +- 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/launch_chffrplus.sh b/launch_chffrplus.sh index 713c325238..c6606c2ebe 100755 --- a/launch_chffrplus.sh +++ b/launch_chffrplus.sh @@ -4,6 +4,14 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" source "$DIR/launch_env.sh" +function run_agnos_updater { + if python3 -c "import openpilot.system.ui.updater"; then + python3 -m openpilot.system.ui.updater "$@" + else + "$DIR/openpilot/common/hardware/comma/updater" "$@" + fi +} + function agnos_init { if [ "${AGNOS_UPDATE_POLICY:-auto}" = "retain" ] && [ "$(< /VERSION)" != "$AGNOS_VERSION" ]; then echo "This StarPilot build retains AGNOS $AGNOS_VERSION; installed OS does not match. No OS update was attempted." @@ -30,7 +38,7 @@ function agnos_init { sudo reboot fi while true; do - "$DIR/openpilot/common/hardware/comma/updater" "$AGNOS_PY" "$MANIFEST" + run_agnos_updater "$AGNOS_PY" "$MANIFEST" done fi diff --git a/openpilot/system/updated/tests/test_retained_agnos.py b/openpilot/system/updated/tests/test_retained_agnos.py index aa4ddcd5be..d20c53431a 100644 --- a/openpilot/system/updated/tests/test_retained_agnos.py +++ b/openpilot/system/updated/tests/test_retained_agnos.py @@ -24,6 +24,53 @@ def shell_function(path, name): return source[start:source.index('\n}\n', start) + 3] +class TestAgnosUiLaunch(unittest.TestCase): + def launch(self, import_status, ui_status=0, legacy_status=0): + with tempfile.TemporaryDirectory() as directory: + root = Path(directory) + log = root / 'calls' + legacy = root / 'openpilot/common/hardware/comma/updater' + legacy.parent.mkdir(parents=True) + legacy.write_text('#!/bin/bash\nprintf "legacy\\0" >> "$CALL_LOG"\n' + + 'printf "%s\\0" "$@" >> "$CALL_LOG"\nexit "$LEGACY_STATUS"\n') + legacy.chmod(0o700) + function = shell_function(ROOT / 'launch_chffrplus.sh', 'run_agnos_updater') + script = function + r''' +python3() { + printf 'python\0' >> "$CALL_LOG" + printf '%s\0' "$@" >> "$CALL_LOG" + if [ "$1" = '-c' ]; then return "$IMPORT_STATUS"; fi + return "$UI_STATUS" +} +run_agnos_updater '/flasher with spaces.py' '/manifest with spaces.json' +''' + environment = dict(os.environ, DIR=str(root), CALL_LOG=str(log), IMPORT_STATUS=str(import_status), + UI_STATUS=str(ui_status), LEGACY_STATUS=str(legacy_status)) + result = subprocess.run(['bash', '-c', script], env=environment, check=False) + return result.returncode, log.read_bytes().split(b'\0')[:-1] + + def test_current_source_ui_uses_the_same_flasher_and_manifest(self): + status, calls = self.launch(0) + self.assertEqual(status, 0) + self.assertEqual(calls, [b'python', b'-c', b'import openpilot.system.ui.updater', b'python', b'-m', + b'openpilot.system.ui.updater', b'/flasher with spaces.py', b'/manifest with spaces.json']) + + def test_older_runtime_uses_portable_updater(self): + status, calls = self.launch(1) + self.assertEqual(status, 0) + self.assertEqual(calls, [b'python', b'-c', b'import openpilot.system.ui.updater', b'legacy', + b'/flasher with spaces.py', b'/manifest with spaces.json']) + + def test_source_ui_failure_does_not_start_another_installation(self): + status, calls = self.launch(0, ui_status=7) + self.assertEqual(status, 7) + self.assertNotIn(b'legacy', calls) + + def test_portable_ui_failure_propagates(self): + status, _ = self.launch(1, legacy_status=9) + self.assertEqual(status, 9) + + class TestRetainedAgnos(unittest.TestCase): def setUp(self): self.directory = tempfile.TemporaryDirectory() diff --git a/prebuilt.json b/prebuilt.json index 94af485840..b0d1c9f79e 100644 --- a/prebuilt.json +++ b/prebuilt.json @@ -1 +1 @@ -{"protected_inventory_sha256": "fcb3cf846157d3a6ef60358a0ad7d68141dc9ba0eb133cd2c9d271f17a10d4f1", "schema_version": 1} +{"protected_inventory_sha256": "ef6bd9e3bf6ab31a5326ae0ddb2ee386613a5d93304fb815d1b4cafa23cb8ce4", "schema_version": 1}