Add orbit self-update to replace the running binary
- `orbit self-update [constraint]` replaces the running orbit with the newest `orbit` package in its channel, or one matching a constraint (which may downgrade). - The new build must print its version before it is renamed over the old binary. - An orbit installed as a global package is upgraded instead, keeping rollback. - `orbit upgrade orbit` does the same when orbit isn't installed as a package. - Read `/proc/self/exe` through a new C stub; document in README; mock-registry test.
This commit is contained in:
1 parent
f14a1900af
commit
d3b1dedeb5
7 files changed
+293
-2
No files matched your search
@@ -0,0 +1,23 @@
|
||||
---
|
||||
data:
|
||||
priority: normal
|
||||
status: done
|
||||
type: feature
|
||||
id: 4thyv
|
||||
title: Update Orbit itself from the registry
|
||||
---
|
||||
Orbit is published as the `orbit` package in `main` (built by orbit-packages, versioned by moon.mod). A copy installed outside Orbit (`just install`, the rolling release in `~/.local/bin`) had no way to update itself.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- `orbit self-update [constraint]` replaces the running binary with the newest `orbit` build in its channel when that is newer than the running version, or with the newest build matching an explicit constraint (which may downgrade).
|
||||
- The new binary is checked to run (`--version`) before it atomically replaces the old one.
|
||||
- When the running binary is the one Orbit installed globally, it upgrades the `orbit` package instead, keeping rollback.
|
||||
- `orbit upgrade orbit` does the same when `orbit` isn't installed as a package.
|
||||
- Mock-registry test; README documents it.
|
||||
|
||||
## Outcome
|
||||
|
||||
Done in `src/main/self_update.mbt` (`cmd_self_update`, `replace_self`), with `orbit_self_exe` in `stub.c` reading `/proc/self/exe`. The new build is staged as `<exe>.orbit-new`, must print `orbit <version>`, then is renamed over the old binary; the store download is deleted unless that build is installed. Tested with the mock registry (upgrade, up to date, downgrade by constraint, broken build left out) and by hand against `main` (0.1.0 reports up to date; a store-installed orbit hands off to `orbit upgrade orbit`).
|
||||
|
||||
Users only see an update once `moon.mod`'s version is bumped and orbit-packages publishes it. The published 0.1.0 doesn't have the command yet.
|
||||
Reference in new issue
Block a user