Updates
Pinnacle updates its apps and itself from the same package sources the
Store reads (store.md). The person chooses, in Settings → Updates,
whether updates are looked for at all, and whether they are then only
told of or installed by themselves. Nothing restarts the device by itself:
a new system starts when the person restarts it.
Apps
store.md ("Updates by themselves") has how the updates service brings
apps up to date: the same install the Store does, by itself only for a
version that asks for no more than the installed one may do, never for an
app that is running.
The system
A system is its kernel (which carries the system programs: the display
server, the launcher, Settings, the Store and the services), the apps it
comes with, its fonts, the certificates' roots TLS checks against and the
time zones (zoneinfo/).
Two slots and a boot record
The system disk keeps up to two systems besides the one the boot medium
holds: /system/a and /system/b, each the files of one system and its
signed package (package). /system/boot, the boot record, says which
runs (pinnacle_pkg::system):
| Field | Meaning |
|---|---|
current | The slot whose system runs, once one has started well. None: the boot medium's own. |
next, tried | A slot to try at the next start, and whether that try was made. |
failed | A slot whose try did not start, until another is tried. |
The kernel on the boot medium (QEMU's -kernel, an SD card's Image) is
the boot kernel. It never changes by an update; at every start it reads
the record before the other cores run (kernel/src/chain.rs):
nextnot yet tried: the record is markedtried, then that slot runs.nexttried already: that system never started. The record is told (failed), and the one before runs:current, or the boot kernel's own.- Otherwise
currentruns, if it is set.
"Runs" means the boot kernel hands over to the slot's kernel, when the
slot's system is newer than its own (a boot medium written since, or a
development build, runs itself). It reads the kernel into memory, checks
its SHA-256 against the slot's package and the package's signature against
/settings/system-keys, stops the disks, masks interrupts, turns the
caches and the MMU off (every line of RAM cleaned to memory first), and
jumps to the image's first byte with the device tree in x0, as a loader
starts a kernel. Its mark in x1, the EL it was entered at in x2 and the
slot in x3 tell the new kernel it was handed over to; the image moves
itself to its load address over the boot kernel (boot.rs), and reads no
record.
A PC (x86-64) hands over as GRUB starts a kernel. Its slot holds the
kernel's ELF; the boot kernel reads it above every address it is to be
copied to, checks it as above, and from a page of its own in the
identity map, interrupts off, copies each segment to the physical
address the ELF names (from 2 MiB, over the boot kernel), drops to
32-bit protected mode with paging and long mode off, and enters it with
Multiboot2's magic in EAX and boot information in EBX: the loader's
memory map, framebuffer and ACPI root pointer, and its command line
with pinnacle.slot=<n> added, which tells the new kernel it was
handed over to (kernel/src/chain.rs, x86_64/loader.rs).
A new system has started well once its display server has drawn its
first screen (the password, or the home screen): the display server then
makes it current (pinnacle_ui::updates::confirm_start). One that hangs
or crashes before that has had its one try: at the next start, after the
person switches the device off and on, the one before runs, and the
updates service tells them that version did not start. It is not fetched
again.
Every write is one transaction of the file system: a power cut leaves the record as before or after it.
Fetching one
The updates service looks for <source>system/<board>/catalog (one
line, system|Pinnacle|<version>|<size>|…) beside each package source's
apps, the board as the kernel names it (qemu-virt, pc; a PC's package
source is the one in pc/). Told, it says a newer
version can be installed (Settings shows Install); installing by itself, it
fetches it. Either way it goes into the slot that does not run and is not
the one a failed try falls back to (Record::free): the package
(packages/system.ppk) checked against the system keys, each file against
the package's list as it is written, a file the slot already holds with the
same hash kept, the package written last, then next set. Settings shows
Restart.
After a start from a slot, once it is current, the service puts the
files that system came with in their places on the system disk (the apps
in /apps, /fonts, /certificates, /zoneinfo), once a version
(/system/applied).
Go back in Settings sets the system kept in the other slot as next
and restarts.
Versions and keys
A version is the number of commits on main the system was built from:
cargo xtask numbers every kernel it builds (PINNACLE_VERSION, else
git rev-list --count HEAD) and Settings shows it. A system is offered
when its version is greater than the one running.
System packages are trusted apart from apps: /settings/system-keys, not
/settings/trusted-keys, so a key that may publish an app cannot replace
the system. Every system disk cargo xtask makes trusts this checkout's
development key and the hosted Store's for both.
Publishing
midas deploy pinnacle-apps (after every landing) runs
tools/deploy/store.sh, which also writes dist/store/system/<board>/
with cargo xtask package-system; the server signs system.ppa with the
Store's key as it signs the apps, and it is published at
https://pinnacle-os.eu/store/pinnacle/system/qemu-virt/, and a PC's at
https://pinnacle-os.eu/store/pinnacle/pc/system/pc/.
Seeing it
cargo xtask updates-demo (apps) and cargo xtask system-update-demo
(the system: version n finds n+1, fetches it and starts it at a restart;
then n+2, whose kernel never starts, is tried, the machine is switched off
and on, and n+1 runs again, saying so); cargo xtask system-update-demo pc
the same on a PC.
Limits
- A PC's slot kernel must lie below 4 GiB once read (the identity map the copy runs from ends there), and a PC needs the room to hold two kernels at once while it hands over (its kernel, with the programs in it, is some 160 MB).
- A PC booted by GRUB from UEFI hands over as GRUB would start the new kernel; UEFI's runtime services are not passed on (Pinnacle uses none).
- A system that starts its display server and then fails later (an app that crashes, a service) counts as started well; Go back is the way out.
- Going back reaches only the system kept in the other slot, not the boot medium's own.
- The boot kernel itself, and the bootloader before it, are not updated: they change with a new boot medium.
- A cut-off fetch starts again (files already fetched whole are kept).