Skip to content

Fix LivePatch remount failures and incomplete installs (#477) - #491

Open
isaacwisdom wants to merge 2 commits into
Open-HMG:release/1.1from
isaacwisdom:fix/release-1.1-install-livepatch-477
Open

isaacwisdom wants to merge 2 commits into
Open-HMG:release/1.1from
isaacwisdom:fix/release-1.1-install-livepatch-477

Conversation

@isaacwisdom

@isaacwisdom isaacwisdom commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the incomplete installation described in #477: a plain remount leaves LivePatch's /system/lib farm read-only, so installation stops after writing hmgapid/lpatch but before installed.txt and the on-unit uninstaller exist. Package removal then skips those leftovers and NEMESIS updates remain blocked.

  • Request --bypass-livepatch during writable remounts in install and uninstall, with a plain-remount fallback for older NEMESIS. Restore farms using ordinary remount ro.
  • Check every system destination before installing runtime files.
  • Recover incomplete installs by reinstalling the fixed package, or remove their leftovers through package/USB uninstall, retaining stock-binary validation and preserving NEMESIS's zygote script.
  • Keep a newer on-unit uninstaller when recovery media are older; compare final and alpha/beta/rc versions, preserving the on-unit script when version precedence is unknown.
  • Restore LivePatch farms even when every writable-remount attempt fails. Preserve executable modes on both USB scripts.

Based directly on release/1.1. Preserves the existing NEMESIS support policy and all prior installer regression tests.

Validation (off-car): 351 installer checks, 81 USB/package checks, 62 NEMESIS sync checks, 58 common checks, and 5 head-unit command checks passed. One host-dependent common check skipped. Includes a read-only-directory simulation of #477, bypass/fallback behavior, reinstall recovery, failed-remount cleanup, guarded partial-install cleanup, and older/equal/newer uninstaller selection. Version-selection tests also pass under macOS sh and dash. The test payload was repackaged with existing runtime binaries; no runtime binary changes. No on-car validation yet.

Refs #477; keep the issue open until the reporter confirms recovery. Replaces closed #490.

…HMG#477)

Bypass read-only LivePatch farms while writing, with a plain-remount fallback for older NEMESIS. Check system destinations before runtime files go in and let package/USB uninstall recover an install without installed.txt. Keep existing NEMESIS compatibility policy and regression coverage.
@isaacwisdom
isaacwisdom marked this pull request as ready for review December 2, 2026 19:34
@isaacwisdom
isaacwisdom requested review from a team and VysseCodes as code owners December 2, 2026 19:34

@AwsomeFox AwsomeFox left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked this against NEMESIS's source (1.17.3) and ran the tests here on macOS. It fixes #477 as described, and I found nothing that puts a unit at risk. Not checked on a car, as the PR says.

Checked:

  • --bypass-livepatch exists from NEMESIS 1.17.1. Before that, cmd_remount stops with a usage error on any second word, so the fallback to a plain remount runs, as the PR says.
  • Any remount ro puts the farms back, rebuilt from the real folders, so a libhmgapi_hook.so written while they're down is in /system/lib afterwards. NEMESIS puts them back before its own remount, so that happens even when remount ro fails because /system is busy. fail() remounts ro once REMOUNTED is set.
  • The flag works inside a NEMESIS hook too. HMG-API's package descriptor is version=1.1, so on 1.17.3 a plain remount in its hooks already steps the farms aside (NEMESIS_LEGACY_HOOK). So this PR is what fixes 1.17.1 and 1.17.2, and the USB stick and adb routes on every 1.17.1 or later.
  • NEMESIS keeps the package on any nonzero preuninstall exit, for an uninstall and for an update (pkg.c, uninstall_tree and cmd_install), so the new exit 1 does what the comment says.
  • Here on macOS:
    • install/common/install-test.sh: 325 ok.
    • install/nemesis/sync-test.sh: 62 ok.
    • install/common/test.sh: 37 ok.
    • tools/check-scripts.sh: ok.
    • install/usb/test.sh: 71 ok, 1 failure ("a pre-release's package-version comes before its release"). That check is already on release/1.1 and fails there the same way (a case inside $(...) under macOS's bash 3.2), so it isn't from this PR.
  • I also tried the other way out of #477: this payload installed over the partial install, with the farm up. The install completes: the wrapper goes into app_process.real, LivePatch's script stays at app_process, and the farm is read-only again afterwards. Uninstall then gives the stock .real back. That's what installing the fixed NEMESIS package over the stuck rc.10 entry does, since the old package's preuninstall exits 0 on an update.

Suggestions:

  1. Say that installing again also recovers. The README and changelog only offer UNINSTALL. The reporter most likely wants HMG-API installed, and installing the fixed package over the stuck entry (or from the stick) does that in one step. A check for it in install-test.sh would keep it working: the partial install from partial_install, then install.sh with the farm stub.
  2. The stick and the package now use their own uninstaller even for a complete install. That's needed while the on-unit uninstaller is 1.1.0's, which has no bypass. But a stick or package older than what's installed would then uninstall with an older uninstall.sh, whose file list (uninstall.sh:186) and stock.txt are that version's. You can keep both: use the payload's uninstaller only when it's at least the installed version (the version line in installed.txt against the payload's VERSION), or when the on-unit one is missing. Low risk today, but worth deciding.
  3. Two mode changes look unintended. install/usb/test.sh and install/usb/troubleShooter go from 755 to 644. Nothing breaks: mkinstallers.sh sets 0755 on the stick, and the tests run both with sh. But they're unrelated to the fix.
  4. main and release/2.0 have the same plain remount (install.sh:39, uninstall.sh:20). 2.0 still updates units that have NEMESIS, so it needs this too. There, the preuninstall and troubleShooter hunks will conflict with #478, #479 and #480.

Smaller: suppose remount rw --bypass-livepatch takes the farms down but NEMESIS's own remount then fails, and so does every fallback. REMOUNTED isn't set yet, so fail() doesn't run remount ro, and the farms stay down until the next restart. While they're down, the files LivePatch serves aren't visible (Enhanced Projection's, on the reporter's unit). This is rare and a restart fixes it, but a remount ro before fail in that one case would close it.

…stall

Document and test completing partial installs by reinstalling. Prefer payload uninstall code only when equal/newer or when the on-unit script is missing. Restore LivePatch farms even if writable remount attempts fail, and retain the USB scripts' executable modes.
@isaacwisdom

Copy link
Copy Markdown
Contributor Author

@AwsomeFox Thanks for the feedback. comments addressed in 895fcbc

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants