6 Commits
Author SHA1 Message Date
w3cjandClaude Opus 5.5 de28721978 fix(build): check base's recorded packages on the host against Ubuntu's signed archive lists
A first build of base gave back each package it downloaded with apt's
entry for it, and the host took the build VM's word that each entry was
apt's: anything with root in that VM before apt.sh end could record a
package with a made-up entry, which every later build of the key
replayed. Now the build also hands back the InRelease files and package
lists apt used, and the host checks them itself before it keeps
anything:

- each InRelease is clearsigned by Ubuntu's archive key, pinned in
  assets/layers/ubuntu-archive.gpg ("Ubuntu Archive Automatic Signing
  Key (2018)", F6ECB3762474EDA9D21B7022871920D1991BC93C, from
  keyserver.ubuntu.com by fingerprint, checked against the Ubuntu
  security team's list), and one of 26.04's suites;
- each package list has the SHA-256 and size a verified InRelease gives
  one of its Packages lists;
- each recorded .deb's SHA-256 is in one of those lists, as the package,
  version, architecture and size apt's entry says, and the set keeps
  the archive's own entry.

- internal/ubuntu/pgp.go verifies clearsigned messages (RFC 4880's
  cleartext signatures: text signatures, dash-escaping, trailing
  whitespace, nothing before or after); archive.go's VerifyRelease and
  Release.Lists read a verified InRelease (ArchiveKeyring).
- assets/layers/apt.sh: record copies apt's *_InRelease and *_Packages
  lists to out/<n>.InRelease and out/<n>.Packages; base's build keeps
  lists uncompressed (Acquire::GzipIndexes "false").
- internal/build: take accepts the lists (an InRelease at most 4 MiB and
  all of them 32 MiB, a list 512 MiB with lines of 1 MiB and entries of
  4 MiB, all lists 2 GiB, no name twice), signedEntries and
  archiveEntry check them; cache carries devvm's own files for the key.
- Tests: Ubuntu's real resolute-updates InRelease verified, and refused
  when changed, framed differently or signed by another key; clearsigned
  parsing (dashes, CR LF, trailing whitespace, a binary signature
  refused); InRelease fields; a recording refused for a forged
  InRelease, a list no InRelease gives, a .deb no signed list has,
  another package's entry, missing lists, a list or an InRelease twice,
  a line over 1 MiB; a good set kept
  with the archive's entry (gpg-made fixtures in
  internal/build/testdata/archive); apt.sh's record giving back the
  lists.
- Docs: images.md's Base's packages, design.md's trust note (the
  recording VM's made-up packages closed), settings.md's mirror
  section, maintaining.md's archive key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 14:57:10 -07:00
w3cjandClaude Opus 5.5 0941219a76 feat(build): base's packages recorded per key, replayed from a host cache
base's apt packages are no longer pinned by a snapshot. A key's first
build of base records them: assets/layers/apt.sh (a recipe step, as
root, before base.sh and after the last feature) points the image's
sources at an apt mirror+file: list of config.toml's ubuntu-mirror and
then Ubuntu's own archive, so apt checks everything against the archive
key whichever server answers, and keeps what it downloads. At the end it
gives back each package with apt's entry for it. devvm checks what comes
back (regular files only, each named by its own SHA-256, each entry
matching a file's size and SHA-256, nothing left over, at most 20,000
entries and 16 GiB), keeps the files in
~/.local/share/devvm/packages/<sha256>.deb and the key's set in
packages/sets/<key>.json, before the image's record. Every later build of
that key replays the set from the cache, checked on the host first, with
apt given only those files: no network for base's packages, and a key's
packages never change. A --from base keeps its image's own sources,
unpinned. base keeps no package lists, so each layer's recipe starts
with apt.sh lists, which fetches them when there are none.

- backend.ImageSpec.Packages (Send before the steps, Take after) and
  backend.PackagesDir; Lima runs both over limactl shell as root.
