Replace oras with native OCI registry client and add login

- Talk to OCI Distribution v2 registries directly over HTTP/TLS; oras is no longer required on PATH
- Add `orbit login <host>` and `orbit logout <host>`; credentials go to $ORBIT_ROOT/auth.json (mode 0600)
- Fall back to Docker config (credHelpers and credsStore) when no Orbit credentials exist
- Verify layer downloads with streaming SHA-256
- Fall back to the next channel only on HTTP 404 instead of matching oras error text
- Update README and moon.mod to drop oras references
This commit is contained in:
nandi committed 2026-11-27 15:46:41 -08:00
1 parent f8c9b99ee3
commit 0919ce105c
13 files changed
+2652 -184

No files matched your search

+16 -11
View File
@@ -1,13 +1,13 @@
# orbit
A small package manager written in MoonBit that uses any OCI registry (Gitea, GHCR, Harbor, `registry:2`, ...) as its repository, with [ORAS](https://github.com/oras-project/oras) as the transport.
A small package manager written in MoonBit that uses any OCI registry (Gitea, GHCR, Harbor, `registry:2`, ...) as its repository, speaking the OCI Distribution v2 protocol directly over HTTP/TLS.
> **Status:** builds cleanly (no warnings) with MoonBit `moonc v1.0.0-rc1` / `moon 0.1.20261126`, and the unit tests pass. publish, install (with dependencies), upgrade, rollback, remove and gc have been exercised end to end against a local `registry:2` with ORAS 1.2.3.
> **Status:** builds cleanly (no warnings) with MoonBit `moonc v1.0.0-rc1` / `moon 0.1.20261126`, and the unit tests pass. publish, install (with dependencies), upgrade, rollback, remove and gc have been exercised end to end against a local `registry:2` and Gitea.
## What it does
- **Publish:** `orbit publish <dir>` packs `<dir>/files/` into `pkg.tar.gz` and pushes it with `<dir>/orbit.json` as the OCI config blob.
- **Install with dependencies:** it reads only the small config blob (`oras manifest fetch-config`) to plan, then pulls the layers by digest.
- **Install with dependencies:** it reads only the small config blob from the OCI registry to plan, then streams the layers by digest with SHA-256 verification.
- **Version constraints:** `1.2.3`, `1.2`, `^1.2.0`, `~1.2.0`, `>=1.2`, `*`. Prereleases match only when the constraint asks for one.
- **Content-addressed store:** packages unpack into `~/.orbit/store/<name>/<digest>/`, and their binaries are symlinked into `~/.orbit/bin/`.
- **File ownership:** two packages can't provide the same binary.
@@ -53,7 +53,7 @@ Because these are ordinary OCI artifacts, you can sign them with `cosign` or `no
## Usage
```sh
oras login git.site.latha.org # once, with a Gitea token (needed to publish)
orbit login git.site.latha.org # once, with a Gitea token (needed to publish)
eval "$(orbit env)"
orbit publish examples/hello
@@ -64,6 +64,8 @@ orbit rollback hello
orbit remove hello
```
Credentials are stored in `~/.orbit/auth.json` (`$ORBIT_ROOT/auth.json`, mode `0600`). Orbit also falls back to `~/.docker/config.json` (`$DOCKER_CONFIG/config.json`) including `credHelpers` and `credsStore`. Use `orbit logout <host>` to remove stored credentials from Orbit.
## Channels
Packages come from **channels**, which work like channels in pixi. A channel is a name for a registry namespace. The built-in `main` channel is `git.site.latha.org/nandi`, so no setup is needed.
@@ -119,7 +121,7 @@ isn't already there. Open a new Bash shell or run `source ~/.bashrc` to pick
up the change in your current shell. `~/.local/bin` must already be on `PATH`
to run `orbit` itself by name.
Linux only for now: arguments come from `/proc/self/cmdline`. It needs `oras`, `tar` and `/bin/sh` on `PATH`.
Linux only for now: arguments come from `/proc/self/cmdline`. It needs `tar` and `/bin/sh` on `PATH`.
### Package Orbit with Orbit
@@ -131,10 +133,10 @@ package_dir=$(sh scripts/package-orbit.sh) &&
_build/native/release/build/main/main.exe publish "$package_dir"
```
This publishes to the `main` channel (use `--channel <name>` for another), so log in with `oras login <host>` first if needed. The
This publishes to the `main` channel (use `--channel <name>` for another), so log in with `orbit login <host>` first if needed. The
package contains a native Linux binary for the build machine's architecture.
Use the same architecture on the install machine. `oras` and `tar` are still
system prerequisites; the package does not bundle them.
Use the same architecture on the install machine. `tar` is still a
system prerequisite; the package does not bundle it.
To bootstrap from source, install the published package with the binary you just
built. After adding Orbit's bin directory to `PATH`, use the installed binary
@@ -152,11 +154,14 @@ orbit upgrade orbit
```
src/main/
stub.c C glue: system(), popen(), file read/write, getenv, exit
sys.mbt FFI bindings, UTF-8, string helpers, shell quoting
stub.c C glue: time, termios echo toggle, getenv, symlink, stderr, exit
sys.mbt FFI bindings, UTF-8, string helpers, spinner, atomic writes
sha256.mbt streaming FIPS 180-4 SHA-256 (+ tests)
auth.mbt credentials store (~/.orbit/auth.json + Docker config fallback)
oci.mbt OCI Distribution v2 HTTP transport, Bearer/Basic auth, redirects
semver.mbt versions, constraints, tag selection (+ tests)
model.mbt orbit.json / state.json / config.json (+ tests)
registry.mbt oras wrappers: tags, resolve, fetch-config, pull, push
registry.mbt OCI registry ops: tags, resolve, fetch, publish, login verify
ops.mbt dependency planner, install/remove/upgrade/rollback/gc
channels.mbt config.toml, channel priority and lookup (+ tests)
main.mbt CLI