Skip to content

Deploy tool: fewer writes to storage on installs and at each start - #344

Merged
robertnisipeanu merged 1 commit into
mainfrom
emmc-deploy
Nov 19, 2026
Merged

robertnisipeanu merged 1 commit into
mainfrom
emmc-deploy

Conversation

@robertnisipeanu

@robertnisipeanu robertnisipeanu commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Cuts what an install and each start write to the head unit's storage, keeping one previous version for rollback, the safety and boot-loop guards, and write-then-rename for everything a power cut must not leave half written.

  • Packages are unpacked, prepared and checked in a RAM folder (/run/mgu-deploy/stage-<pid>) when they fit: within 128 MiB for the run, a quarter of the memory available, and 64 MiB left free on /run, sized from the decompressed archive. Otherwise they unpack under /var/opt/mgu-deploy as before. A tool's files are then written once into versions/<v>.partial and renamed into place, as before.
  • An app's package is written to preinstalled_apps once, straight from its file, in the same root-partition window (temp file, sync, rename, sync). The window's script and any staged data live in RAM.
  • A backup links a file that an earlier backup or the kept package of the same name already holds, after checking its sha256, instead of storing another copy. Backups and kept packages are only ever replaced by rename or removed, so a link keeps its bytes after the other copy goes.
  • The provisioning fallback copy of MainApp's main.js is built and patched in RAM, both at installs and in the boot unit, and written to /var/opt/mgu-deploy/main.js only when its bytes change.
  • writeAtomic leaves a regular file that already holds the same bytes as it is (synced, mode set). A symlink or other non-regular file is still replaced by rename. The kept package is written only when its bytes differ.

Update order: the boot unit and the scripts it runs keep their command lines, and any path to an artifact is accepted, so this works with the published updater, app-privacy and renderer.

AI: Claude Code, Claude Opus 5.5

Tested: deploy/test/run.sh (Node 8.16.2): 1476/1476 pass, including new tests: unpacking on storage when RAM has no room, a backup linked to a kept package, and the backup keeping its bytes once that kept package is pruned. On an iDrive 7 test unit, measuring /var/opt block writes with the updater change (#345) installed: one tool update 23.5 → 9.2 MB, a Store update 70 → 28.6 MB (what remains is mostly MainApp's own unpack), Update all of six tools and three idrive7-apps apps 232 → 78.5 MB. Our writes at a start went from 2.3 MB to under 0.1 MB; the fallback copy was not rewritten. Hard power cuts (cache lost) mid-write of a tool's version folder, right after its version-folder swap, and during the Store's in-place update all recovered: the previous or the new version complete and current, services running, the next install finishing normally. Not tested on a car or an iDrive 8 unit.

Human review: no

Screenshots: n/a

🤖 Generated with Claude Code

Packages are unpacked, prepared and checked in RAM when they fit (on
storage otherwise); a package is written to the system partition once,
from its file; a backup links a file an earlier backup or kept package
holds; the provisioning fallback copy of main.js is built in RAM and
written only when it changes, at installs and at each start; state files
are written only when they change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@robertnisipeanu
robertnisipeanu merged commit ed22d25 into main Nov 19, 2026
1 check passed
@robertnisipeanu
robertnisipeanu deleted the emmc-deploy branch November 19, 2026 19:52
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.

1 participant