Repository navigation
One install or uninstall at a time; the USB stick no longer offers the NEMESIS install - #478
Open
VysseCodes wants to merge 3 commits into
Open
VysseCodes wants to merge 3 commits into
VysseCodes wants to merge 3 commits into
Conversation
…e NEMESIS install The stick carried both ota_package.tar (Engineering Mode's DSP OTA) and a NEMESIS.data of type install, so on a unit with NEMESIS both could run the same install.sh at once, each swapping app_process, and install.sh had no lock. install.sh and uninstall.sh take a lock first (lib.sh install_lock): a folder on tmpfs (/dev/.hmgapi-install), so a run cut off by a power loss never blocks the next boot, with the holder's pid; a holder that's gone is taken over. While it's held they refuse and change nothing. The stick no longer has NEMESIS.data or the NEMESIS package; the README points NEMESIS owners to route A or the NEMESIS download. Tested off-car only: install/common/test.sh (lock taken, refused while another install runs, taken over from a holder that's gone), install-test.sh (262), orders-test.sh, install/usb/test.sh (60).
…load HMG-API isn't installed alongside NEMESIS (2.0), so the stick's route B says so instead of pointing at hmgapi-<v>-nemesis.zip.
This was referenced Dec 1, 2026
Contributor
|
Small race: the pid is written after |
…t fix A second install arriving between the first one's mkdir and its pid write saw an empty pid, took the lock over, and both ran (review). An empty pid is now read again after a second before the lock counts as left behind. The test's skip path (no /proc, macOS) never made the lock folder before writing a pid into it, which ended the suite under set -e. Tested off-car: install/common/test.sh (new check: a lock taken a moment ago with no pid yet is refused; it fails without the fix), in sh and bash.
AwsomeFox
reviewed
Dec 2, 2026
AwsomeFox
left a comment
Contributor
There was a problem hiding this comment.
The macOS test fix in 6abb939 works: install/common/test.sh passes here on macOS at that commit.
On the lock itself:
grep -eis new on the unit. No script that runs on the head unit usesgrep -etoday. If the unit's grep doesn't take it, the stale-holder check errors, every lock looks stale, and the lock quietly does nothing. One plaingrep -q install.shcovers it: it also matchesuninstall.sh, and the holder is nevertroubleShooter, which doesn't take the lock.- Taking over still isn't atomic. The read-again in 6abb939 covers a holder that hasn't written its pid yet. Two runs that both find a stale lock can still both go ahead: A removes it and makes its own, then B's
rm -rfremoves A's fresh lock and B makes its own. The window is small. Taking over by rename closes it, since only onemv "$INSTALL_LOCK" "$INSTALL_LOCK.stale.$$"wins. - A
mkdirthat fails for another reason refuses every install. If/devcan't be written from some caller's context, every install says "another HMG-API install or uninstall just started". That message misleads. When the folder doesn't exist after a failedmkdir, say the lock couldn't be taken. Not checked on a car, as the PR says. - README B says "This build has no way to install on a unit with NEMESIS yet". But
tools/mkinstallers.shstill buildshmgapi-<v>-nemesis.zip, and with #480 that download still updates units that already have HMG-API. Say that, or drop the download for 2.0.
Checked and fine:
- A NEMESIS sync inside a locked install never reaches a second
install.shoruninstall.sh, because both NEMESIS hooks exit at once onHMGAPI_NEMESIS_SYNC=1. - No other
trap ... EXITreplaces the lock's.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
install.shanduninstall.shhad no lock, and the USB stick carried two ways into the same install:ota_package.tar: Engineering Mode → USB Copy → DSP → Update OTA runstroubleShooter, which runsinstall.sh.NEMESIS.data(type=install): on a unit with NEMESIS, plugging the stick in makes NEMESIS offer the same package, whosepostinstall.shrunsinstall.shtoo.Both can run at once, each remounting
/systemand swappingapp_process. The app, adb and NEMESIS packages call these scripts as well.Change
lib.shinstall_lock, called byinstall.shanduninstall.shright after the root check, before anything changes:/dev/.hmgapi-install, with the holder's pid; given back when the script exits;install.sh/uninstall.sh/troubleShooter: refused with "another HMG-API install or uninstall is running (pid N). Nothing was changed: wait for it to finish.";HMGAPI_NEMESIS_SYNC=1) never reachesuninstall.sh, soinstall.sh's ownnemesis-syncisn't refused by its lock.tools/mkinstallers.sh) no longer hasNEMESIS.dataorHMGAPI/install/hmgapi.zip. The README's route B says HMG-API isn't installed alongside NEMESIS (no pointer to the NEMESIS download).Part of 2.0 (#468, section 2).
Tested
Off-car only:
install/common/test.sh: new checks for the lock (taken and given back; refused while another install runs, its lock left alone; taken over from a holder that's gone or whose pid is another process)install/common/install-test.sh(262),install/common/orders-test.sh,install/usb/test.sh(60, with new checks: noNEMESIS.data, no NEMESIS package, the DSP entry and payload there)core/runtime/scriptcheck-test.shinstall/common/test.shunder dash fails the same way onrelease/2.0without this change.Not on a car yet. To check on one: an install while another runs is refused; an install after a power cut mid-install isn't.