- Fail fast: apt.sh turns apt's retries off and exits 75 when no source
  answers, which Lima reports as build_sources_unreachable.
- packages_missing refuses a replay whose cached file is gone or changed;
  packages_refused what a build gives back that isn't packages.
- config.toml's ubuntu-mirror (settings.UbuntuMirror), checked as an
  http(s) address without a user, query or spaces (ubuntu_mirror_invalid).
- devvm gc deletes the sets of keys neither current nor built, then,
  under the cache's lock, the files no set names at that moment, and
  builds' leftover folders over a day old (gc_packages,
  deleted_packages); devvm space lists the cache.
- The snapshot is gone from base.sh, guest/sync.sh and desktop.sh, and
  scripts/bump.sh's apt step with it.
- Tests: recording then replaying, a missing or changed cached file,
  every refusal of what comes back, gc's view of the cache and its race
  with a new set, the set record, the mirror setting, Lima's exchange and
  exit 75, apt.sh's mirrored and record functions, apt.sh in the keys;
  the limactl stub keeps what's sent and gives back
  $STUB_DIR/packages-out.tar.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-04 11:58:23 -07:00
w3cjandClaude Opus 5.5 ddbc377f8f test: testscript commands for the scripts' setup, and a coverage baseline per package
script_test.go's sandbox sets DEVVM_MESSAGES=names and DATA, VMS, RUN
and CFG by default, and adds stub_reset, catg (the one file a glob
matches), vm_name VAR NAME (the folder's VM) and project NAME [git];
script_cmds.txtar checks each. Every script is rewritten onto them, its
assertions kept; TestCommandLines leaves the scripts' own commands out.

mise run test runs scripts/test.sh: the tests as before, with the CLI
tests' devvm built with -cover for every package (CLI_GOCOVERDIR),
merged with the Go tests' counters by go tool covdata, then
scripts/coverage.sh holds each package to testdata/coverage/<os>.txt.
mise run coverage raises the baselines; coverage.txtar checks the
comparison. The macOS baseline is recorded from this tree.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-02 14:25:09 -07:00
w3cjandClaude Opus 5.5 851e39ef86 build: embed devvm's files in its binary
devvm is one file: assets/ (base.yaml, layers/, features/,
shared-tools/, guest/, oci/, smolvm/) is embedded as assets.FS, which
cli passes to every constructor; backends, the builder, the shared
tools, the proxy and Ubuntu's key check read it as an fs.FS. Scripts
reach VMs on stdin (backend.Script carries their contents). What needs
a path (limactl create's base.yaml, oci/ mounted into the conversion
VM, the proxies' policy files) is written out to
~/.local/share/devvm/assets/<hash>, atomically, files 600 and folders
700; devvm gc deletes older copies no VM's proxy was started with
(gc_assets, deleted_assets). Release archives hold the binary with
README.md, CHANGELOG.md and LICENSE, and the formula installs the
binary alone.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 18:12:37 -06:00
w3cjandClaude Opus 5.5 9f24d2639e refactor: group devvm's files under assets/
assets/ holds the files devvm ships: base.yaml, layers/, features/,
shared-tools/ (mise.toml, build.sh, the tools' policies), guest/ and
oci/. devvm reads them from assets/ beside its binary (paths.Root,
paths.RootOf); releases, the Homebrew formula, the CLI tests and e2e
put them there. Image keys hash them by their names in assets/.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-25 17:08:33 -06:00
w3cjandClaude Opus 5.5 27905c2413 feat(build): build and rebuild images through the backend
devvm build and devvm rebuild build base and the user's layers through
Backend.BuildImage. On Lima an image is a stopped instance: base from
Ubuntu's cloud image with base.yaml, a layer a clone of its parent, each
started confined with no host mounts, its script run, then stopped. Records
are written last; an interrupted or failed build deletes its instance
through the cleanup stack. Rebuild bumps the rebuild counter and deletes
stale images no VM uses.

tests/e2e.sh starts here, with its framework and an images section.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-10-24 03:47:25 -06:00