EngineUpdate final readonly class
Minn\Ops\EngineUpdate · public/minn/src/Minn/Ops/EngineUpdate.php · 150 lines
Replaces the running engine with a published release. The release's minn.zip comes from the Minn update service and nowhere else (every redirect hop is judged), must match the sha256 its release records, and must carry an Ed25519 signature made with a key this engine was built to trust (KEYS; the secret half never leaves the release maintainer's machine, so neither GitHub nor the service can stand in a build of their own). It is unpacked beside the engine into a folder of its own, where it is checked again: its bootstrap names the version on offer and bin/minn is there. Then the swap, two renames in the folder the engine lives in: the running engine moves aside, the new one moves in, and the old copy is removed; when the second rename fails the first is undone. The webroot's shape files are laid again from the new engine (ShapeFiles::refresh): one still as the old engine wrote it, a stock empty placeholder above all, is replaced, and one the site changed is left alone. The legacy install record (.install.json, from installs that kept it inside the engine) comes along. One update runs at a time. A development checkout (a symbolic link, or a folder under git) is refused: git owns those. The site keeps answering throughout.
Constants and properties
| const | KEYS = array ( 0 => '+Usjnr1ZTudBbWToqYLkZ1Oy2yKN07d9+u62AIJ2FG8=', ) | The public halves of the keys that sign Minn releases (base64 Ed25519; scripts/release-key.php). A new key ships here in a release signed by an old one before it signs anything. |
| private | MAX_DOWNLOAD = 67108864 | |
| private | readonly string $engineDir | Promoted from the constructor. |
| private | readonly array $keys | Promoted from the constructor. |
| private | readonly Minn\Http $http | Promoted from the constructor. |
Public
| new | __construct(string $engineDir, array $keys = self::KEYS, Minn\Http $http = \Minn\Http::__set_state(array( 'within' => array ( ), 'fake' => NULL, 'refusal' => NULL, )))# |
| |||
| method | apply(Minn\Ops\Release $release): string# | Downloads, checks and installs a release; the version now in place. | |||
| method | install(string $zip, string $sha256, string $signature, string $version): string# | Installs an archive in hand once it matches its checksum and signature, holds the version named, and that version is newer than the running one: an older release signed in its day is still signed, and putting it back would bring back what it was replaced for. The version now in place. | |||
| method | verify(string $zip, string $sha256, string $signature, string $version, string $use = 'used'): void# | Throws unless an archive matches the checksum its release publishes and carries a signature from a trusted key; $use says what would not happen. | |||
| static | versionOf(string $engineDir): string# | The version a bootstrap.php names; "0.0.0" when it names none. |
Internals 3
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | swap(string $zip, string $version, string $parent): string# | Unpacks, checks and swaps in the archive, one update at a time (install() holds the lock). |
| private | signed(string $zip, string $signature): bool# | Whether one of the trusted keys made this signature over the archive. |
| private | refuseCheckout(): void# | A link, or a folder inside a git working copy at any depth (the engine's own repository keeps it two levels down). |
Nothing matches.