The installer's engine¶
TL;DR. The installer is one engine for every headset: a headset gives it a plan, stages of tasks built on its commands and steps, and the engine runs them in order, records what is done, goes on after a failure where it stopped, and talks to the app (or a terminal) in events. It is standard library only. A task that writes to the headset is never cut off, secrets never leave the engine's memory, and only one engine runs at a time. The headset's backup is checked before and after every move: exported as one file, imported, or chosen among several.
| The engine | overpressure/install.py |
| A headset's plan | Headset.install_plan(), from the headset's own module (the PICO 4's tooling/installer/install.py) on the shared building blocks of overpressure/roles.py |
| Its commands | overpressure install, upgrade, restore, backup (the command line) |
| Its events | the engine's protocol |
Plans and workflows¶
A headset's plan comes from Headset.install_plan(): stages, each a list of tasks built on its commands and
steps. A headset without one has no installer (exit status 2).
- Workflows. A headset may give more than the install (
Headset.workflows(), each aWorkflow: key, title, summary, whether it erases the headset) with their plans (Headset.plan(key));install --workflow KEYruns one.upgradeisinstall --workflow upgrade(a new system, the data kept),restoreisinstall --workflow restore(back to the headset's own system). Before a run,Headset.workflow_problem(key)may refuse it (exit status 2). - Flavours. The install asks which system the headset gets when the headset offers more than one (flavours): SteamOS by default, later overpressure OS. An upgrade builds the one installed; another one means installing again.
- Questions before the start. The app asks what a workflow needs before it starts (
Headset.questions) and passes the answers on the engine's stdin (install --early); a question asked so is not asked again mid-run.
Order and resume¶
Tasks run in order; the first failure ends the run.
- The state is
out/install/<codename>/state.jsonfor the install,out/install/<codename>/<workflow>/state.jsonfor another workflow ({"schema": 1, "tasks": {ID: {"status": ..., "finished": UTC}}}, and"choices": what a task recorded withctx.remember, never a secret, such as a skipped ask), the tasks' logs beside it. - Skipping what is done. A task done earlier is skipped unless its done check says its result is gone; a done
check also skips a task whose output is already there (
skipped).--restart STAGEforgets that stage and every later one. - The end of a workflow. A finished workflow forgets the other workflows' state and records
"completed": {"release": ..., "at": UTC}in its own. A workflow that changes the headset records its last run in"last":runningwith its start while it runs (still there: it was cut off), then thefinishedevent's fields with when it ended. - Another release. The state records the headset's tooling (
"release": its tag and zip, or the development checkout); progress another release made starts over, the choices kept, so a changed plan never resumes in the middle, and each task's done check skips what is there already. - What the headset runs.
install.installed_releasereads it: the release of its last finished install or upgrade (none after a restore).
Running tasks¶
- Child programs run from the repository root (Linux-root steps in the build container,
steps); their output, and what a task prints, goes to log events and
out/install/<codename>/<task>.log, so stdout carries only events. - Progress. A task reports how far it is with
ctx.progress, or its program prints progress lines; a task without them is shown against its estimate. - One at a time. An OS lock on
out/install/lockkeeps a second engine out, whatever its headset. - Stopping. Ctrl-C, a closed stdin or
{"stop": true}on stdin stop the run wherever it waits: an ask, a wait throughctx.clock(checked every 0.2 s), a program that does not write (it is ended). A program that writes to the headset runs in its own process group and is never cut off: the stop takes effect when it has ended. The stopped task is pending again, andfinished'swheresays the headset's state. - Secrets. A form's secret values stay in the engine's memory: never in a log, the state, the records, a
command line (refused), an event or stderr; a program gets them on its stdin only. Text that would carry one
shows
***. - Records. What the installer finds out (a headset's serials) it records (
ctx.set_setting,localconfig.update:out/records.json; the owner's SSH key goes tosettings.json, settings).
Power¶
Before each task that writes to the headset the engine checks the computer's battery again and fails the task before its write when it has dropped below the limit (30 %, the command line).
Exit status¶
| Status | Means |
|---|---|
| 0 | finished |
| 1 | failed |
| 2 | a usage error, no installer or a refused workflow |
| 3 | stopped |
A headset another computer installed¶
Its recovery takes that computer's key alone, and its installed system that computer's and the owner's own. The
look offers Check and Restore when the owner's private key (Settings) gets in, else Restore alone. The restore
then writes the whole backup in EDL mode: the owner's key restarts the headset into it, or the owner does by hand
(the restore's question How should the restore reach the headset?, roles.reach_ask, whose chosen key goes into
Settings by its location).
Every refused login counts against this computer on the headset (OpenSSH's per-source penalties: 5 s each, up to 10 min without any connection): the look offers keys it was refused again only after 10 minutes or once they change, and tries none when this computer has no key file at all.
Backups¶
The backup as one file¶
backup export FILE writes the headset's backup (Headset.backup_set(): the verified backup folder, the
identity, other files and the settings the way back needs on another computer) as one uncompressed tar
(overpressure/backup.py), whose partition images are sparse members (GNU's PAX
format 1.0: their zero runs are not stored; tarfile and GNU tar read them back whole):
overpressure-backup.json first (schema, headset, folder name, identity, file names, settings, export time), then
the backup under backup/ and the other files under files/. The backup is verified before, the file read back
after; it appears only when both match, never over an existing file.
backup import FILE refuses another kind of headset, another headset than this computer's identity, a damaged
file and any file that would replace a different one; a backup already there with the same manifest is kept,
another gets a new folder beside it. The imported backup is verified and its zero runs handed back to the disk as a
new backup's are (overpressure/holes.py); Headset.adopt_backup records it as the
way back when the headset has none yet (backup.adopts), else it stays beside it. An export holds what reaches
overpressure's recovery on the headset: keep it private.
Several backups¶
A headset's backups are the folders beside its way back, each with its manifest (backup.kept): a new backup or an
import goes into a folder of its own there. backup use NAME checks one whole and then has Headset.adopt_backup
record it as the way back; another headset's is refused. backup delete NAME asks, then deletes one for good;
never the way back, never the headset's only backup. backup export FILE --name NAME exports one that is not the
way back.