MMotor OS
Developing

Lorry: the package manager

Lorry is Motor OS's Rust package manager: a smaller, stricter Cargo replacement for security-sensitive environments. It is Cargo-compatible. It takes a package's Cargo.toml and Cargo.lock as they are, and aims to produce byte-identical binaries. Builds are always offline, and Lorry never invokes Cargo. On Motor OS, dependencies come only from Lorry's own repositories: each one was fetched once, checked, shown to a person, and recorded. Lorry runs on Linux and on Motor OS. On Motor OS it is the Rust build driver, because the developer image has no Cargo.

Cargo compatibility

A Lorry project is a Cargo project. Nothing about the package changes, and Cargo can still build it:

The compatibility is with the package model Lorry supports, which is deliberately smaller than Cargo's. What is left out is listed under The package model. Anything outside it is rejected with a clear error, not approximated.

Where dependencies come from

Lorry has two sources for crates.io packages:

Git dependencies always come from Lorry's own verified snapshots.

Why a smaller, stricter Cargo replacement

In many corporate environments a build tool that goes out to the Internet on its own and silently downloads and runs code from hundreds of crates is a weakness, not a convenience. That is what cargo build does: the lock file names the crates, Cargo fetches them, runs their build scripts, and loads their procedural macros into the compiler, and nothing in that sequence asks anyone anything. Lorry is designed for the environments where that is not acceptable:

Lorry does not replace reading the code you depend on; it makes sure that nothing enters a build without having been seen, and nothing runs during a build without having been allowed.

Commands

lorry new hello                  # a package with an edition-2024 binary and a lock file
cd hello
lorry build [--release]          # build, offline
lorry check                      # type-check without linking
lorry clippy [-- LINT OPTIONS]   # lint with the clippy-driver next to rustc
lorry run [-- args...]           # build and run a binary, forwarding arguments
lorry test [--no-run] [-- args]  # build and run the library, binary, and integration tests
lorry clean
lorry vendor [--accept-all]      # fetch, check, review, and record dependencies
lorry vendor upgrade PKG[@OLD] --to VERSION
lorry fetch                      # fetch the locked sources, for browsing; grants nothing
lorry review                     # print the canonical review of the dependency set
lorry metadata, tree, locate-project   # Cargo-compatible project queries
lorry cache clean
OptionMeaning
+toolchainOn Linux, a rustup toolchain selector, as with Cargo. On Motor OS the compiler is /devtools/bin/rustc.
-p NAME, --workspace, --exclude NAMESelect workspace members, as in Cargo. A member's directory selects that member.
--lib, --bin NAME, --test NAME, --example NAME, --all-targets, ...Choose targets, as in Cargo. run otherwise takes package.default-run or the sole binary.
--features, --all-features, --no-default-featuresSelect features, as in Cargo.
--release, --profile NAMEChoose a profile. Named profiles inherit as in Cargo.
--target TRIPLEAn installed target; custom JSON targets are rejected.
--target-dir DIRWhere build output goes; CARGO_TARGET_DIR and Cargo's build.target-dir work too. Lorry writes only below its lorry/ subdirectory.
-j NHow many compilers run at once. LORRY_JOBS and Cargo's build.jobs work too.
--message-format jsonCargo's JSON messages on stdout, for tools.
--lorry-messagesLorry's own errors as JSON lines on stderr, for tools and agents.
--keep-going, --no-fail-fastKeep building after a compile error; keep testing after a failed test.
--bundlePackage the test harnesses and the binary into one self-extracting executable for the target, to run on another machine.
--strict-validationRehash every source, tool, cache entry, and artifact before reusing it.
--use-cargo-registry, --no-use-cargo-registryRequire Cargo's cache, or use only Lorry repositories (Linux).
-q, -v, --colorOutput control.

lorry run executes the program directly, without a shell, and returns its exit status. lorry test builds separate harnesses for the library, the binaries, and each integration test, then runs them in Cargo's order and stops at the first failure. Arguments after -- go to every harness. Documentation tests are not run, because Motor OS has no rustdoc. Usage errors exit 1; build, vendoring, policy, and operational failures exit 101; an interrupted run exits 130.

Where things live

On Motor OSPurpose
/user/cfg/lorry.tomlYour Lorry configuration: the Cargo compatibility version (1.99), policy limits, and the reviewed grants for build scripts and procedural macros. Rules for one workspace go in its [workspaces."/path"] table. The curl program, CA bundle, and native C and C++ tools are built in.
/user/cfg/lorry-workspaces/Lorry's record of your decisions for each workspace: vendor --accept-all, the review you approved, and the build-time code and repository Cargo files you approved. Delete a file to forget them.
/devtools/lorry/user/vendorThe user repository: content-addressed, immutable objects under objects/crates-io/sha256/, a .staging area, and a repository.toml. Ships empty.
/devtools/lorry/user/cacheCompiled dependency units shared between projects, read-only views of dependency sources, and saved answers from rustc.
/user/cfg/lorry-redirect-sites.tomlThe list of sites whose HTTP redirects have been allowed or denied.
/none/cfg, /devtools/lorry/noneThe same files for Lorry running as None, which cannot read Interactive's. Lorry refuses to run as System.
PROJECT/.lorry/dependencies-v2.tomlThe project's admission record: which packages, at which checksums, were reviewed for which host and target pairs. Committed with the project, never edited by hand.
PROJECT/.lorry/vendor/git/Verified snapshots of the project's Git dependencies.
PROJECT/target/lorry/Build output, in Cargo-shaped debug and release directories, plus incremental state for workspace members and path dependencies.

