# images: the images, by name, unfinished builds last, each with what its # base started from, its digest, key, state and size; then the shared tool # images by the name images have them by, each with the C library it's # built for; then the total. Project VMs aren't images. Listing never # resolves the tools lock. env IMAGES=$XDG_DATA_HOME/devvm/images env SHARE=$XDG_DATA_HOME/devvm/tools # Nothing built: the headers, and every name not installed. exec devvm images stdout '^IMAGE +FROM +DIGEST +KEY +STATE +SIZE\n\nNAME +TOOL +VERSION +LIBC +SIZE +VMS +STATE\n' stdout '^node +- +- +- +- +- +not installed$' stdout '^opencode +- +- +- +- +- +not installed$' stderr '^images_total size=0B$' ! stderr images_unused stub_calls stdout '^limactl list --json\n\z' # base, foo on it, a build that didn't finish, and a project VM. mkdir $XDG_CONFIG_HOME/devvm/layers cp foo.sh $XDG_CONFIG_HOME/devvm/layers/foo.sh exec devvm build foo exec stub vm devvm-img-000000000000 Stopped exec stub vm devvm-proj-12345612345601 Stopped exec sh -c 'for i in base foo; do grep -lxF " \"name\": \"$i\"," "$IMAGES"/*/record.json | xargs dirname | xargs basename > "$i.key"; done' exec devvm images stdout '^base +ubuntu 26\.04 \(\d{8}\) +[0-9a-f]{12} +[0-9a-f]{12} +current +\S+\nfoo +ubuntu 26\.04 \(\d{8}\) +[0-9a-f]{12} +[0-9a-f]{12} +current +\S+\n- +- +- +000000000000 +unfinished +-\n\n' ! stdout devvm-proj # An edited script: foo is stale. exec sh -c 'echo "# edited" >> "$XDG_CONFIG_HOME/devvm/layers/foo.sh"' exec devvm images stdout '^foo +ubuntu .* +stale +\S+$' # --backend is no flag of devvm's. ! exec devvm images --backend lima stderr '^devvm: flag_unknown command=devvm images flag=--backend$' # Shared tools: each version newest first, how many VMs list it, and # whether it's the lock's; the lock's go, not built, and an older one no # VM uses. claude's built for a VM that's gone since. project ag exec devvm --tools none --agents claude --network open --no-git-protect exec devvm rm --force --no-export cd $WORK exec sh -c 'cd "$SHARE" && : > go-1.20.0-0123456789ab.erofs && : > go-1.9.0-0123456789ab.erofs' json_set $SHARE/go-1.20.0-0123456789ab.erofs.json sha256=x libc=musl backend=lima built=2020-01-01T00:00:00Z mkdir $VMS/12345612345602 exec sh -c 'printf "{\"version\": 1, \"id\": \"x\", \"name\": \"devvm-p-12345612345602\", \"image\": \"base\", \"dir\": \"/p\", \"backend\": \"lima\", \"created\": \"2020-01-01T00:00:00Z\", \"tools\": {\"names\": [\"claude\", \"go\"], \"made\": {\"libc\": \"musl\", \"files\": [\"%s\", \"go-1.20.0-0123456789ab.erofs\"]}}}\n" "$(cd "$SHARE" && ls claude-*.erofs)" > "$VMS/12345612345602/vm.json"' stub_reset exec devvm images # The lock's go isn't built; the old go has the C library its record # names, the oldest, without a record, none; claude's build says its own. stdout '^go +go +1\.27\.2 +- +- +- +not built\ngo +go +1\.20\.0 +musl +\S+ +1 +in use\ngo +go +1\.9\.0 +- +\S+ +0 +unused\n' stdout '^claude +claude +2\.1\.295 +gnu +\S+ +1 +current$' stderr '^images_total size=\S+$' stdout '^node +- ' stub_calls ! stdout mise # --json: the same as fields, sizes in bytes; the notes stay on stderr. exec devvm images --json stdout '^{\n "version": 1,\n "images": \[\n {\n "name": "base",\n "from": "ubuntu 26\.04 \(\d{8}\)",\n "digest": "sha256:[0-9a-f]{64}",\n "key": "[0-9a-f]{12}",\n "state": "current",\n "size": \d+,\n "sized": true,\n "backend": "lima"\n' stdout '^ "name": "go",\n "tool": "go",\n "version": "1\.20\.0",\n "built": true,\n "backend": "lima",\n "libc": "musl",\n "size": \d+,\n "vms": 1,\n "state": "in use"\n' stdout '^ "name": "go",\n "tool": "go",\n "version": "1\.27\.2",\n "built": false,\n "size": 0,\n "vms": 0,\n "state": "not built"\n' stdout '^ "total": \d+,\n "unused_tools": \d+,\n "nix_cache": {\n "files": 0,\n "size": 0,\n "cap": \d+\n }\n}\n\z' stderr '^images_total size=\S+$' ! stdout '^IMAGE' # images rm: by key (an unfinished build), or by name; nothing else. # A name is its image as it is now: foo is current again. cp foo.sh $XDG_CONFIG_HOME/devvm/layers/foo.sh ! exec devvm images rm 000000000000 base+foo stderr '^images_rm_confirm images=000000000000 base\+foo\ndevvm: no_input answer=--force$' exec devvm images rm --force 000000000000 base+foo stdout '^==> deleted_unfinished_build key=000000000000$' stdout '^==> deleted_image image=foo key=[0-9a-f]{12}$' exec sh -c 'grep "^limactl delete" "$STUB_LOG"' stdout '^limactl delete -f devvm-img-000000000000$' ! stdout 'devvm-proj' exec sh -c '! test -e "$IMAGES/$(cat foo.key)"' # A key no image has, a name no layer has, what isn't built and shared # tools: errors, and nothing is deleted. stub_reset ! exec devvm images rm --force fedcba987654 stderr '^devvm: unknown_layer ' ! exec devvm images rm --force base nope stderr '^devvm: unknown_layer .*layer=nope' ! exec devvm images rm --force foo stderr '^devvm: no_image_named image=foo$' ! exec devvm images rm --force node+foo stderr '^devvm: tool_not_layer tool=node$' ! exec devvm images rm --force --from node:24 base stderr '^devvm: no_image_named_from ' ! exec devvm images rm stderr '^devvm: arg_missing args=IMAGE\|KEY\.\.\. command=devvm images rm$' exec sh -c 'grep -c "^limactl delete" "$STUB_LOG" || true' stdout '^0$' exec sh -c 'test -e "$IMAGES/$(cat base.key)"' -- foo.sh -- #!/bin/bash echo foo