Configuration files are merged in order: your file, then the workspace root's own lorry.toml. Every file declares config-version = 1, and an unknown key is an error. A project's own file grants nothing, because a cloned repository controls it: it may set only the Cargo compatibility version, vendor targets, and which dependency forms to keep. Policy, tools, and paths come from your file. On Linux your file is $HOME/.config/lorry/lorry.toml and the cache is $HOME/.cache/lorry. Repositories come in three roles, system (read-only, Linux only), user, and local, set in a workspace's table. Lookup goes local, then user, then system. Vendoring writes to the local repository if one is configured, otherwise to the user's.

Vendoring and admission

lorry vendor resolves the whole workspace from Cargo.toml and Cargo.lock. For each package missing from the repositories, it fetches it over HTTPS, checks the checksum and the archive structure, and applies the policy. Then it asks for one approval, showing each new package's exact version, checksum, license, size, whether it has a build script or is a procedural macro, and the dependency edges it adds. The review also lists build scripts and procedural macros that no rule grants, and repository .cargo files that set a linker, a runner, or other risky options; one "yes" approves exactly what it shows, and Lorry records it for this workspace. --accept-all approves after all checks have passed, and Lorry remembers it: the workspace's build-time code then runs as it does with Cargo. It cannot bypass an integrity failure, a policy denial, or the redirect list. A fresh clone's committed admission record counts only after you approve its review with one lorry vendor. Approved objects are written with fsync and published atomically, and an object is never replaced. Cargo.lock is replaced next, and the admission record is written last.

lorry fetch also uses the network, but only to fetch the exact sources that Cargo.lock names. It shows no review, runs no package code, and grants nothing. It is enough for metadata, tree, and browsing sources in an editor; building needs a review.

Policy

The policy in your lorry.toml decides what may be admitted. It has a default action, optional path roots, limits, and per-package rules. On the developer image the limits are: at most 384 packages from outside the workspace, 16 MiB per package archive and 128 MiB or 20,000 files extracted, 256 MiB per transaction and 1 GiB extracted, and 300 seconds and 8 MiB of output per build script. Dependency depth is not limited unless configured. A rule names the package, its exact version, its source, and its checksum. Rules, an approved review, or --accept-all are the only ways to grant the two things that run code at build time:

[policy.rules.serde_derive-1_0_229]
action = "allow"
name = "serde_derive"
version = "=1.0.229"
source = "crates.io"
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
allow-proc-macro = true

[policy.rules.libc-0_2_189]
action = "allow"
name = "libc"
version = "=0.2.189"
source = "crates.io"
checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
allow-build-script = true

allow-build-script and allow-proc-macro are independent grants, required even when the default action is allow. A workspace member's own build script needs a rule with source = "path" that names the member. A build script that needs a C compiler or an archiver uses the tools declared under [native-tools."x86_64-unknown-motor"], which on the image are /devtools/bin/cc and /devtools/llvm/bin/llvm ar, and only with the build-script grant. The developer image ships grants for the common crates that the in-tree programs need (serde and its derive macro, libc, proc-macro2, quote, rustls, thiserror, and others).

Building

The package model

Supported: workspaces as in Cargo, with members, globs, exclusions, default members, and inherited package fields, dependencies, and lints; per package, one library and up to 1,024 each of binaries, examples, integration tests, and benches, found as Cargo finds them or declared explicitly; build scripts of members and dependencies; procedural macros; crates.io, Git, and path dependencies, including renamed and optional ones, default and forwarded features, and target-conditioned dependencies; crates.io patches by path or Git; lock versions 1 through 4; editions 2015 through 2024; resolvers 1 through 3; rust-version; and Rust and Clippy lints.

Not supported, by decision: alternative registries, artifact dependencies, custom JSON targets and build-std, rustc wrappers, dynamic and procedural-macro example types, clippy --fix, and running Cargo aliases. Builds never create or update Cargo.lock; lorry vendor does that, after a review. Lorry's spec.md gives the details, and its future-work.md lists the remaining differences from Cargo that may change.

Self-hosting

Lorry builds Motor OS programs on Motor OS. The developer-image test vendors and builds red, gears, and then Lorry itself natively in a VM, from the source snapshots under /devtools/src, and checks that the freshly linked build scripts carry the expected permissions. It also runs lorry test offline in /devtools/src/motor-os/sys/lib, where the image build has already admitted the Motor OS libraries staged there and compiled their dependencies. Lorry's own suite checks that Lorry built natively on Motor OS is byte-identical to Lorry cross-built on Linux. Replacing the repository's Cargo-driven build of every component with Lorry is not there yet. Lorry's future-work.md lists what remains: the kernel's custom target and its build-std needs, the imager's Linux-only dependencies, admission records for the other projects, and switching the Makefile from Cargo to Lorry.

Tests

src/bin/lorry/tests/test-all.sh runs Lorry's whole suite within a fixed time budget: the unit and integration tests offline, a dependency-resolution oracle that compares Lorry's resolution with Cargo's, contract scripts for the review format, Cargo identity, workspaces, build scripts, procedural macros, the registry protocol, and curl, and a native leg that boots a Motor OS VM and proves that the cross-built Lorry rebuilds itself there byte-identically and reuses its incremental state across two builds. The developer-image test run (src/tests/full-test-dev.sh) includes it; the main full-test.sh does not. Lorry's README, specification, design, and future-work list are under src/bin/lorry/ in the repository.