carlos / platform Public

media: reproducible arm64 image from Debian 13 packages

cmd/mediaimage pins, builds and pushes the engine image with no container
runtime. Two builds from one lock give byte-identical layouts.

debs.lock: snapshot 20261117T000000Z, base
docker.io/library/debian@sha256:a72b4433de1cf7d6bae0c4cee74d0547f58601a643b3375f070c51600d63b6b2
(trixie-slim), 206 packages, ffmpeg 7:7.1.5-0+deb13u1.

The build moves entries onto merged /usr, makes the libblas and liblapack
links dpkg's scripts would make, and fails unless every arm64 ELF's
libraries resolve in the image. libcaca0's OpenGL plugin is left out: it
needs libraries the package does not depend on.

Push writes under a release tag, because the repository's tags are
immutable, refuses a used tag and reads the digest back.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev ca373e849cb53a53a53d37c0d7f045bd690f4195 parent 1f41eab
12 files changed, +4,421 −1
  • .gitignore +1 −0
  • Makefile +18 −1
  • cmd/mediaimage/build.go +1,001 −0
  • cmd/mediaimage/deb.go +121 −0
  • cmd/mediaimage/lock.go +597 −0
  • cmd/mediaimage/main.go +127 −0
  • cmd/mediaimage/mediaimage_test.go +1,531 −0
  • cmd/mediaimage/oci.go +454 −0
  • cmd/mediaimage/push.go +269 −0
  • deploy/media-image/README.md +69 −0
  • deploy/media-image/debs.lock +208 −0
  • docs/superpowers/notes/media-conversion-copy-deck.md +25 −0
diff --git a/.gitignore b/.gitignore
index 104b5d43f..617369df2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
/console
+/dist/
carlos
platform
*.tfstate*
diff --git a/Makefile b/Makefile
index 5eda80ea5..59eceed3a 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@ LDFLAGS := -s -w -X github.com/carlosframework/platform/internal/version.Build=$
GOOS ?=
GOARCH ?=
-.PHONY: test build build-console fmt staticcheck govulncheck census-card census-propose code-health code-health-record console-mockup-kit parity-doc
+.PHONY: test build build-console fmt staticcheck govulncheck census-card census-propose code-health code-health-record console-mockup-kit parity-doc media-image media-image-lock
# The build gate: vet, format, tests. `.amadan/ci.d/10-gate` runs this same
# target, so what CI checks and what you check are one definition.
@@ -29,6 +29,23 @@ build-console:
@test -n "$(COMMIT)" || { echo "build-console: git can't say which commit this is, so the console couldn't name it. Build from a git checkout." >&2; exit 1; }
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -trimpath -ldflags "$(LDFLAGS)" -o console ./cmd/console
+# The media engine's arm64 image (deploy/media-image/README.md). The image's
+# time is the commit's, so a commit builds the same image every time.
+MEDIA_IMAGE_LOCK := deploy/media-image/debs.lock
+MEDIA_IMAGE_CACHE ?= dist/media-image-cache
+MEDIA_IMAGE_CREATED ?= $(shell TZ=UTC git log -1 --format=%cd --date=format-local:%Y-%m-%dT%H:%M:%SZ)
+MEDIA_IMAGE_SNAPSHOT ?= $(shell date -u +%Y%m%dT000000Z)
+MEDIA_IMAGE_BASE ?= $(shell sed -n 's/^\# base //p' $(MEDIA_IMAGE_LOCK))
+
+media-image:
+ CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -trimpath -buildvcs=false -ldflags "$(LDFLAGS)" -o dist/carlos-media ./cmd/carlos-media
+ GOOS= GOARCH= go run ./cmd/mediaimage build --lock $(MEDIA_IMAGE_LOCK) --binary dist/carlos-media --created $(MEDIA_IMAGE_CREATED) --cache $(MEDIA_IMAGE_CACHE) --out dist/media-image
+
+# Pins the newest packages at today's snapshot, on the base the lock already
+# names. MEDIA_IMAGE_BASE=docker.io/library/debian@sha256:... moves the base.
+media-image-lock:
+ GOOS= GOARCH= go run ./cmd/mediaimage lock --snapshot $(MEDIA_IMAGE_SNAPSHOT) --base $(MEDIA_IMAGE_BASE) --cache $(MEDIA_IMAGE_CACHE) --out $(MEDIA_IMAGE_LOCK)
+
fmt:
gofmt -w .
diff --git a/cmd/mediaimage/build.go b/cmd/mediaimage/build.go
new file mode 100644
index 000000000..0db45805f
--- /dev/null
+++ b/cmd/mediaimage/build.go
@@ -0,0 +1,1001 @@
+package main
+
+import (
+ "archive/tar"
+ "bytes"
+ "compress/gzip"
+ "context"
+ "crypto/sha256"
+ "debug/elf"
+ "encoding/hex"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io"
+ "maps"
+ "os"
+ "path"
+ "path/filepath"
+ "slices"
+ "strings"
+ "sync"
+ "time"
+
+ "github.com/carlosframework/platform/internal/media"
+)
+
+var (
+ // errBadEntry is a package entry an image layer must not carry.
+ errBadEntry = errors.New("refused package entry")
+ // errConflict is two sources disagreeing about one path.
+ errConflict = errors.New("conflicting paths")
+ // errUnresolvedLibrary is an ELF whose library the image does not hold.
+ errUnresolvedLibrary = errors.New("unresolved library")
+ // errMissingExecutable is a program the engine runs that the image
+ // does not hold for arm64.
+ errMissingExecutable = errors.New("missing executable")
+)
+
+const (
+ scratchPath = "scratch"
+ // scratchID is the numeric user and group the engine runs as.
+ scratchID = 65534
+ imageUser = "65534:65534"
+ downloadsAtOnce = 4
+
+ labelCreated = "org.opencontainers.image.created"
+ labelFFmpeg = "io.carlosframework.ffmpeg"
+ labelDebsLock = "io.carlosframework.debs-lock"
+)
+
+// libraryDirs is the arm64 loader's default search path on Debian.
+var libraryDirs = []string{"lib/aarch64-linux-gnu", "usr/lib/aarch64-linux-gnu", "lib", "usr/lib"}
+
+// requiredExecutables are the programs the engine starts.
+var requiredExecutables = []string{"usr/bin/ffmpeg", "usr/bin/ffprobe", strings.TrimPrefix(media.EngineEntryPoint, "/")}
+
+// alternativeLinks are the library links Debian's maintainer scripts make
+// with update-alternatives, which never run here. A package in the lock
+// whose libraries are reached this way needs its row; the library check
+// fails the build when one is missing.
+var alternativeLinks = []struct{ pkg, link, target string }{
+ {"libblas3", "usr/lib/aarch64-linux-gnu/libblas.so.3", "blas/libblas.so.3"},
+ {"liblapack3", "usr/lib/aarch64-linux-gnu/liblapack.so.3", "lapack/liblapack.so.3"},
+}
+
+// unloadableFiles are left out of the image. libcaca0 ships an optional
+// OpenGL display plugin that needs libGLU and libglut, which it does not
+// depend on, so the plugin could never load here. Leaving it out keeps the
+// library check free of exceptions.
+var unloadableFiles = map[string]bool{
+ "usr/lib/aarch64-linux-gnu/caca/libgl_plugin.so": true,
+ "usr/lib/aarch64-linux-gnu/caca/libgl_plugin.so.0": true,
+ "usr/lib/aarch64-linux-gnu/caca/libgl_plugin.so.0.0.0": true,
+}
+
+// buildOptions are the build command's flags.
+type buildOptions struct {
+ Lock, Binary, Created, Out, Cache string
+}
+
+// buildImage assembles the OCI layout and returns what image.json records.
+func buildImage(ctx context.Context, o buildOptions) (media.ImageInfo, error) {
+ lockData, err := os.ReadFile(o.Lock)
+ if err != nil {
+ return media.ImageInfo{}, err
+ }
+ lock, err := parseLock(lockData)
+ if err != nil {
+ return media.ImageInfo{}, err
+ }
+ ffmpeg, ok := lock.version(lockRoot)
+ if !ok {
+ return media.ImageInfo{}, fmt.Errorf("%w: no %s package", errBadLock, lockRoot)
+ }
+ created, err := time.Parse(time.RFC3339, o.Created)
+ if err != nil {
+ return media.ImageInfo{}, fmt.Errorf("--created: %w", err)
+ }
+ created = created.UTC().Truncate(time.Second)
+ if o.Out == "" || o.Binary == "" || o.Cache == "" {
+ return media.ImageInfo{}, errors.New("--out, --binary and --cache are required")
+ }
+ ref, err := parseImageRef(lock.Base)
+ if err != nil {
+ return media.ImageInfo{}, err
+ }
+ store, err := openStore(o.Cache)
+ if err != nil {
+ return media.ImageInfo{}, err
+ }
+ base, err := loadBase(ctx, store, ref)
+ if err != nil {
+ return media.ImageInfo{}, err
+ }
+ if err := fetchDebs(ctx, store, lock.Entries); err != nil {
+ return media.ImageInfo{}, err
+ }
+
+ if err := os.MkdirAll(filepath.Dir(o.Out), 0o755); err != nil {
+ return media.ImageInfo{}, err
+ }
+ work, err := os.MkdirTemp(filepath.Dir(o.Out), ".media-image-work-")
+ if err != nil {
+ return media.ImageInfo{}, err
+ }
+ defer os.RemoveAll(work)
+ layout := filepath.Join(work, "layout")
+ spool := filepath.Join(work, "spool")
+ for _, dir := range []string{filepath.Join(layout, "blobs", "sha256"), spool} {
+ if err := os.MkdirAll(dir, 0o755); err != nil {
+ return media.ImageInfo{}, err
+ }
+ }
+
+ root := newTree()
+ var layers []ociDescriptor
+ diffIDs := slices.Clone(base.Config.RootFS.DiffIDs)
+ for _, layer := range base.Manifest.Layers {
+ if err := scanLayerBlob(store.path(layer.Digest), root); err != nil {
+ return media.ImageInfo{}, fmt.Errorf("base layer %s: %w", layer.Digest, err)
+ }
+ if err := copyFile(store.path(layer.Digest), filepath.Join(layout, "blobs", "sha256", strings.TrimPrefix(layer.Digest, "sha256:"))); err != nil {
+ return media.ImageInfo{}, err
+ }
+ layers = append(layers, ociDescriptor{MediaType: mediaTypeOCILayer, Digest: layer.Digest, Size: layer.Size})
+ }
+
+ plan, err := planDebs(ctx, store, lock, root, spool)
+ if err != nil {
+ return media.ImageInfo{}, err
+ }
+ top, err := planTopLayer(o.Binary, root, spool)
+ if err != nil {
+ return media.ImageInfo{}, err
+ }
+ for _, items := range [][]layerItem{plan, top} {
+ desc, diffID, err := writeLayer(layout, spool, items, created)
+ if err != nil {
+ return media.ImageInfo{}, err
+ }
+ if err := scanLayerBlob(filepath.Join(layout, "blobs", "sha256", strings.TrimPrefix(desc.Digest, "sha256:")), root); err != nil {
+ return media.ImageInfo{}, err
+ }
+ layers = append(layers, desc)
+ diffIDs = append(diffIDs, diffID)
+ }
+ if err := checkImage(root); err != nil {
+ return media.ImageInfo{}, err
+ }
+
+ stamp := created.Format(time.RFC3339)
+ config := ociConfig{
+ Created: stamp, Architecture: "arm64", OS: "linux",
+ Config: ociImageConfig{
+ User: imageUser,
+ Env: base.Config.Config.Env,
+ Entrypoint: []string{media.EngineEntryPoint},
+ Volumes: map[string]struct{}{"/" + scratchPath: {}},
+ Labels: map[string]string{
+ labelCreated: stamp,
+ labelFFmpeg: ffmpeg,
+ labelDebsLock: hex.EncodeToString(sha256Sum(lockData)),
+ },
+ },
+ RootFS: ociRootFS{Type: "layers", DiffIDs: diffIDs},
+ }
+ info, err := writeLayout(layout, config, layers, stamp, ffmpeg)
+ if err != nil {
+ return media.ImageInfo{}, err
+ }
+ if err := publishLayout(layout, o.Out); err != nil {
+ return media.ImageInfo{}, err
+ }
+ return info, nil
+}
+
+func sha256Sum(data []byte) []byte {
+ sum := sha256.Sum256(data)
+ return sum[:]
+}
+
+// fetchDebs makes every locked package present and verified.
+func fetchDebs(ctx context.Context, store blobStore, entries []lockEntry) error {
+ ctx, cancel := context.WithCancel(ctx)
+ defer cancel()
+ errs := make([]error, len(entries))
+ slots := make(chan struct{}, downloadsAtOnce)
+ var wg sync.WaitGroup
+ for i, e := range entries {
+ wg.Add(1)
+ slots <- struct{}{}
+ go func() {
+ defer wg.Done()
+ defer func() { <-slots }()
+ err := store.ensure(ctx, e.SHA256, e.Size, func(ctx context.Context) (io.ReadCloser, error) {
+ return httpGet(ctx, e.URL)
+ })
+ if err != nil {
+ errs[i] = fmt.Errorf("%s: %w", e.Package, err)
+ cancel()
+ }
+ }()
+ }
+ wg.Wait()
+ for _, err := range errs {
+ if err != nil && !errors.Is(err, context.Canceled) {
+ return err
+ }
+ }
+ return errors.Join(errs...)
+}
+
+// writeLayout writes the config, manifest, index and image.json.
+func writeLayout(layout string, config ociConfig, layers []ociDescriptor, stamp, ffmpeg string) (media.ImageInfo, error) {
+ configData, err := json.Marshal(config)
+ if err != nil {
+ return media.ImageInfo{}, err
+ }
+ configDesc, err := writeBlob(layout, mediaTypeOCIConfig, configData)
+ if err != nil {
+ return media.ImageInfo{}, err
+ }
+ manifestData, err := json.Marshal(ociManifest{SchemaVersion: 2, MediaType: mediaTypeOCIManifest, Config: configDesc, Layers: layers})
+ if err != nil {
+ return media.ImageInfo{}, err
+ }
+ manifestDesc, err := writeBlob(layout, mediaTypeOCIManifest, manifestData)
+ if err != nil {
+ return media.ImageInfo{}, err
+ }
+ manifestDesc.Platform = &ociPlatform{Architecture: "arm64", OS: "linux"}
+ indexData, err := json.Marshal(ociIndex{SchemaVersion: 2, MediaType: mediaTypeOCIIndex, Manifests: []ociDescriptor{manifestDesc}})
+ if err != nil {
+ return media.ImageInfo{}, err
+ }
+ info := media.ImageInfo{Digest: manifestDesc.Digest, BuiltAt: stamp, FFmpeg: ffmpeg}
+ infoData, err := json.Marshal(info)
+ if err != nil {
+ return media.ImageInfo{}, err
+ }
+ for name, data := range map[string][]byte{
+ "index.json": indexData,
+ "oci-layout": []byte(`{"imageLayoutVersion":"1.0.0"}`),
+ "image.json": append(infoData, '\n'),
+ } {
+ if err := os.WriteFile(filepath.Join(layout, name), data, 0o644); err != nil {
+ return media.ImageInfo{}, err
+ }
+ }
+ return info, nil
+}
+
+func writeBlob(layout, mediaType string, data []byte) (ociDescriptor, error) {
+ digest := digestBytes(data)
+ path := filepath.Join(layout, "blobs", "sha256", strings.TrimPrefix(digest, "sha256:"))
+ if err := os.WriteFile(path, data, 0o644); err != nil {
+ return ociDescriptor{}, err
+ }
+ return ociDescriptor{MediaType: mediaType, Digest: digest, Size: int64(len(data))}, nil
+}
+
+// publishLayout moves the finished layout to out, replacing an earlier
+// layout but never a directory that is something else.
+func publishLayout(layout, out string) error {
+ if _, err := os.Stat(out); err == nil {
+ if _, err := os.Stat(filepath.Join(out, "oci-layout")); err != nil {
+ return fmt.Errorf("%s exists and is not an image layout", out)
+ }
+ if err := os.RemoveAll(out); err != nil {
+ return err
+ }
+ }
+ return os.Rename(layout, out)
+}
+
+func copyFile(from, to string) error {
+ in, err := os.Open(from)
+ if err != nil {
+ return err
+ }
+ defer in.Close()
+ out, err := os.OpenFile(to, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0o644)
+ if err != nil {
+ return err
+ }
+ if _, err := io.Copy(out, in); err != nil {
+ out.Close()
+ return err
+ }
+ return out.Close()
+}
+
+// layerItem is one entry of a layer this tool writes.
+type layerItem struct {
+ path string
+ typ byte
+ mode int64
+ uid, gid int
+ link string
+ size int64
+ sum string // spool file of a regular file
+}
+
+// tarName is the entry's name in the layer; a directory ends in a slash.
+func (i layerItem) tarName() string {
+ if i.typ == tar.TypeDir {
+ return i.path + "/"
+ }
+ return i.path
+}
+
+// spoolFile copies r into the spool under its sha256.
+func spoolFile(spool string, r io.Reader) (sum string, size int64, err error) {
+ tmp, err := os.CreateTemp(spool, ".in-*")
+ if err != nil {
+ return "", 0, err
+ }
+ defer os.Remove(tmp.Name())
+ defer tmp.Close()
+ h := sha256.New()
+ size, err = io.Copy(io.MultiWriter(tmp, h), r)
+ if err != nil {
+ return "", 0, err
+ }
+ if err := tmp.Close(); err != nil {
+ return "", 0, err
+ }
+ sum = hex.EncodeToString(h.Sum(nil))
+ return sum, size, os.Rename(tmp.Name(), filepath.Join(spool, sum))
+}
+
+// mergedRoot reports whether a top-level name lives under /usr on a
+// merged-/usr system.
+func mergedRoot(name string) bool {
+ return name == "bin" || name == "sbin" || strings.HasPrefix(name, "lib")
+}
+
+// underUsr rewrites a clean relative path onto merged /usr.
+func underUsr(p string) string {
+ first, _, _ := strings.Cut(p, "/")
+ if mergedRoot(first) {
+ return "usr/" + p
+ }
+ return p
+}
+
+// cleanEntry validates a package entry's name and returns its path in the
+// image. The package's root directory returns "". An absolute name fails
+// on its empty first component.
+func cleanEntry(name string) (string, error) {
+ p := strings.TrimSuffix(strings.TrimPrefix(name, "./"), "/")
+ if p == "" || p == "." {
+ return "", nil
+ }
+ for _, part := range strings.Split(p, "/") {
+ if part == "" || part == "." || part == ".." {
+ return "", fmt.Errorf("%w: %s leaves the root", errBadEntry, name)
+ }
+ if strings.HasPrefix(part, ".wh.") {
+ return "", fmt.Errorf("%w: %s would delete files from a lower layer", errBadEntry, name)
+ }
+ }
+ return underUsr(p), nil
+}
+
+// relativeTo returns target as a path relative to the directory dir.
+func relativeTo(dir, target string) string {
+ from, to := strings.Split(dir, "/"), strings.Split(target, "/")
+ if dir == "." || dir == "" {
+ from = nil
+ }
+ i := 0
+ for i < len(from) && i < len(to) && from[i] == to[i] {
+ i++
+ }
+ parts := make([]string, 0, len(from)-i+len(to)-i)
+ for range from[i:] {
+ parts = append(parts, "..")
+ }
+ return path.Join(append(parts, to[i:]...)...)
+}
+
+// rewriteLink keeps a symlink true after its entry moved from original to
+// moved. drop is true for a link that names its own merged path: the alias
+// /bin/x -> /usr/bin/x is the file itself on merged /usr.
+func rewriteLink(original, moved, link string) (target string, drop bool) {
+ // Rooting the join first stops a link that climbs past / at /, as the
+ // kernel does.
+ resolved := path.Join("/", path.Dir(original), link)
+ if strings.HasPrefix(link, "/") {
+ resolved = path.Clean(link)
+ }
+ canonical := underUsr(strings.TrimPrefix(resolved, "/"))
+ if canonical == moved {
+ return "", true
+ }
+ if strings.HasPrefix(link, "/") || original == moved {
+ return link, false
+ }
+ return relativeTo(path.Dir(moved), canonical), false
+}
+
+// debPlan collects the package layer's entries by path.
+type debPlan struct {
+ entries map[string]layerItem
+ spool string
+}
+
+// add records an entry; two sources must agree about a path. A directory
+// and a symlink at one path resolve to the symlink, as dpkg leaves them.
+func (p *debPlan) add(item layerItem) error {
+ old, ok := p.entries[item.path]
+ if !ok {
+ p.entries[item.path] = item
+ return nil
+ }
+ switch {
+ case old.typ == tar.TypeDir && item.typ == tar.TypeDir:
+ case old.typ == tar.TypeSymlink && item.typ == tar.TypeDir:
+ case old.typ == tar.TypeDir && item.typ == tar.TypeSymlink:
+ p.entries[item.path] = item
+ case old.typ == tar.TypeReg && item.typ == tar.TypeReg && old.sum == item.sum:
+ case old.typ == tar.TypeSymlink && item.typ == tar.TypeSymlink && old.link == item.link:
+ default:
+ return fmt.Errorf("%w: two packages ship different %s", errConflict, item.path)
+ }
+ return nil
+}
+
+// addDeb reads one package's data tar into the plan.
+func (p *debPlan) addDeb(ctx context.Context, file, pkg string) error {
+ f, err := os.Open(file)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+ data, err := readDeb(ctx, f)
+ if err != nil {
+ return fmt.Errorf("%s: %w", pkg, err)
+ }
+ defer data.Close()
+ regular := map[string]layerItem{}
+ r := tar.NewReader(data)
+ for {
+ h, err := r.Next()
+ if errors.Is(err, io.EOF) {
+ break
+ }
+ if err != nil {
+ return fmt.Errorf("%s: %w", pkg, err)
+ }
+ item, err := p.readEntry(h, r, regular)
+ if err != nil {
+ return fmt.Errorf("%s: %w", pkg, err)
+ }
+ if item == nil {
+ continue
+ }
+ if item.typ == tar.TypeReg {
+ regular[item.path] = *item
+ }
+ if err := p.add(*item); err != nil {
+ return fmt.Errorf("%s: %w", pkg, err)
+ }
+ }
+ // Reading to the end surfaces a decompressor that failed late.
+ if _, err := io.Copy(io.Discard, data); err != nil {
+ return fmt.Errorf("%s: %w", pkg, err)
+ }
+ return nil
+}
+
+// readEntry turns a tar entry into a layer item; nil means it adds nothing.
+func (p *debPlan) readEntry(h *tar.Header, r io.Reader, regular map[string]layerItem) (*layerItem, error) {
+ clean, err := cleanEntry(h.Name)
+ if err != nil || clean == "" || unloadableFiles[clean] {
+ return nil, err
+ }
+ item := layerItem{path: clean, typ: h.Typeflag, mode: h.Mode & 0o7777}
+ switch h.Typeflag {
+ case tar.TypeDir:
+ case tar.TypeReg:
+ if item.sum, item.size, err = spoolFile(p.spool, r); err != nil {
+ return nil, err
+ }
+ case tar.TypeSymlink:
+ original := strings.TrimSuffix(strings.TrimPrefix(h.Name, "./"), "/")
+ target, drop := rewriteLink(original, clean, h.Linkname)
+ if drop {
+ return nil, nil
+ }
+ item.link = target
+ case tar.TypeLink:
+ // A layer sorted by path cannot promise a hard link's target comes
+ // first, so the link becomes a copy.
+ target, err := cleanEntry(h.Linkname)
+ if err != nil {
+ return nil, err
+ }
+ source, ok := regular[target]
+ if !ok {
+ return nil, fmt.Errorf("%w: hard link %s has no target in its package", errBadEntry, h.Name)
+ }
+ item.typ, item.sum, item.size = tar.TypeReg, source.sum, source.size
+ default:
+ return nil, fmt.Errorf("%w: %s is not a file, directory or link", errBadEntry, h.Name)
+ }
+ return &item, nil
+}
+
+// lookup views the base tree with the plan on top.
+func (p *debPlan) lookup(root *tree) func(string) *node {
+ return func(name string) *node {
+ lower := root.nodes[name]
+ item, ok := p.entries[name]
+ if ok && item.typ == tar.TypeDir && lower != nil && lower.kind == kindLink {
+ return lower // settle drops this directory; the base's symlink stays
+ }
+ if ok {
+ switch item.typ {
+ case tar.TypeSymlink:
+ return &node{kind: kindLink, link: item.link}
+ case tar.TypeDir:
+ return &node{kind: kindDir}
+ }
+ return &node{kind: kindFile}
+ }
+ return lower
+ }
+}
+
+// settle fits the plan onto the base: entries follow symlinked parents,
+// directories that already exist are left to the base (so no directory
+// entry ever covers a base symlink), and a file never replaces a directory.
+func (p *debPlan) settle(root *tree) error {
+ names := make([]string, 0, len(p.entries))
+ for name := range p.entries {
+ names = append(names, name)
+ }
+ slices.Sort(names)
+ for _, name := range names {
+ item, ok := p.entries[name]
+ if !ok {
+ continue
+ }
+ moved := path.Join(resolvePath(p.lookup(root), path.Dir(name), true), path.Base(name))
+ if moved != name {
+ delete(p.entries, name)
+ item.path = moved
+ if err := p.add(item); err != nil {
+ return err
+ }
+ }
+ }
+ for name, item := range p.entries {
+ lower := root.nodes[name]
+ if lower == nil {
+ continue
+ }
+ switch {
+ case item.typ == tar.TypeDir && lower.kind != kindFile:
+ delete(p.entries, name)
+ case item.typ == tar.TypeDir:
+ return fmt.Errorf("%w: a package directory %s covers a base file", errConflict, name)
+ case lower.kind == kindDir:
+ return fmt.Errorf("%w: a package entry %s covers a base directory", errConflict, name)
+ }
+ }
+ return nil
+}
+
+// addParents adds any parent directory neither the items nor the tree hold.
+func addParents(items map[string]layerItem, root *tree) {
+ for _, name := range slices.Collect(maps.Keys(items)) {
+ for dir := path.Dir(name); dir != "."; dir = path.Dir(dir) {
+ if _, ok := items[dir]; ok || root.nodes[dir] != nil {
+ continue
+ }
+ items[dir] = layerItem{path: dir, typ: tar.TypeDir, mode: 0o755}
+ }
+ }
+}
+
+// sortedItems orders a layer by entry name.
+func sortedItems(items map[string]layerItem) []layerItem {
+ out := make([]layerItem, 0, len(items))
+ for _, item := range items {
+ out = append(out, item)
+ }
+ slices.SortFunc(out, func(a, b layerItem) int { return strings.Compare(a.tarName(), b.tarName()) })
+ return out
+}
+
+// planDebs builds the package layer's entries from every locked package.
+func planDebs(ctx context.Context, store blobStore, lock lockFile, root *tree, spool string) ([]layerItem, error) {
+ plan := &debPlan{entries: map[string]layerItem{}, spool: spool}
+ for _, e := range lock.Entries {
+ if err := plan.addDeb(ctx, store.path(e.SHA256), e.Package); err != nil {
+ return nil, err
+ }
+ }
+ for _, alt := range alternativeLinks {
+ if _, ok := lock.version(alt.pkg); !ok {
+ continue
+ }
+ target := path.Join(path.Dir(alt.link), alt.target)
+ if item, ok := plan.entries[target]; !ok || item.typ == tar.TypeDir {
+ return nil, fmt.Errorf("%w: %s no longer ships %s", errUnresolvedLibrary, alt.pkg, target)
+ }
+ if err := plan.add(layerItem{path: alt.link, typ: tar.TypeSymlink, mode: 0o777, link: alt.target}); err != nil {
+ return nil, err
+ }
+ }
+ if err := plan.settle(root); err != nil {
+ return nil, err
+ }
+ addParents(plan.entries, root)
+ return sortedItems(plan.entries), nil
+}
+
+// planTopLayer is the binary and the scratch directory the engine writes to.
+func planTopLayer(binary string, root *tree, spool string) ([]layerItem, error) {
+ f, err := os.Open(binary)
+ if err != nil {
+ return nil, err
+ }
+ defer f.Close()
+ sum, size, err := spoolFile(spool, f)
+ if err != nil {
+ return nil, err
+ }
+ entry := strings.TrimPrefix(media.EngineEntryPoint, "/")
+ items := map[string]layerItem{
+ entry: {path: entry, typ: tar.TypeReg, mode: 0o755, sum: sum, size: size},
+ scratchPath: {path: scratchPath, typ: tar.TypeDir, mode: 0o700, uid: scratchID, gid: scratchID},
+ }
+ addParents(items, root)
+ return sortedItems(items), nil
+}
+
+// writeLayer writes a reproducible gzip tar blob: fixed owners and times,
+// no names, no extended records.
+func writeLayer(layout, spool string, items []layerItem, created time.Time) (ociDescriptor, string, error) {
+ dir := filepath.Join(layout, "blobs", "sha256")
+ tmp, err := os.CreateTemp(dir, ".layer-*")
+ if err != nil {
+ return ociDescriptor{}, "", err
+ }
+ defer os.Remove(tmp.Name())
+ defer tmp.Close()
+ blobHash, diffHash := sha256.New(), sha256.New()
+ counted := &countingWriter{w: io.MultiWriter(tmp, blobHash)}
+ gz, err := gzip.NewWriterLevel(counted, gzip.BestCompression)
+ if err != nil {
+ return ociDescriptor{}, "", err
+ }
+ w := tar.NewWriter(io.MultiWriter(gz, diffHash))
+ for _, item := range items {
+ if err := writeItem(w, spool, item, created); err != nil {
+ return ociDescriptor{}, "", fmt.Errorf("%s: %w", item.path, err)
+ }
+ }
+ if err := w.Close(); err != nil {
+ return ociDescriptor{}, "", err
+ }
+ if err := gz.Close(); err != nil {
+ return ociDescriptor{}, "", err
+ }
+ if err := tmp.Chmod(0o644); err != nil {
+ return ociDescriptor{}, "", err
+ }
+ if err := tmp.Close(); err != nil {
+ return ociDescriptor{}, "", err
+ }
+ sum := hex.EncodeToString(blobHash.Sum(nil))
+ if err := os.Rename(tmp.Name(), filepath.Join(dir, sum)); err != nil {
+ return ociDescriptor{}, "", err
+ }
+ desc := ociDescriptor{MediaType: mediaTypeOCILayer, Digest: "sha256:" + sum, Size: counted.n}
+ return desc, "sha256:" + hex.EncodeToString(diffHash.Sum(nil)), nil
+}
+
+type countingWriter struct {
+ w io.Writer
+ n int64
+}
+
+func (c *countingWriter) Write(p []byte) (int, error) {
+ n, err := c.w.Write(p)
+ c.n += int64(n)
+ return n, err
+}
+
+func writeItem(w *tar.Writer, spool string, item layerItem, created time.Time) error {
+ h := &tar.Header{
+ Name: item.tarName(), Typeflag: item.typ, Mode: item.mode, Linkname: item.link,
+ Uid: item.uid, Gid: item.gid, Size: item.size, ModTime: created, Format: tar.FormatPAX,
+ }
+ if err := w.WriteHeader(h); err != nil {
+ return err
+ }
+ if item.typ != tar.TypeReg {
+ return nil
+ }
+ f, err := os.Open(filepath.Join(spool, item.sum))
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+ _, err = io.Copy(w, f)
+ return err
+}
+
+type nodeKind int
+
+const (
+ kindFile nodeKind = iota
+ kindDir
+ kindLink
+)
+
+// elfInfo is what the library check needs from an ELF file.
+type elfInfo struct {
+ machine elf.Machine
+ needed, rpath, runpath []string
+}
+
+// node is one path of the layered image.
+type node struct {
+ kind nodeKind
+ link string
+ elf *elfInfo
+}
+
+// tree is the image's file system as its layers build it up.
+type tree struct{ nodes map[string]*node }
+
+func newTree() *tree { return &tree{nodes: map[string]*node{}} }
+
+// resolvePath walks p through symlinks and returns the path it names. A
+// walk that never ends returns p unchanged.
+func resolvePath(lookup func(string) *node, p string, followLast bool) string {
+ pending := strings.Split(p, "/")
+ current := ""
+ for hops := 0; len(pending) > 0; {
+ part := pending[0]
+ pending = pending[1:]
+ switch part {
+ case "", ".":
+ continue
+ case "..":
+ if current = path.Dir(current); current == "." {
+ current = ""
+ }
+ continue
+ }
+ next := path.Join(current, part)
+ n := lookup(next)
+ if n == nil || n.kind != kindLink || (len(pending) == 0 && !followLast) {
+ current = next
+ continue
+ }
+ if hops++; hops > 40 {
+ return p
+ }
+ if strings.HasPrefix(n.link, "/") {
+ current = ""
+ }
+ pending = append(strings.Split(n.link, "/"), pending...)
+ }
+ return current
+}
+
+func (t *tree) lookup(name string) *node { return t.nodes[name] }
+
+// put places a node, removing whatever a directory it replaces held.
+func (t *tree) put(name string, n *node) {
+ if old := t.nodes[name]; old != nil && old.kind == kindDir && n.kind != kindDir {
+ t.removeChildren(name)
+ }
+ t.nodes[name] = n
+}
+
+func (t *tree) removeChildren(name string) {
+ prefix := name + "/"
+ for child := range t.nodes {
+ if strings.HasPrefix(child, prefix) {
+ delete(t.nodes, child)
+ }
+ }
+}
+
+// scanLayerBlob applies a gzip layer to the tree.
+func scanLayerBlob(file string, t *tree) error {
+ f, err := os.Open(file)
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+ gz, err := gzip.NewReader(f)
+ if err != nil {
+ return err
+ }
+ defer gz.Close()
+ return scanLayer(gz, t)
+}
+
+// scanLayer applies one layer: its whiteouts first, as they only ever hide
+// what lower layers hold, then its entries.
+func scanLayer(r io.Reader, t *tree) error {
+ type entry struct {
+ name, hardlink string
+ node *node
+ }
+ var entries []entry
+ var whiteouts []string
+ tr := tar.NewReader(r)
+ for {
+ h, err := tr.Next()
+ if errors.Is(err, io.EOF) {
+ break
+ }
+ if err != nil {
+ return err
+ }
+ name := strings.TrimSuffix(strings.TrimPrefix(h.Name, "./"), "/")
+ if name == "" || name == "." {
+ continue
+ }
+ if strings.HasPrefix(path.Base(name), ".wh.") {
+ whiteouts = append(whiteouts, name)
+ continue
+ }
+ e := entry{name: name}
+ switch h.Typeflag {
+ case tar.TypeDir:
+ e.node = &node{kind: kindDir}
+ case tar.TypeSymlink:
+ e.node = &node{kind: kindLink, link: h.Linkname}
+ case tar.TypeLink:
+ e.hardlink = strings.TrimSuffix(strings.TrimPrefix(h.Linkname, "./"), "/")
+ case tar.TypeReg:
+ info, err := readELF(tr)
+ if err != nil {
+ return fmt.Errorf("%s: %w", name, err)
+ }
+ e.node = &node{kind: kindFile, elf: info}
+ default:
+ e.node = &node{kind: kindFile}
+ }
+ entries = append(entries, e)
+ }
+ for _, name := range whiteouts {
+ dir, base := path.Dir(name), path.Base(name)
+ if dir == "." {
+ dir = ""
+ }
+ if base == ".wh..wh..opq" {
+ if dir == "" {
+ t.nodes = map[string]*node{}
+ } else {
+ t.removeChildren(dir)
+ }
+ continue
+ }
+ hidden := path.Join(dir, strings.TrimPrefix(base, ".wh."))
+ t.removeChildren(hidden)
+ delete(t.nodes, hidden)
+ }
+ for _, e := range entries {
+ n := e.node
+ if e.hardlink != "" {
+ if n = t.nodes[e.hardlink]; n == nil {
+ return fmt.Errorf("%s: hard link to a missing file", e.name)
+ }
+ }
+ parent := resolvePath(t.lookup, path.Dir(e.name), true)
+ t.put(path.Join(parent, path.Base(e.name)), n)
+ }
+ return nil
+}
+
+// readELF parses a file that starts with the ELF magic; anything else, and
+// a file debug/elf cannot read, is plain data.
+func readELF(r io.Reader) (*elfInfo, error) {
+ var magic [4]byte
+ if _, err := io.ReadFull(r, magic[:]); err != nil {
+ if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) {
+ return nil, nil
+ }
+ return nil, err
+ }
+ if string(magic[:]) != elf.ELFMAG {
+ return nil, nil
+ }
+ rest, err := io.ReadAll(r)
+ if err != nil {
+ return nil, err
+ }
+ f, err := elf.NewFile(bytes.NewReader(append(magic[:], rest...)))
+ if err != nil {
+ return nil, nil
+ }
+ defer f.Close()
+ if f.Class != elf.ELFCLASS64 || (f.Type != elf.ET_EXEC && f.Type != elf.ET_DYN) {
+ return nil, nil
+ }
+ info := &elfInfo{machine: f.Machine}
+ if info.needed, err = f.DynString(elf.DT_NEEDED); err != nil {
+ return nil, nil
+ }
+ rpath, _ := f.DynString(elf.DT_RPATH)
+ runpath, _ := f.DynString(elf.DT_RUNPATH)
+ info.rpath = splitSearchPath(rpath)
+ info.runpath = splitSearchPath(runpath)
+ return info, nil
+}
+
+func splitSearchPath(values []string) []string {
+ var out []string
+ for _, v := range values {
+ out = append(out, strings.Split(v, ":")...)
+ }
+ return out
+}
+
+// isArm64 reports whether a resolved path is an arm64 ELF file.
+func (t *tree) isArm64(name string) bool {
+ n := t.nodes[resolvePath(t.lookup, name, true)]
+ return n != nil && n.kind == kindFile && n.elf != nil && n.elf.machine == elf.EM_AARCH64
+}
+
+// findLibrary searches for a DT_NEEDED name as the arm64 loader would.
+func (t *tree) findLibrary(owner string, info *elfInfo, lib string) bool {
+ if strings.Contains(lib, "/") {
+ return t.isArm64(strings.TrimPrefix(lib, "/"))
+ }
+ var dirs []string
+ if len(info.runpath) == 0 {
+ dirs = append(dirs, info.rpath...)
+ }
+ dirs = append(dirs, info.runpath...)
+ for _, dir := range dirs {
+ dir = strings.NewReplacer("${ORIGIN}", "/"+path.Dir(owner), "$ORIGIN", "/"+path.Dir(owner)).Replace(dir)
+ if strings.HasPrefix(dir, "/") && t.isArm64(path.Join(dir[1:], lib)) {
+ return true
+ }
+ }
+ for _, dir := range libraryDirs {
+ if t.isArm64(path.Join(dir, lib)) {
+ return true
+ }
+ }
+ return false
+}
+
+// checkImage fails unless the engine's programs are present for arm64 and
+// every arm64 ELF's libraries resolve inside the image.
+func checkImage(t *tree) error {
+ for _, name := range requiredExecutables {
+ if !t.isArm64(name) {
+ return fmt.Errorf("%w: /%s is not an arm64 program", errMissingExecutable, name)
+ }
+ }
+ var missing []string
+ for name, n := range t.nodes {
+ if n.kind != kindFile || n.elf == nil || n.elf.machine != elf.EM_AARCH64 {
+ continue
+ }
+ for _, lib := range n.elf.needed {
+ if !t.findLibrary(name, n.elf, lib) {
+ missing = append(missing, "/"+name+" needs "+lib)
+ }
+ }
+ }
+ if len(missing) > 0 {
+ slices.Sort(missing)
+ return fmt.Errorf("%w: %s", errUnresolvedLibrary, strings.Join(missing, "; "))
+ }
+ return nil
+}
diff --git a/cmd/mediaimage/deb.go b/cmd/mediaimage/deb.go
new file mode 100644
index 000000000..debb9924f
--- /dev/null
+++ b/cmd/mediaimage/deb.go
@@ -0,0 +1,121 @@
+package main
+
+import (
+ "bytes"
+ "compress/gzip"
+ "context"
+ "errors"
+ "fmt"
+ "io"
+ "os/exec"
+ "strconv"
+ "strings"
+)
+
+// errBadDeb is a .deb this tool cannot read.
+var errBadDeb = errors.New("bad deb")
+
+const arMagic = "!<arch>\n"
+
+// readDeb finds the data member of a .deb (an ar archive) and returns its
+// tar stream, decompressed. The caller closes it.
+func readDeb(ctx context.Context, r io.Reader) (io.ReadCloser, error) {
+ magic := make([]byte, len(arMagic))
+ if _, err := io.ReadFull(r, magic); err != nil || string(magic) != arMagic {
+ return nil, fmt.Errorf("%w: not an ar archive", errBadDeb)
+ }
+ for {
+ var header [60]byte
+ if _, err := io.ReadFull(r, header[:]); err != nil {
+ return nil, fmt.Errorf("%w: no data member", errBadDeb)
+ }
+ if string(header[58:60]) != "`\n" {
+ return nil, fmt.Errorf("%w: a member header is damaged", errBadDeb)
+ }
+ name := strings.TrimRight(strings.TrimSpace(string(header[:16])), "/")
+ size, err := strconv.ParseInt(strings.TrimSpace(string(header[48:58])), 10, 64)
+ if err != nil || size < 0 {
+ return nil, fmt.Errorf("%w: a member size is damaged", errBadDeb)
+ }
+ if strings.HasPrefix(name, "data.tar") {
+ return decompressMember(ctx, name, io.LimitReader(r, size))
+ }
+ if _, err := io.CopyN(io.Discard, r, size+size%2); err != nil {
+ return nil, fmt.Errorf("%w: a member is cut short", errBadDeb)
+ }
+ }
+}
+
+func decompressMember(ctx context.Context, name string, r io.Reader) (io.ReadCloser, error) {
+ switch name {
+ case "data.tar":
+ return io.NopCloser(r), nil
+ case "data.tar.gz":
+ gz, err := gzip.NewReader(r)
+ if err != nil {
+ return nil, fmt.Errorf("%w: %s: %w", errBadDeb, name, err)
+ }
+ return gz, nil
+ case "data.tar.xz":
+ return xzReader(ctx, r)
+ }
+ return nil, fmt.Errorf("%w: %s is not a compression this tool reads", errBadDeb, name)
+}
+
+// xzStream is the output of an xz -dc child. Reading it to the end reports
+// the child's failure, so a damaged stream is never a short success.
+type xzStream struct {
+ cmd *exec.Cmd
+ out io.ReadCloser
+ stderr *bytes.Buffer
+ cancel context.CancelFunc
+ waited bool
+ err error
+}
+
+// xzReader decompresses r with the xz program.
+func xzReader(ctx context.Context, r io.Reader) (io.ReadCloser, error) {
+ ctx, cancel := context.WithCancel(ctx)
+ cmd := exec.CommandContext(ctx, "xz", "-dc")
+ cmd.Stdin = r
+ stderr := &bytes.Buffer{}
+ cmd.Stderr = stderr
+ out, err := cmd.StdoutPipe()
+ if err != nil {
+ cancel()
+ return nil, err
+ }
+ if err := cmd.Start(); err != nil {
+ cancel()
+ return nil, fmt.Errorf("xz: %w", err)
+ }
+ return &xzStream{cmd: cmd, out: out, stderr: stderr, cancel: cancel}, nil
+}
+
+func (x *xzStream) wait() error {
+ if !x.waited {
+ x.waited = true
+ if err := x.cmd.Wait(); err != nil {
+ x.err = fmt.Errorf("xz: %w: %s", err, strings.TrimSpace(x.stderr.String()))
+ }
+ }
+ return x.err
+}
+
+func (x *xzStream) Read(p []byte) (int, error) {
+ n, err := x.out.Read(p)
+ if errors.Is(err, io.EOF) {
+ if werr := x.wait(); werr != nil {
+ return n, werr
+ }
+ }
+ return n, err
+}
+
+// Close stops the child if it is still running. A stream abandoned early
+// is the caller's choice, so the child's death is not an error here.
+func (x *xzStream) Close() error {
+ x.cancel()
+ _ = x.wait()
+ return nil
+}
diff --git a/cmd/mediaimage/lock.go b/cmd/mediaimage/lock.go
new file mode 100644
index 000000000..7eabaaa29
--- /dev/null
+++ b/cmd/mediaimage/lock.go
@@ -0,0 +1,597 @@
+package main
+
+import (
+ "archive/tar"
+ "bufio"
+ "compress/gzip"
+ "context"
+ "errors"
+ "fmt"
+ "io"
+ "net/url"
+ "os"
+ "path/filepath"
+ "regexp"
+ "slices"
+ "strconv"
+ "strings"
+)
+
+var (
+ // errBadLock is a lock file that does not have the lock's shape.
+ errBadLock = errors.New("bad lock file")
+ // errUnresolved is a dependency no package in the snapshot satisfies.
+ errUnresolved = errors.New("unresolved dependency")
+)
+
+const defaultArchive = "https://snapshot.debian.org/archive"
+
+// lockRoot is the package whose dependencies the lock pins.
+const lockRoot = "ffmpeg"
+
+// suites are the indexes a lock reads, each in its archive on
+// snapshot.debian.org.
+var suites = []struct{ archive, suite string }{
+ {"debian", "trixie"},
+ {"debian", "trixie-updates"},
+ {"debian-security", "trixie-security"},
+}
+
+var (
+ snapshotPattern = regexp.MustCompile(`^[0-9]{8}T[0-9]{6}Z$`)
+ sha256Pattern = regexp.MustCompile(`^[0-9a-f]{64}$`)
+)
+
+// lockEntry is one pinned package.
+type lockEntry struct {
+ Package, Version, URL, SHA256 string
+ Size int64
+}
+
+// lockFile is deploy/media-image/debs.lock.
+type lockFile struct {
+ Snapshot, Base string
+ Entries []lockEntry
+}
+
+// render writes the lock in its one canonical form, sorted by package.
+func (l lockFile) render() []byte {
+ entries := slices.Clone(l.Entries)
+ slices.SortFunc(entries, func(a, b lockEntry) int { return strings.Compare(a.Package, b.Package) })
+ var b strings.Builder
+ fmt.Fprintf(&b, "# snapshot %s\n# base %s\n", l.Snapshot, l.Base)
+ for _, e := range entries {
+ fmt.Fprintf(&b, "%s\t%s\t%s\t%s\t%d\n", e.Package, e.Version, e.URL, e.SHA256, e.Size)
+ }
+ return []byte(b.String())
+}
+
+// version returns the pinned version of a package.
+func (l lockFile) version(name string) (string, bool) {
+ for _, e := range l.Entries {
+ if e.Package == name {
+ return e.Version, true
+ }
+ }
+ return "", false
+}
+
+// parseLock reads a lock, refusing anything render would not have written.
+func parseLock(data []byte) (lockFile, error) {
+ var l lockFile
+ for i, line := range strings.Split(strings.TrimSuffix(string(data), "\n"), "\n") {
+ bad := func(why string) (lockFile, error) {
+ return lockFile{}, fmt.Errorf("%w: line %d: %s", errBadLock, i+1, why)
+ }
+ if rest, ok := strings.CutPrefix(line, "# snapshot "); ok && i == 0 {
+ if !snapshotPattern.MatchString(rest) {
+ return bad("the snapshot is not YYYYMMDDTHHMMSSZ")
+ }
+ l.Snapshot = rest
+ continue
+ }
+ if rest, ok := strings.CutPrefix(line, "# base "); ok && i == 1 {
+ if _, err := parseImageRef(rest); err != nil {
+ return bad("the base is not pinned by digest")
+ }
+ l.Base = rest
+ continue
+ }
+ if i < 2 {
+ return bad("the lock starts with # snapshot and # base")
+ }
+ e, why := parseLockRow(line)
+ if why != "" {
+ return bad(why)
+ }
+ if n := len(l.Entries); n > 0 && l.Entries[n-1].Package >= e.Package {
+ return bad("packages are not sorted")
+ }
+ l.Entries = append(l.Entries, e)
+ }
+ if l.Snapshot == "" || l.Base == "" {
+ return lockFile{}, fmt.Errorf("%w: the lock starts with # snapshot and # base", errBadLock)
+ }
+ if len(l.Entries) == 0 {
+ return lockFile{}, fmt.Errorf("%w: no packages", errBadLock)
+ }
+ return l, nil
+}
+
+// parseLockRow reads one package line; why is empty when it is valid.
+func parseLockRow(line string) (e lockEntry, why string) {
+ f := strings.Split(line, "\t")
+ if len(f) != 5 {
+ return e, "a package line has five columns"
+ }
+ size, err := strconv.ParseInt(f[4], 10, 64)
+ if err != nil || size <= 0 {
+ return e, "the size is not a positive number"
+ }
+ if !sha256Pattern.MatchString(f[3]) {
+ return e, "the sha256 is not 64 hex digits"
+ }
+ u, err := url.Parse(f[2])
+ if err != nil || (u.Scheme != "https" && !(u.Scheme == "http" && isLoopback(u.Host))) {
+ return e, "the url is not https"
+ }
+ if f[0] == "" || f[1] == "" {
+ return e, "the package or version is empty"
+ }
+ return lockEntry{Package: f[0], Version: f[1], URL: f[2], SHA256: f[3], Size: size}, ""
+}
+
+// depAtom is one alternative of a dependency.
+type depAtom struct{ Name, Rel, Version string }
+
+// debPackage is one stanza of a Packages index.
+type debPackage struct {
+ Name, Version, URL, SHA256 string
+ Size int64
+ Depends [][]depAtom
+ Provides map[string]string // name to provided version, "" for none
+}
+
+// stanzas calls f with the fields of each RFC 822 stanza in r.
+func stanzas(r io.Reader, f func(fields map[string]string) error) error {
+ s := bufio.NewScanner(r)
+ s.Buffer(make([]byte, 0, 1<<16), 1<<24)
+ fields := map[string]string{}
+ last := ""
+ flush := func() error {
+ if len(fields) == 0 {
+ return nil
+ }
+ err := f(fields)
+ fields, last = map[string]string{}, ""
+ return err
+ }
+ for s.Scan() {
+ line := s.Text()
+ switch {
+ case line == "":
+ if err := flush(); err != nil {
+ return err
+ }
+ case line[0] == ' ' || line[0] == '\t':
+ if last != "" {
+ fields[last] += " " + strings.TrimSpace(line)
+ }
+ default:
+ name, value, ok := strings.Cut(line, ":")
+ if !ok {
+ continue
+ }
+ last = name
+ fields[name] = strings.TrimSpace(value)
+ }
+ }
+ if err := s.Err(); err != nil {
+ return err
+ }
+ return flush()
+}
+
+// parsePackages reads a Packages index whose Filename paths are relative
+// to origin.
+func parsePackages(r io.Reader, origin string) ([]debPackage, error) {
+ var out []debPackage
+ err := stanzas(r, func(fields map[string]string) error {
+ if arch := fields["Architecture"]; arch != "arm64" && arch != "all" {
+ return nil
+ }
+ size, err := strconv.ParseInt(fields["Size"], 10, 64)
+ if err != nil {
+ return fmt.Errorf("package %s: size: %w", fields["Package"], err)
+ }
+ p := debPackage{
+ Name: fields["Package"], Version: fields["Version"], Size: size,
+ URL: origin + fields["Filename"], SHA256: fields["SHA256"],
+ Provides: map[string]string{},
+ }
+ for _, field := range []string{"Pre-Depends", "Depends"} {
+ p.Depends = append(p.Depends, parseDepends(fields[field])...)
+ }
+ for _, group := range parseDepends(fields["Provides"]) {
+ for _, a := range group {
+ p.Provides[a.Name] = a.Version
+ }
+ }
+ out = append(out, p)
+ return nil
+ })
+ return out, err
+}
+
+var depPattern = regexp.MustCompile(`^([^\s(:]+)(?::[a-z0-9-]+)?\s*(?:\(\s*(<<|<=|=|>=|>>|<|>)\s*([^\s)]+)\s*\))?`)
+
+// parseDepends reads a Depends-style field.
+func parseDepends(field string) [][]depAtom {
+ var out [][]depAtom
+ for _, group := range strings.Split(field, ",") {
+ var atoms []depAtom
+ for _, alt := range strings.Split(group, "|") {
+ m := depPattern.FindStringSubmatch(strings.TrimSpace(alt))
+ if m != nil {
+ atoms = append(atoms, depAtom{Name: m[1], Rel: m[2], Version: m[3]})
+ }
+ }
+ if len(atoms) > 0 {
+ out = append(out, atoms)
+ }
+ }
+ return out
+}
+
+// parseStatus reads a dpkg status file: installed package to version.
+func parseStatus(r io.Reader) (map[string]string, error) {
+ out := map[string]string{}
+ err := stanzas(r, func(fields map[string]string) error {
+ if fields["Status"] == "install ok installed" {
+ out[fields["Package"]] = fields["Version"]
+ }
+ return nil
+ })
+ return out, err
+}
+
+// satisfies reports whether version meets the relation.
+func satisfies(version, rel, want string) bool {
+ if rel == "" {
+ return true
+ }
+ c := compareVersions(version, want)
+ switch rel {
+ case "=":
+ return c == 0
+ case ">=", ">":
+ return c >= 0
+ case "<=", "<":
+ return c <= 0
+ case ">>":
+ return c > 0
+ case "<<":
+ return c < 0
+ }
+ return false
+}
+
+// resolveClosure walks root's Pre-Depends and Depends through index, taking
+// each dependency's first available alternative and the newest version of
+// each package across the suites. A virtual name resolves to the first
+// package, by name, that provides it. It returns the closure sorted by
+// name, without the packages base already holds at the same version.
+func resolveClosure(index []debPackage, base map[string]string, root string) ([]debPackage, error) {
+ newest := map[string]*debPackage{}
+ for i := range index {
+ p := &index[i]
+ if cur, ok := newest[p.Name]; !ok || compareVersions(p.Version, cur.Version) > 0 {
+ newest[p.Name] = p
+ }
+ }
+ providers := map[string][]*debPackage{}
+ for _, p := range newest {
+ for name := range p.Provides {
+ providers[name] = append(providers[name], p)
+ }
+ }
+ for _, list := range providers {
+ slices.SortFunc(list, func(a, b *debPackage) int { return strings.Compare(a.Name, b.Name) })
+ }
+ pick := func(a depAtom) *debPackage {
+ if p, ok := newest[a.Name]; ok && satisfies(p.Version, a.Rel, a.Version) {
+ return p
+ }
+ for _, p := range providers[a.Name] {
+ if a.Rel == "" || (p.Provides[a.Name] != "" && satisfies(p.Provides[a.Name], a.Rel, a.Version)) {
+ return p
+ }
+ }
+ return nil
+ }
+
+ first, ok := newest[root]
+ if !ok {
+ return nil, fmt.Errorf("%w: no package %s in the snapshot", errUnresolved, root)
+ }
+ seen := map[string]bool{root: true}
+ queue := []*debPackage{first}
+ var out []debPackage
+ for len(queue) > 0 {
+ p := queue[0]
+ queue = queue[1:]
+ if base[p.Name] != p.Version {
+ out = append(out, *p)
+ }
+ for _, group := range p.Depends {
+ var chosen *debPackage
+ for _, atom := range group {
+ if chosen = pick(atom); chosen != nil {
+ break
+ }
+ }
+ if chosen == nil {
+ return nil, fmt.Errorf("%w: %s depends on %s", errUnresolved, p.Name, group[0].Name)
+ }
+ if !seen[chosen.Name] {
+ seen[chosen.Name] = true
+ queue = append(queue, chosen)
+ }
+ }
+ }
+ slices.SortFunc(out, func(a, b debPackage) int { return strings.Compare(a.Name, b.Name) })
+ return out, nil
+}
+
+// compareVersions orders two Debian versions as dpkg does.
+func compareVersions(a, b string) int {
+ ae, au, ar := splitVersion(a)
+ be, bu, br := splitVersion(b)
+ if ae != be {
+ if ae < be {
+ return -1
+ }
+ return 1
+ }
+ if c := compareVersionPart(au, bu); c != 0 {
+ return c
+ }
+ return compareVersionPart(ar, br)
+}
+
+func splitVersion(v string) (epoch int, upstream, revision string) {
+ if e, rest, ok := strings.Cut(v, ":"); ok {
+ if n, err := strconv.Atoi(e); err == nil {
+ epoch, v = n, rest
+ }
+ }
+ if i := strings.LastIndexByte(v, '-'); i >= 0 {
+ return epoch, v[:i], v[i+1:]
+ }
+ return epoch, v, ""
+}
+
+func isDigit(c byte) bool { return c >= '0' && c <= '9' }
+
+// versionOrder is dpkg's weight of a character outside a number: tilde
+// sorts before the end of the string, letters before everything else.
+func versionOrder(c byte) int {
+ switch {
+ case isDigit(c), c == 0:
+ return 0
+ case c == '~':
+ return -1
+ case c >= 'a' && c <= 'z', c >= 'A' && c <= 'Z':
+ return int(c)
+ }
+ return int(c) + 256
+}
+
+func compareVersionPart(a, b string) int {
+ at := func(s string, i int) byte {
+ if i < len(s) {
+ return s[i]
+ }
+ return 0
+ }
+ i, j := 0, 0
+ for i < len(a) || j < len(b) {
+ for (i < len(a) && !isDigit(a[i])) || (j < len(b) && !isDigit(b[j])) {
+ if x, y := versionOrder(at(a, i)), versionOrder(at(b, j)); x != y {
+ return sign(x - y)
+ }
+ i++
+ j++
+ }
+ for at(a, i) == '0' {
+ i++
+ }
+ for at(b, j) == '0' {
+ j++
+ }
+ first := 0
+ for isDigit(at(a, i)) && isDigit(at(b, j)) {
+ if first == 0 {
+ first = int(a[i]) - int(b[j])
+ }
+ i++
+ j++
+ }
+ if isDigit(at(a, i)) {
+ return 1
+ }
+ if isDigit(at(b, j)) {
+ return -1
+ }
+ if first != 0 {
+ return sign(first)
+ }
+ }
+ return 0
+}
+
+func sign(n int) int {
+ switch {
+ case n < 0:
+ return -1
+ case n > 0:
+ return 1
+ }
+ return 0
+}
+
+// lockOptions are the lock command's flags. Archive replaces
+// snapshot.debian.org's archive root in tests.
+type lockOptions struct {
+ Snapshot, Base, Out, Cache, Archive string
+}
+
+// writeLock resolves the closure at a snapshot and writes the lock.
+func writeLock(ctx context.Context, o lockOptions) error {
+ if !snapshotPattern.MatchString(o.Snapshot) {
+ return fmt.Errorf("%w: --snapshot is not YYYYMMDDTHHMMSSZ", errBadLock)
+ }
+ if o.Out == "" {
+ return fmt.Errorf("%w: --out is required", errBadLock)
+ }
+ ref, err := parseImageRef(o.Base)
+ if err != nil {
+ return err
+ }
+ cache := o.Cache
+ if cache == "" {
+ if cache, err = os.MkdirTemp("", "mediaimage-lock-"); err != nil {
+ return err
+ }
+ defer os.RemoveAll(cache)
+ }
+ store, err := openStore(cache)
+ if err != nil {
+ return err
+ }
+ base, err := loadBase(ctx, store, ref)
+ if err != nil {
+ return err
+ }
+ status, err := baseStatus(store, base)
+ if err != nil {
+ return err
+ }
+ archive := o.Archive
+ if archive == "" {
+ archive = defaultArchive
+ }
+ var index []debPackage
+ for _, s := range suites {
+ origin := archive + "/" + s.archive + "/" + o.Snapshot + "/"
+ packages, err := fetchPackages(ctx, origin, s.suite)
+ if err != nil {
+ return fmt.Errorf("%s: %w", s.suite, err)
+ }
+ index = append(index, packages...)
+ }
+ closure, err := resolveClosure(index, status, lockRoot)
+ if err != nil {
+ return err
+ }
+ l := lockFile{Snapshot: o.Snapshot, Base: o.Base}
+ for _, p := range closure {
+ l.Entries = append(l.Entries, lockEntry{Package: p.Name, Version: p.Version, URL: p.URL, SHA256: p.SHA256, Size: p.Size})
+ }
+ data := l.render()
+ if _, err := parseLock(data); err != nil {
+ return err
+ }
+ return writeFileAtomic(o.Out, data)
+}
+
+// fetchPackages downloads and parses one suite's index.
+func fetchPackages(ctx context.Context, origin, suite string) ([]debPackage, error) {
+ var packages []debPackage
+ err := withRetry(ctx, func() error {
+ body, err := httpGet(ctx, origin+"dists/"+suite+"/main/binary-arm64/Packages.xz")
+ if err != nil {
+ return err
+ }
+ defer body.Close()
+ xz, err := xzReader(ctx, body)
+ if err != nil {
+ return err
+ }
+ defer xz.Close()
+ packages, err = parsePackages(xz, origin)
+ return err
+ })
+ return packages, err
+}
+
+// baseStatus reads var/lib/dpkg/status from the base image's layers; the
+// last layer that holds it wins.
+func baseStatus(store blobStore, base baseImage) (map[string]string, error) {
+ var status map[string]string
+ for _, layer := range base.Manifest.Layers {
+ found, err := layerStatus(store.path(layer.Digest))
+ if err != nil {
+ return nil, fmt.Errorf("base layer %s: %w", layer.Digest, err)
+ }
+ if found != nil {
+ status = found
+ }
+ }
+ if status == nil {
+ return nil, fmt.Errorf("%w: the base image has no var/lib/dpkg/status", errBadBase)
+ }
+ return status, nil
+}
+
+func layerStatus(path string) (map[string]string, error) {
+ f, err := os.Open(path)
+ if err != nil {
+ return nil, err
+ }
+ defer f.Close()
+ gz, err := gzip.NewReader(f)
+ if err != nil {
+ return nil, err
+ }
+ defer gz.Close()
+ r := tar.NewReader(gz)
+ var status map[string]string
+ for {
+ h, err := r.Next()
+ if errors.Is(err, io.EOF) {
+ return status, nil
+ }
+ if err != nil {
+ return nil, err
+ }
+ if strings.TrimPrefix(h.Name, "./") == "var/lib/dpkg/status" {
+ if status, err = parseStatus(r); err != nil {
+ return nil, err
+ }
+ }
+ }
+}
+
+// writeFileAtomic replaces path in one step.
+func writeFileAtomic(path string, data []byte) error {
+ if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
+ return err
+ }
+ tmp, err := os.CreateTemp(filepath.Dir(path), ".mediaimage-*")
+ if err != nil {
+ return err
+ }
+ defer os.Remove(tmp.Name())
+ if _, err := tmp.Write(data); err != nil {
+ tmp.Close()
+ return err
+ }
+ if err := tmp.Close(); err != nil {
+ return err
+ }
+ if err := os.Chmod(tmp.Name(), 0o644); err != nil {
+ return err
+ }
+ return os.Rename(tmp.Name(), path)
+}
diff --git a/cmd/mediaimage/main.go b/cmd/mediaimage/main.go
new file mode 100644
index 000000000..ea9ff3479
--- /dev/null
+++ b/cmd/mediaimage/main.go
@@ -0,0 +1,127 @@
+// Command mediaimage assembles the media engine's arm64 OCI image without
+// a container runtime, because amadan CI has none. The image is Debian 13's
+// base image, Debian's ffmpeg packages and the carlos-media binary.
+//
+// - lock pins the packages: it reads the base image's package list and a
+// snapshot.debian.org timestamp, resolves ffmpeg's dependencies and
+// writes deploy/media-image/debs.lock.
+// - build turns the lock and a linux/arm64 carlos-media into an OCI
+// layout. The same inputs give the same bytes.
+// - push copies a layout into a deployment's image repository under a
+// release tag and verifies the digest the registry holds.
+//
+// deploy/media-image/README.md is the operator's guide.
+package main
+
+import (
+ "context"
+ "errors"
+ "flag"
+ "fmt"
+ "io"
+ "os"
+ "os/signal"
+ "syscall"
+)
+
+const usage = "usage: mediaimage <lock|build|push> [flags]"
+
+// errUsage is a command line that names no valid command or flags; the
+// flag package has already said why.
+var errUsage = errors.New("usage")
+
+func main() {
+ ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
+ err := run(ctx, os.Args[1:], os.Stdout, os.Stderr, os.Getenv)
+ stop()
+ if err != nil {
+ if !errors.Is(err, errUsage) {
+ fmt.Fprintf(os.Stderr, "mediaimage: %v\n", err)
+ }
+ os.Exit(1)
+ }
+}
+
+func run(ctx context.Context, args []string, stdout, stderr io.Writer, getenv func(string) string) error {
+ if len(args) == 0 {
+ fmt.Fprintln(stderr, usage)
+ return errUsage
+ }
+ switch args[0] {
+ case "lock":
+ return runLock(ctx, args[1:], stdout, stderr)
+ case "build":
+ return runBuild(ctx, args[1:], stdout, stderr)
+ case "push":
+ return runPush(ctx, args[1:], stdout, stderr, getenv)
+ }
+ fmt.Fprintln(stderr, usage)
+ return errUsage
+}
+
+// parseFlags parses a command's flags and refuses stray arguments.
+func parseFlags(fs *flag.FlagSet, args []string, stderr io.Writer) error {
+ fs.SetOutput(stderr)
+ if err := fs.Parse(args); err != nil {
+ return errUsage
+ }
+ if fs.NArg() != 0 {
+ fmt.Fprintln(stderr, usage)
+ return errUsage
+ }
+ return nil
+}
+
+func runLock(ctx context.Context, args []string, stdout, stderr io.Writer) error {
+ fs := flag.NewFlagSet("lock", flag.ContinueOnError)
+ var o lockOptions
+ fs.StringVar(&o.Snapshot, "snapshot", "", "snapshot.debian.org timestamp, YYYYMMDDTHHMMSSZ")
+ fs.StringVar(&o.Base, "base", "", "base image, docker.io/library/debian@sha256:<digest>")
+ fs.StringVar(&o.Out, "out", "", "lock file to write")
+ fs.StringVar(&o.Cache, "cache", "", "directory that keeps downloads between runs")
+ if err := parseFlags(fs, args, stderr); err != nil {
+ return err
+ }
+ if err := writeLock(ctx, o); err != nil {
+ return err
+ }
+ fmt.Fprintln(stdout, o.Out)
+ return nil
+}
+
+func runBuild(ctx context.Context, args []string, stdout, stderr io.Writer) error {
+ fs := flag.NewFlagSet("build", flag.ContinueOnError)
+ var o buildOptions
+ fs.StringVar(&o.Lock, "lock", "", "lock file")
+ fs.StringVar(&o.Binary, "binary", "", "carlos-media built for linux/arm64")
+ fs.StringVar(&o.Created, "created", "", "image creation time, RFC 3339")
+ fs.StringVar(&o.Out, "out", "", "directory to write the OCI layout to")
+ fs.StringVar(&o.Cache, "cache", "dist/media-image-cache", "directory that keeps downloads between runs")
+ if err := parseFlags(fs, args, stderr); err != nil {
+ return err
+ }
+ info, err := buildImage(ctx, o)
+ if err != nil {
+ return err
+ }
+ fmt.Fprintln(stdout, info.Digest)
+ return nil
+}
+
+func runPush(ctx context.Context, args []string, stdout, stderr io.Writer, getenv func(string) string) error {
+ fs := flag.NewFlagSet("push", flag.ContinueOnError)
+ var o pushOptions
+ fs.StringVar(&o.Layout, "layout", "", "OCI layout written by build")
+ fs.StringVar(&o.Repo, "repo", "", "image repository, <registry>/<repo>")
+ fs.StringVar(&o.Tag, "tag", "", "release tag; each release has its own, never reused")
+ if err := parseFlags(fs, args, stderr); err != nil {
+ return err
+ }
+ o.Password = getenv(registryPasswordEnv)
+ digest, err := pushImage(ctx, o)
+ if err != nil {
+ return err
+ }
+ fmt.Fprintln(stdout, digest)
+ return nil
+}
diff --git a/cmd/mediaimage/mediaimage_test.go b/cmd/mediaimage/mediaimage_test.go
new file mode 100644
index 000000000..bc2db9e4c
--- /dev/null
+++ b/cmd/mediaimage/mediaimage_test.go
@@ -0,0 +1,1531 @@
+package main
+
+import (
+ "archive/tar"
+ "bytes"
+ "compress/gzip"
+ "crypto/sha256"
+ "debug/elf"
+ "encoding/base64"
+ "encoding/binary"
+ "encoding/hex"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io"
+ "net/http"
+ "net/http/httptest"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "slices"
+ "strconv"
+ "strings"
+ "sync"
+ "testing"
+
+ "github.com/carlosframework/platform/internal/media"
+)
+
+const testCreated = "2026-11-16T10:00:00Z"
+
+// fx is one entry of a fixture tar.
+type fx struct {
+ name string
+ typ byte
+ mode int64
+ link string
+ body []byte
+}
+
+func file(name string, body []byte) fx {
+ return fx{name: name, typ: tar.TypeReg, mode: 0o644, body: body}
+}
+func dir(name string) fx { return fx{name: name, typ: tar.TypeDir, mode: 0o755} }
+func symlink(name, target string) fx {
+ return fx{name: name, typ: tar.TypeSymlink, mode: 0o777, link: target}
+}
+
+func tarBytes(t *testing.T, files []fx) []byte {
+ t.Helper()
+ var buf bytes.Buffer
+ w := tar.NewWriter(&buf)
+ for _, f := range files {
+ h := &tar.Header{Name: f.name, Typeflag: f.typ, Mode: f.mode, Linkname: f.link, Size: int64(len(f.body)), Uid: 1000, Gid: 1000, Uname: "builder", Gname: "builder"}
+ if err := w.WriteHeader(h); err != nil {
+ t.Fatalf("tar header %s: %v", f.name, err)
+ }
+ if _, err := w.Write(f.body); err != nil {
+ t.Fatalf("tar body %s: %v", f.name, err)
+ }
+ }
+ if err := w.Close(); err != nil {
+ t.Fatal(err)
+ }
+ return buf.Bytes()
+}
+
+func gzipBytes(t *testing.T, data []byte) []byte {
+ t.Helper()
+ var buf bytes.Buffer
+ w := gzip.NewWriter(&buf)
+ if _, err := w.Write(data); err != nil {
+ t.Fatal(err)
+ }
+ if err := w.Close(); err != nil {
+ t.Fatal(err)
+ }
+ return buf.Bytes()
+}
+
+// arBytes writes a Debian-shaped ar archive.
+func arBytes(members ...fx) []byte {
+ var buf bytes.Buffer
+ buf.WriteString("!<arch>\n")
+ for _, m := range members {
+ fmt.Fprintf(&buf, "%-16s%-12d%-6d%-6d%-8s%-10d`\n", m.name, 0, 0, 0, "100644", len(m.body))
+ buf.Write(m.body)
+ if len(m.body)%2 == 1 {
+ buf.WriteByte('\n')
+ }
+ }
+ return buf.Bytes()
+}
+
+func debBytes(t *testing.T, files []fx) []byte {
+ t.Helper()
+ return arBytes(
+ fx{name: "debian-binary", body: []byte("2.0\n")},
+ fx{name: "control.tar.gz", body: gzipBytes(t, tarBytes(t, nil))},
+ fx{name: "data.tar.gz", body: gzipBytes(t, tarBytes(t, files))},
+ )
+}
+
+// elfBytes builds a minimal ELF64 shared object for machine with the
+// given DT_NEEDED entries, enough for debug/elf to read.
+func elfBytes(t *testing.T, machine elf.Machine, needed ...string) []byte {
+ t.Helper()
+ dynstr := []byte{0}
+ var dynamic bytes.Buffer
+ le := binary.LittleEndian
+ for _, n := range needed {
+ _ = binary.Write(&dynamic, le, []uint64{uint64(elf.DT_NEEDED), uint64(len(dynstr))})
+ dynstr = append(append(dynstr, n...), 0)
+ }
+ _ = binary.Write(&dynamic, le, []uint64{uint64(elf.DT_NULL), 0})
+ shstr := []byte("\x00.dynstr\x00.dynamic\x00.shstrtab\x00")
+
+ const headerSize, sectionSize = 64, 64
+ dynstrOff := uint64(headerSize)
+ dynamicOff := dynstrOff + uint64(len(dynstr))
+ shstrOff := dynamicOff + uint64(dynamic.Len())
+ sectionsOff := shstrOff + uint64(len(shstr))
+
+ var out bytes.Buffer
+ out.Write([]byte{0x7f, 'E', 'L', 'F', 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0})
+ _ = binary.Write(&out, le, elf.Header64{}.Type)
+ out.Truncate(16)
+ _ = binary.Write(&out, le, uint16(elf.ET_DYN))
+ _ = binary.Write(&out, le, uint16(machine))
+ _ = binary.Write(&out, le, uint32(1))
+ _ = binary.Write(&out, le, []uint64{0, 0, sectionsOff})
+ _ = binary.Write(&out, le, uint32(0))
+ _ = binary.Write(&out, le, []uint16{headerSize, 56, 0, sectionSize, 4, 3})
+ out.Write(dynstr)
+ out.Write(dynamic.Bytes())
+ out.Write(shstr)
+ section := func(name, typ uint32, off, size uint64, link uint32, entsize uint64) {
+ _ = binary.Write(&out, le, elf.Section64{Name: name, Type: typ, Off: off, Size: size, Link: link, Addralign: 1, Entsize: entsize})
+ }
+ section(0, uint32(elf.SHT_NULL), 0, 0, 0, 0)
+ section(1, uint32(elf.SHT_STRTAB), dynstrOff, uint64(len(dynstr)), 0, 0)
+ section(9, uint32(elf.SHT_DYNAMIC), dynamicOff, uint64(dynamic.Len()), 1, 16)
+ section(18, uint32(elf.SHT_STRTAB), shstrOff, uint64(len(shstr)), 0, 0)
+ return out.Bytes()
+}
+
+func arm(t *testing.T, needed ...string) []byte { return elfBytes(t, elf.EM_AARCH64, needed...) }
+
+func digestOf(data []byte) string {
+ sum := sha256.Sum256(data)
+ return hex.EncodeToString(sum[:])
+}
+
+func putBlob(t *testing.T, cache string, data []byte) string {
+ t.Helper()
+ sum := digestOf(data)
+ dir := filepath.Join(cache, "blobs", "sha256")
+ if err := os.MkdirAll(dir, 0o755); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(filepath.Join(dir, sum), data, 0o644); err != nil {
+ t.Fatal(err)
+ }
+ return sum
+}
+
+func mustJSON(t *testing.T, v any) []byte {
+ t.Helper()
+ data, err := json.Marshal(v)
+ if err != nil {
+ t.Fatal(err)
+ }
+ return data
+}
+
+const multiarch = "usr/lib/aarch64-linux-gnu/"
+
+// baseFiles is a small merged-/usr Debian root.
+func baseFiles(t *testing.T) []fx {
+ return []fx{
+ symlink("bin", "usr/bin"), symlink("lib", "usr/lib"), symlink("sbin", "usr/sbin"),
+ dir("etc/"), dir("usr/"), dir("usr/bin/"), dir("usr/lib/"), dir(multiarch), dir("usr/sbin/"),
+ dir("usr/local/"), dir("usr/local/bin/"), dir("usr/share/"), dir("var/"), dir("var/lib/"), dir("var/lib/dpkg/"),
+ file(multiarch+"libc.so.6", arm(t)),
+ file("var/lib/dpkg/status", []byte("Package: libc6\nStatus: install ok installed\nVersion: 2.41-12\n\n")),
+ }
+}
+
+// putBase stores a base image in the cache and returns its pinned ref. The
+// index also lists an amd64 image, which a build must never use.
+func putBase(t *testing.T, cache string, files []fx) string {
+ t.Helper()
+ raw := tarBytes(t, files)
+ layer := gzipBytes(t, raw)
+ layerSum := putBlob(t, cache, layer)
+ config := mustJSON(t, map[string]any{
+ "architecture": "arm64", "os": "linux",
+ "config": map[string]any{"Env": []string{"PATH=/usr/local/bin:/usr/bin"}, "Cmd": []string{"bash"}},
+ "rootfs": map[string]any{"type": "layers", "diff_ids": []string{"sha256:" + digestOf(raw)}},
+ })
+ configSum := putBlob(t, cache, config)
+ manifest := mustJSON(t, map[string]any{
+ "schemaVersion": 2, "mediaType": mediaTypeDockerManifest,
+ "config": map[string]any{"mediaType": "application/vnd.docker.container.image.v1+json", "digest": "sha256:" + configSum, "size": len(config)},
+ "layers": []any{map[string]any{"mediaType": mediaTypeDockerLayer, "digest": "sha256:" + layerSum, "size": len(layer)}},
+ })
+ manifestSum := putBlob(t, cache, manifest)
+ index := mustJSON(t, map[string]any{
+ "schemaVersion": 2, "mediaType": mediaTypeDockerList,
+ "manifests": []any{
+ map[string]any{"mediaType": mediaTypeDockerManifest, "digest": "sha256:" + strings.Repeat("a", 64), "size": 1, "platform": map[string]any{"architecture": "amd64", "os": "linux"}},
+ map[string]any{"mediaType": mediaTypeDockerManifest, "digest": "sha256:" + manifestSum, "size": len(manifest), "platform": map[string]any{"architecture": "arm64", "os": "linux", "variant": "v8"}},
+ },
+ })
+ return "docker.io/library/debian@sha256:" + putBlob(t, cache, index)
+}
+
+// fixture is a build's inputs on disk.
+type fixture struct {
+ cache, lock, binary, out string
+ base []fx
+ debs map[string][]fx
+}
+
+func ffmpegDebs(t *testing.T) map[string][]fx {
+ return map[string][]fx{
+ "ffmpeg": {
+ dir("./usr/"), dir("./usr/bin/"),
+ {name: "./usr/bin/ffmpeg", typ: tar.TypeReg, mode: 0o755, body: arm(t, "libavcodec.so.61", "libc.so.6")},
+ {name: "./usr/bin/ffprobe", typ: tar.TypeReg, mode: 0o755, body: arm(t, "libc.so.6")},
+ },
+ "libavcodec61": {
+ dir("./lib/"), dir("./lib/aarch64-linux-gnu/"),
+ file("./lib/aarch64-linux-gnu/libavcodec.so.61.19.101", arm(t, "libc.so.6")),
+ symlink("./lib/aarch64-linux-gnu/libavcodec.so.61", "libavcodec.so.61.19.101"),
+ },
+ }
+}
+
+func newFixture(t *testing.T) *fixture {
+ t.Helper()
+ root := t.TempDir()
+ f := &fixture{
+ cache: filepath.Join(root, "cache"),
+ lock: filepath.Join(root, "debs.lock"),
+ binary: filepath.Join(root, "carlos-media"),
+ out: filepath.Join(root, "dist", "media-image"),
+ base: baseFiles(t),
+ debs: ffmpegDebs(t),
+ }
+ if err := os.WriteFile(f.binary, arm(t), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ return f
+}
+
+// write stores the debs and base and writes the lock.
+func (f *fixture) write(t *testing.T) lockFile {
+ t.Helper()
+ l := lockFile{Snapshot: "20261116T000000Z", Base: putBase(t, f.cache, f.base)}
+ for name, files := range f.debs {
+ data := debBytes(t, files)
+ l.Entries = append(l.Entries, lockEntry{
+ Package: name, Version: "7:7.1.5-0+deb13u1",
+ URL: "https://deb.invalid/" + name + ".deb",
+ SHA256: putBlob(t, f.cache, data), Size: int64(len(data)),
+ })
+ }
+ if err := os.WriteFile(f.lock, l.render(), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ return l
+}
+
+func (f *fixture) options() buildOptions {
+ return buildOptions{Lock: f.lock, Binary: f.binary, Created: testCreated, Out: f.out, Cache: f.cache}
+}
+
+func (f *fixture) build(t *testing.T) media.ImageInfo {
+ t.Helper()
+ f.write(t)
+ info, err := buildImage(t.Context(), f.options())
+ if err != nil {
+ t.Fatalf("build: %v", err)
+ }
+ return info
+}
+
+// buildErr builds a fixture that must be refused and returns why.
+func (f *fixture) buildErr(t *testing.T) error {
+ t.Helper()
+ f.write(t)
+ _, err := buildImage(t.Context(), f.options())
+ if err == nil {
+ t.Fatal("the build succeeded; want a refusal")
+ }
+ return err
+}
+
+func readLayout(t *testing.T, out string) (ociManifest, ociConfig) {
+ t.Helper()
+ var index ociIndex
+ readJSONFile(t, filepath.Join(out, "index.json"), &index)
+ if len(index.Manifests) != 1 {
+ t.Fatalf("index holds %d manifests, want 1", len(index.Manifests))
+ }
+ var m ociManifest
+ readJSONFile(t, blobPath(out, index.Manifests[0].Digest), &m)
+ var c ociConfig
+ readJSONFile(t, blobPath(out, m.Config.Digest), &c)
+ return m, c
+}
+
+func blobPath(out, digest string) string {
+ return filepath.Join(out, "blobs", "sha256", strings.TrimPrefix(digest, "sha256:"))
+}
+
+func readJSONFile(t *testing.T, path string, v any) {
+ t.Helper()
+ data, err := os.ReadFile(path)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := json.Unmarshal(data, v); err != nil {
+ t.Fatalf("%s: %v", path, err)
+ }
+}
+
+// layerEntry is one tar entry of a built layer.
+type layerEntry struct {
+ hdr tar.Header
+ body []byte
+}
+
+func readLayer(t *testing.T, out, digest string) []layerEntry {
+ t.Helper()
+ blob, err := os.Open(blobPath(out, digest))
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer blob.Close()
+ gz, err := gzip.NewReader(blob)
+ if err != nil {
+ t.Fatal(err)
+ }
+ r := tar.NewReader(gz)
+ var entries []layerEntry
+ for {
+ h, err := r.Next()
+ if errors.Is(err, io.EOF) {
+ return entries
+ }
+ if err != nil {
+ t.Fatal(err)
+ }
+ body, err := io.ReadAll(r)
+ if err != nil {
+ t.Fatal(err)
+ }
+ entries = append(entries, layerEntry{hdr: *h, body: body})
+ }
+}
+
+// builtEntries returns the deb layer and the binary layer by path.
+func builtEntries(t *testing.T, out string) (debs, top map[string]layerEntry) {
+ t.Helper()
+ m, _ := readLayout(t, out)
+ if len(m.Layers) != 3 {
+ t.Fatalf("image has %d layers, want base + debs + binary", len(m.Layers))
+ }
+ index := func(digest string) map[string]layerEntry {
+ entries := map[string]layerEntry{}
+ for _, e := range readLayer(t, out, digest) {
+ entries[e.hdr.Name] = e
+ }
+ return entries
+ }
+ return index(m.Layers[1].Digest), index(m.Layers[2].Digest)
+}
+
+func TestLockParsesAndSorts(t *testing.T) {
+ sum := strings.Repeat("c", 64)
+ l := lockFile{Snapshot: "20261116T000000Z", Base: "docker.io/library/debian@sha256:" + strings.Repeat("b", 64), Entries: []lockEntry{
+ {Package: "zlib1g", Version: "1:1.3", URL: "https://deb.invalid/z.deb", SHA256: sum, Size: 9},
+ {Package: "ffmpeg", Version: "7:7.1.5-0+deb13u1", URL: "https://deb.invalid/f.deb", SHA256: sum, Size: 7},
+ }}
+ got := string(l.render())
+ want := "# snapshot 20261116T000000Z\n# base " + l.Base + "\n" +
+ "ffmpeg\t7:7.1.5-0+deb13u1\thttps://deb.invalid/f.deb\t" + sum + "\t7\n" +
+ "zlib1g\t1:1.3\thttps://deb.invalid/z.deb\t" + sum + "\t9\n"
+ if got != want {
+ t.Fatalf("render:\n%s\nwant:\n%s", got, want)
+ }
+ parsed, err := parseLock([]byte(got))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if parsed.Snapshot != l.Snapshot || parsed.Base != l.Base || len(parsed.Entries) != 2 ||
+ parsed.Entries[0].Package != "ffmpeg" || parsed.Entries[1].Size != 9 {
+ t.Fatalf("parsed = %+v", parsed)
+ }
+ if v, ok := parsed.version("ffmpeg"); !ok || v != "7:7.1.5-0+deb13u1" {
+ t.Fatalf("version(ffmpeg) = %q, %v", v, ok)
+ }
+}
+
+func TestLockRefusesAMalformedFile(t *testing.T) {
+ sum := strings.Repeat("c", 64)
+ head := "# snapshot 20261116T000000Z\n# base docker.io/library/debian@sha256:" + strings.Repeat("b", 64) + "\n"
+ row := func(pkg string) string { return pkg + "\t1\thttps://deb.invalid/x.deb\t" + sum + "\t7\n" }
+ for name, data := range map[string]string{
+ "no snapshot": "# base docker.io/library/debian@sha256:" + strings.Repeat("b", 64) + "\n" + row("a"),
+ "no base": "# snapshot 20261116T000000Z\n" + row("a"),
+ "bad snapshot": "# snapshot yesterday\n# base docker.io/library/debian@sha256:" + strings.Repeat("b", 64) + "\n" + row("a"),
+ "base by tag": "# snapshot 20261116T000000Z\n# base docker.io/library/debian:trixie\n" + row("a"),
+ "few columns": head + "a\t1\thttps://deb.invalid/x.deb\t" + sum + "\n",
+ "short hash": head + "a\t1\thttps://deb.invalid/x.deb\tabc\t7\n",
+ "zero size": head + "a\t1\thttps://deb.invalid/x.deb\t" + sum + "\t0\n",
+ "unsorted": head + row("b") + row("a"),
+ "duplicate": head + row("a") + row("a"),
+ "plain http": head + "a\t1\thttp://deb.invalid/x.deb\t" + sum + "\t7\n",
+ "no packages": head,
+ } {
+ t.Run(name, func(t *testing.T) {
+ if _, err := parseLock([]byte(data)); !errors.Is(err, errBadLock) {
+ t.Fatalf("parseLock = %v, want errBadLock", err)
+ }
+ })
+ }
+}
+
+func TestCompareVersions(t *testing.T) {
+ for _, c := range []struct {
+ a, b string
+ want int
+ }{
+ {"1.0", "1.0", 0},
+ {"1.0", "1.1", -1},
+ {"1.10", "1.9", 1},
+ {"1:1.0", "2.0", 1},
+ {"7:7.1.5-0+deb13u1", "7:7.1.5-0", 1},
+ {"1.0~rc1", "1.0", -1},
+ {"1.0~rc1-1", "1.0~rc1-1+b1", -1},
+ {"1.0-1", "1.0-1~bpo13+1", 1},
+ {"1.0a", "1.0+", -1},
+ {"2.41-12", "2.41-12+deb13u1", -1},
+ } {
+ if got := compareVersions(c.a, c.b); got != c.want {
+ t.Errorf("compareVersions(%q, %q) = %d, want %d", c.a, c.b, got, c.want)
+ }
+ if got := compareVersions(c.b, c.a); got != -c.want {
+ t.Errorf("compareVersions(%q, %q) = %d, want %d", c.b, c.a, got, -c.want)
+ }
+ }
+}
+
+const packagesFixture = `Package: ffmpeg
+Version: 7:7.1.5-0+deb13u1
+Architecture: arm64
+Pre-Depends: libpre1
+Depends: libavcodec61 (>= 7:7.1), missing-first | libalt1, virtual-gl, libloop-a, libbase1, libtoonew (>= 2) | libfallback1
+Recommends: recommended-pkg
+Suggests: suggested-pkg
+Filename: pool/main/f/ffmpeg/ffmpeg_7.1.5-0+deb13u1_arm64.deb
+Size: 100
+SHA256: 0000000000000000000000000000000000000000000000000000000000000001
+
+Package: libavcodec61
+Version: 7:7.1.5-0+deb13u1
+Architecture: arm64
+Filename: pool/main/f/ffmpeg/libavcodec61.deb
+Size: 101
+SHA256: 0000000000000000000000000000000000000000000000000000000000000002
+
+Package: libpre1
+Version: 1.0-1
+Architecture: arm64
+Filename: pool/main/libp/libpre1.deb
+Size: 102
+SHA256: 0000000000000000000000000000000000000000000000000000000000000003
+
+Package: libalt1
+Version: 1.0-1
+Architecture: arm64
+Filename: pool/main/liba/libalt1.deb
+Size: 103
+SHA256: 0000000000000000000000000000000000000000000000000000000000000004
+
+Package: zz-provider
+Version: 1.0-1
+Architecture: arm64
+Provides: virtual-gl (= 1.0)
+Filename: pool/main/z/zz-provider.deb
+Size: 104
+SHA256: 0000000000000000000000000000000000000000000000000000000000000005
+
+Package: aa-provider
+Version: 1.0-1
+Architecture: arm64
+Provides: other-name, virtual-gl
+Filename: pool/main/a/aa-provider.deb
+Size: 105
+SHA256: 0000000000000000000000000000000000000000000000000000000000000006
+
+Package: libloop-a
+Version: 1.0-1
+Architecture: arm64
+Depends: libloop-b
+Filename: pool/main/libl/libloop-a.deb
+Size: 106
+SHA256: 0000000000000000000000000000000000000000000000000000000000000007
+
+Package: libloop-b
+Version: 1.0-1
+Architecture: arm64
+Depends: libloop-a:any
+Filename: pool/main/libl/libloop-b.deb
+Size: 107
+SHA256: 0000000000000000000000000000000000000000000000000000000000000008
+
+Package: libbase1
+Version: 2.0-1
+Architecture: arm64
+Filename: pool/main/libb/libbase1.deb
+Size: 108
+SHA256: 0000000000000000000000000000000000000000000000000000000000000009
+
+Package: libtoonew
+Version: 1.0-1
+Architecture: arm64
+Filename: pool/main/libt/libtoonew.deb
+Size: 109
+SHA256: 000000000000000000000000000000000000000000000000000000000000000a
+
+Package: libfallback1
+Version: 1.0-1
+Architecture: arm64
+Filename: pool/main/libf/libfallback1.deb
+Size: 110
+SHA256: 000000000000000000000000000000000000000000000000000000000000000b
+
+Package: recommended-pkg
+Version: 1.0-1
+Architecture: arm64
+Filename: pool/main/r/recommended.deb
+Size: 111
+SHA256: 000000000000000000000000000000000000000000000000000000000000000c
+
+Package: suggested-pkg
+Version: 1.0-1
+Architecture: arm64
+Filename: pool/main/s/suggested.deb
+Size: 112
+SHA256: 000000000000000000000000000000000000000000000000000000000000000d
+`
+
+func TestResolveClosure(t *testing.T) {
+ index, err := parsePackages(strings.NewReader(packagesFixture), "https://snap.invalid/debian/T/")
+ if err != nil {
+ t.Fatal(err)
+ }
+ base, err := parseStatus(strings.NewReader("Package: libbase1\nStatus: install ok installed\nVersion: 2.0-1\n\nPackage: libpre1\nStatus: deinstall ok config-files\nVersion: 1.0-1\n\n"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ closure, err := resolveClosure(index, base, "ffmpeg")
+ if err != nil {
+ t.Fatal(err)
+ }
+ var names []string
+ for _, p := range closure {
+ names = append(names, p.Name)
+ }
+ want := []string{"aa-provider", "ffmpeg", "libalt1", "libavcodec61", "libfallback1", "libloop-a", "libloop-b", "libpre1"}
+ if !slices.Equal(names, want) {
+ t.Fatalf("closure = %v\nwant %v", names, want)
+ }
+ if got := closure[1].URL; got != "https://snap.invalid/debian/T/pool/main/f/ffmpeg/ffmpeg_7.1.5-0+deb13u1_arm64.deb" {
+ t.Fatalf("url = %q", got)
+ }
+}
+
+func TestResolveClosureTakesTheNewestAcrossSuites(t *testing.T) {
+ older := "Package: ffmpeg\nVersion: 7:7.1.1-1\nArchitecture: arm64\nFilename: pool/old.deb\nSize: 1\nSHA256: " + strings.Repeat("1", 64) + "\n\n"
+ newer := "Package: ffmpeg\nVersion: 7:7.1.5-0+deb13u1\nArchitecture: arm64\nFilename: pool/new.deb\nSize: 2\nSHA256: " + strings.Repeat("2", 64) + "\n\n"
+ a, err := parsePackages(strings.NewReader(newer), "https://snap.invalid/security/")
+ if err != nil {
+ t.Fatal(err)
+ }
+ b, err := parsePackages(strings.NewReader(older), "https://snap.invalid/main/")
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, index := range [][]debPackage{append(slices.Clone(a), b...), append(slices.Clone(b), a...)} {
+ closure, err := resolveClosure(index, nil, "ffmpeg")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(closure) != 1 || closure[0].Version != "7:7.1.5-0+deb13u1" {
+ t.Fatalf("closure = %+v", closure)
+ }
+ }
+}
+
+func TestResolveClosureUpgradesAnOlderBasePackage(t *testing.T) {
+ data := "Package: ffmpeg\nVersion: 2\nArchitecture: arm64\nDepends: libc6\nFilename: pool/f.deb\nSize: 1\nSHA256: " + strings.Repeat("1", 64) + "\n\n" +
+ "Package: libc6\nVersion: 2.41-12+deb13u1\nArchitecture: arm64\nFilename: pool/l.deb\nSize: 1\nSHA256: " + strings.Repeat("2", 64) + "\n\n"
+ index, err := parsePackages(strings.NewReader(data), "https://snap.invalid/")
+ if err != nil {
+ t.Fatal(err)
+ }
+ closure, err := resolveClosure(index, map[string]string{"libc6": "2.41-12"}, "ffmpeg")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if len(closure) != 2 || closure[1].Name != "libc6" {
+ t.Fatalf("closure = %+v, want libc6 upgraded over the base", closure)
+ }
+}
+
+func TestResolveClosureRefusesAnUnresolvedDependency(t *testing.T) {
+ data := "Package: ffmpeg\nVersion: 1\nArchitecture: arm64\nDepends: libgone1 | libgone2 (>= 3)\nFilename: pool/f.deb\nSize: 1\nSHA256: " + strings.Repeat("1", 64) + "\n\n"
+ index, err := parsePackages(strings.NewReader(data), "https://snap.invalid/")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := resolveClosure(index, nil, "ffmpeg"); !errors.Is(err, errUnresolved) {
+ t.Fatalf("resolveClosure = %v, want errUnresolved", err)
+ }
+ if _, err := resolveClosure(index, nil, "not-a-package"); !errors.Is(err, errUnresolved) {
+ t.Fatalf("resolveClosure(no root) = %v, want errUnresolved", err)
+ }
+}
+
+// fakeRegistry is a registry v2 on 127.0.0.1, for pulls and pushes.
+type fakeRegistry struct {
+ mu sync.Mutex
+ blobs map[string][]byte
+ manifests map[string][]byte
+ uploads map[string][]byte
+ puts []string
+ password string
+ tamper bool
+ srv *httptest.Server
+}
+
+func newFakeRegistry(t *testing.T) *fakeRegistry {
+ t.Helper()
+ r := &fakeRegistry{blobs: map[string][]byte{}, manifests: map[string][]byte{}, uploads: map[string][]byte{}}
+ r.srv = httptest.NewServer(r)
+ t.Cleanup(r.srv.Close)
+ return r
+}
+
+func (r *fakeRegistry) host() string { return strings.TrimPrefix(r.srv.URL, "http://") }
+
+func (r *fakeRegistry) ServeHTTP(w http.ResponseWriter, req *http.Request) {
+ r.mu.Lock()
+ defer r.mu.Unlock()
+ if r.password != "" {
+ want := "Basic " + base64.StdEncoding.EncodeToString([]byte("AWS:"+r.password))
+ if req.Header.Get("Authorization") != want {
+ w.WriteHeader(http.StatusUnauthorized)
+ return
+ }
+ }
+ path := strings.TrimPrefix(req.URL.Path, "/v2/engine/")
+ switch {
+ case strings.HasPrefix(path, "blobs/uploads/") && req.Method == http.MethodPost:
+ id := strconv.Itoa(len(r.uploads) + 1)
+ r.uploads[id] = nil
+ w.Header().Set("Location", "/v2/engine/blobs/uploads/"+id+"?state=s")
+ w.WriteHeader(http.StatusAccepted)
+ case strings.HasPrefix(path, "blobs/uploads/") && req.Method == http.MethodPatch:
+ id := strings.TrimPrefix(path, "blobs/uploads/")
+ body, _ := io.ReadAll(req.Body)
+ r.uploads[id] = append(r.uploads[id], body...)
+ w.Header().Set("Location", "/v2/engine/blobs/uploads/"+id+"?state=t")
+ w.WriteHeader(http.StatusAccepted)
+ case strings.HasPrefix(path, "blobs/uploads/") && req.Method == http.MethodPut:
+ id := strings.TrimPrefix(path, "blobs/uploads/")
+ digest := req.URL.Query().Get("digest")
+ if "sha256:"+digestOf(r.uploads[id]) != digest {
+ w.WriteHeader(http.StatusBadRequest)
+ return
+ }
+ r.blobs[digest] = r.uploads[id]
+ w.WriteHeader(http.StatusCreated)
+ case strings.HasPrefix(path, "blobs/"):
+ data, ok := r.blobs[strings.TrimPrefix(path, "blobs/")]
+ if !ok {
+ w.WriteHeader(http.StatusNotFound)
+ return
+ }
+ w.Header().Set("Content-Length", strconv.Itoa(len(data)))
+ if req.Method == http.MethodGet {
+ _, _ = w.Write(data)
+ }
+ case strings.HasPrefix(path, "manifests/") && req.Method == http.MethodPut:
+ ref := strings.TrimPrefix(path, "manifests/")
+ body, _ := io.ReadAll(req.Body)
+ r.puts = append(r.puts, ref)
+ r.manifests[ref] = body
+ r.manifests["sha256:"+digestOf(body)] = body
+ w.Header().Set("Docker-Content-Digest", "sha256:"+digestOf(body))
+ w.WriteHeader(http.StatusCreated)
+ case strings.HasPrefix(path, "manifests/"):
+ data, ok := r.manifests[strings.TrimPrefix(path, "manifests/")]
+ if !ok {
+ w.WriteHeader(http.StatusNotFound)
+ return
+ }
+ if r.tamper {
+ data = append(slices.Clone(data), ' ')
+ }
+ w.Header().Set("Content-Type", mediaTypeOCIManifest)
+ w.Header().Set("Docker-Content-Digest", "sha256:"+digestOf(data))
+ _, _ = w.Write(data)
+ default:
+ w.WriteHeader(http.StatusNotFound)
+ }
+}
+
+func TestLockCommandEndToEnd(t *testing.T) {
+ requireXZ(t)
+ reg := newFakeRegistry(t)
+ status := "Package: libbase1\nStatus: install ok installed\nVersion: 2.0-1\n\n"
+ layer := gzipBytes(t, tarBytes(t, []fx{dir("var/"), dir("var/lib/"), dir("var/lib/dpkg/"), file("var/lib/dpkg/status", []byte(status))}))
+ config := []byte(`{"architecture":"arm64","os":"linux","rootfs":{"type":"layers","diff_ids":["sha256:` + strings.Repeat("d", 64) + `"]}}`)
+ reg.blobs["sha256:"+digestOf(layer)] = layer
+ reg.blobs["sha256:"+digestOf(config)] = config
+ manifest := mustJSON(t, map[string]any{
+ "schemaVersion": 2, "mediaType": mediaTypeOCIManifest,
+ "config": map[string]any{"mediaType": mediaTypeOCIConfig, "digest": "sha256:" + digestOf(config), "size": len(config)},
+ "layers": []any{map[string]any{"mediaType": mediaTypeOCILayer, "digest": "sha256:" + digestOf(layer), "size": len(layer)}},
+ })
+ index := mustJSON(t, map[string]any{
+ "schemaVersion": 2, "mediaType": mediaTypeOCIIndex,
+ "manifests": []any{map[string]any{"mediaType": mediaTypeOCIManifest, "digest": "sha256:" + digestOf(manifest), "size": len(manifest), "platform": map[string]any{"architecture": "arm64", "os": "linux"}}},
+ })
+ reg.manifests["sha256:"+digestOf(manifest)] = manifest
+ reg.manifests["sha256:"+digestOf(index)] = index
+
+ packages := map[string]string{
+ "/debian/20261116T000000Z/dists/trixie/main/binary-arm64/Packages.xz": "Package: ffmpeg\nVersion: 1\nArchitecture: arm64\nDepends: libbase1\nFilename: pool/main/f/ffmpeg.deb\nSize: 3\nSHA256: " + strings.Repeat("1", 64) + "\n\nPackage: libbase1\nVersion: 2.0-1\nArchitecture: arm64\nFilename: pool/main/l/libbase1.deb\nSize: 4\nSHA256: " + strings.Repeat("2", 64) + "\n\n",
+ "/debian/20261116T000000Z/dists/trixie-updates/main/binary-arm64/Packages.xz": "",
+ "/debian-security/20261116T000000Z/dists/trixie-security/main/binary-arm64/Packages.xz": "Package: ffmpeg\nVersion: 2\nArchitecture: arm64\nDepends: libbase1\nFilename: pool/updates/main/f/ffmpeg.deb\nSize: 5\nSHA256: " + strings.Repeat("3", 64) + "\n\n",
+ }
+ archive := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
+ body, ok := packages[req.URL.Path]
+ if !ok {
+ w.WriteHeader(http.StatusNotFound)
+ return
+ }
+ _, _ = w.Write(xzBytes(t, []byte(body)))
+ }))
+ defer archive.Close()
+
+ out := filepath.Join(t.TempDir(), "debs.lock")
+ ref := reg.host() + "/engine@sha256:" + digestOf(index)
+ err := writeLock(t.Context(), lockOptions{Snapshot: "20261116T000000Z", Base: ref, Out: out, Archive: archive.URL})
+ if err != nil {
+ t.Fatal(err)
+ }
+ data, err := os.ReadFile(out)
+ if err != nil {
+ t.Fatal(err)
+ }
+ want := "# snapshot 20261116T000000Z\n# base " + ref + "\n" +
+ "ffmpeg\t2\t" + archive.URL + "/debian-security/20261116T000000Z/pool/updates/main/f/ffmpeg.deb\t" + strings.Repeat("3", 64) + "\t5\n"
+ if string(data) != want {
+ t.Fatalf("lock:\n%s\nwant:\n%s", data, want)
+ }
+}
+
+// TestRegistryAnswersAnAnonymousChallenge: Docker Hub answers a first pull
+// 401 and names the token service to ask.
+func TestRegistryAnswersAnAnonymousChallenge(t *testing.T) {
+ var srv *httptest.Server
+ srv = httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
+ switch {
+ case req.URL.Path == "/token":
+ if req.URL.Query().Get("service") != "registry.test" || req.URL.Query().Get("scope") != "repository:engine:pull" {
+ w.WriteHeader(http.StatusBadRequest)
+ return
+ }
+ _, _ = w.Write([]byte(`{"token":"anon-token"}`))
+ case req.Header.Get("Authorization") == "Bearer anon-token":
+ _, _ = w.Write([]byte("manifest"))
+ default:
+ w.Header().Set("WWW-Authenticate", `Bearer realm="`+srv.URL+`/token",service="registry.test",scope="repository:engine:pull"`)
+ w.WriteHeader(http.StatusUnauthorized)
+ }
+ }))
+ defer srv.Close()
+ reg := &registry{base: srv.URL, repo: "engine"}
+ body, err := reg.get(t.Context(), "manifests/x")
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer body.Close()
+ data, err := io.ReadAll(body)
+ if err != nil || string(data) != "manifest" {
+ t.Fatalf("body = %q, %v", data, err)
+ }
+}
+
+func requireXZ(t *testing.T) {
+ t.Helper()
+ if _, err := exec.LookPath("xz"); err != nil {
+ if os.Getenv("CI") != "" {
+ t.Fatal("xz is required in CI")
+ }
+ t.Skip("no xz on this machine")
+ }
+}
+
+func xzBytes(t *testing.T, data []byte) []byte {
+ t.Helper()
+ cmd := exec.Command("xz", "-c")
+ cmd.Stdin = bytes.NewReader(data)
+ out, err := cmd.Output()
+ if err != nil {
+ t.Errorf("xz: %v", err)
+ }
+ return out
+}
+
+func TestBuildIsDeterministic(t *testing.T) {
+ f := newFixture(t)
+ first := f.build(t)
+ second := filepath.Join(t.TempDir(), "again")
+ o := f.options()
+ o.Out = second
+ again, err := buildImage(t.Context(), o)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if first != again {
+ t.Fatalf("image info differs: %+v and %+v", first, again)
+ }
+ if want := treeDigests(t, f.out); !equalMaps(want, treeDigests(t, second)) {
+ t.Fatalf("the two layouts differ:\n%v\n%v", want, treeDigests(t, second))
+ }
+ o.Created = "2026-11-17T10:00:00Z"
+ o.Out = filepath.Join(t.TempDir(), "later")
+ later, err := buildImage(t.Context(), o)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if later.Digest == first.Digest {
+ t.Fatal("a different --created gave the same digest")
+ }
+}
+
+func treeDigests(t *testing.T, root string) map[string]string {
+ t.Helper()
+ sums := map[string]string{}
+ err := filepath.WalkDir(root, func(path string, d os.DirEntry, err error) error {
+ if err != nil || d.IsDir() {
+ return err
+ }
+ data, err := os.ReadFile(path)
+ if err != nil {
+ return err
+ }
+ rel, _ := filepath.Rel(root, path)
+ sums[rel] = digestOf(data)
+ return nil
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ return sums
+}
+
+func equalMaps(a, b map[string]string) bool {
+ if len(a) != len(b) {
+ return false
+ }
+ for k, v := range a {
+ if b[k] != v {
+ return false
+ }
+ }
+ return true
+}
+
+func TestBuildRefusesABadDebHash(t *testing.T) {
+ t.Run("a cached deb that is not the locked one", func(t *testing.T) {
+ f := newFixture(t)
+ l := f.write(t)
+ if err := os.WriteFile(filepath.Join(f.cache, "blobs", "sha256", l.Entries[0].SHA256), []byte("not the deb"), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := buildImage(t.Context(), f.options()); !errors.Is(err, errBadHash) {
+ t.Fatalf("build = %v, want errBadHash", err)
+ }
+ if _, err := os.Stat(f.out); !errors.Is(err, os.ErrNotExist) {
+ t.Fatalf("a refused build left %s", f.out)
+ }
+ })
+ t.Run("a download that is not the locked one", func(t *testing.T) {
+ f := newFixture(t)
+ l := f.write(t)
+ srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
+ _, _ = w.Write(make([]byte, l.Entries[0].Size))
+ }))
+ defer srv.Close()
+ l.Entries[0].URL = srv.URL + "/ffmpeg.deb"
+ path := filepath.Join(f.cache, "blobs", "sha256", l.Entries[0].SHA256)
+ if err := os.Remove(path); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(f.lock, l.render(), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := buildImage(t.Context(), f.options()); !errors.Is(err, errBadHash) {
+ t.Fatalf("build = %v, want errBadHash", err)
+ }
+ if _, err := os.Stat(path); !errors.Is(err, os.ErrNotExist) {
+ t.Fatal("the bad download stayed in the cache")
+ }
+ })
+ t.Run("a base layer that is not the pinned one", func(t *testing.T) {
+ f := newFixture(t)
+ f.write(t)
+ m := baseManifest(t, f)
+ if err := os.WriteFile(blobPath(f.cache, m.Layers[0].Digest), []byte("tampered"), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := buildImage(t.Context(), f.options()); !errors.Is(err, errBadHash) {
+ t.Fatalf("build = %v, want errBadHash", err)
+ }
+ })
+}
+
+func baseManifest(t *testing.T, f *fixture) ociManifest {
+ t.Helper()
+ data, err := os.ReadFile(f.lock)
+ if err != nil {
+ t.Fatal(err)
+ }
+ l, err := parseLock(data)
+ if err != nil {
+ t.Fatal(err)
+ }
+ _, digest, _ := strings.Cut(l.Base, "@")
+ var index ociIndex
+ readJSONFile(t, blobPath(f.cache, digest), &index)
+ var m ociManifest
+ readJSONFile(t, blobPath(f.cache, index.Manifests[1].Digest), &m)
+ return m
+}
+
+func TestImageConfig(t *testing.T) {
+ f := newFixture(t)
+ l := f.write(t)
+ info, err := buildImage(t.Context(), f.options())
+ if err != nil {
+ t.Fatal(err)
+ }
+ m, c := readLayout(t, f.out)
+ if c.Architecture != "arm64" || c.OS != "linux" {
+ t.Fatalf("platform = %s/%s", c.OS, c.Architecture)
+ }
+ if !slices.Equal(c.Config.Entrypoint, []string{media.EngineEntryPoint}) {
+ t.Fatalf("entrypoint = %v", c.Config.Entrypoint)
+ }
+ if len(c.Config.Cmd) != 0 {
+ t.Fatalf("cmd = %v, want the base's dropped", c.Config.Cmd)
+ }
+ if c.Config.User != "65534:65534" {
+ t.Fatalf("user = %q", c.Config.User)
+ }
+ if _, ok := c.Config.Volumes["/scratch"]; !ok || len(c.Config.Volumes) != 1 {
+ t.Fatalf("volumes = %v", c.Config.Volumes)
+ }
+ if !slices.Contains(c.Config.Env, "PATH=/usr/local/bin:/usr/bin") {
+ t.Fatalf("env = %v, want the base's PATH", c.Config.Env)
+ }
+ wantLabels := map[string]string{
+ "org.opencontainers.image.created": testCreated,
+ "io.carlosframework.ffmpeg": "7:7.1.5-0+deb13u1",
+ "io.carlosframework.debs-lock": digestOf(l.render()),
+ }
+ if !equalMaps(c.Config.Labels, wantLabels) {
+ t.Fatalf("labels = %v\nwant %v", c.Config.Labels, wantLabels)
+ }
+ if len(c.RootFS.DiffIDs) != len(m.Layers) {
+ t.Fatalf("%d diff ids for %d layers", len(c.RootFS.DiffIDs), len(m.Layers))
+ }
+ for i, l := range m.Layers {
+ blob, err := os.ReadFile(blobPath(f.out, l.Digest))
+ if err != nil {
+ t.Fatal(err)
+ }
+ gz, err := gzip.NewReader(bytes.NewReader(blob))
+ if err != nil {
+ t.Fatal(err)
+ }
+ raw, err := io.ReadAll(gz)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if got := "sha256:" + digestOf(raw); got != c.RootFS.DiffIDs[i] {
+ t.Fatalf("layer %d diff id = %s, config says %s", i, got, c.RootFS.DiffIDs[i])
+ }
+ if l.MediaType != mediaTypeOCILayer {
+ t.Fatalf("layer %d media type = %s", i, l.MediaType)
+ }
+ }
+
+ debs, top := builtEntries(t, f.out)
+ scratch, ok := top["scratch/"]
+ if !ok {
+ t.Fatalf("no scratch entry in %v", top)
+ }
+ if scratch.hdr.Typeflag != tar.TypeDir || scratch.hdr.Uid != 65534 || scratch.hdr.Gid != 65534 || scratch.hdr.Mode != 0o700 {
+ t.Fatalf("scratch = type %c uid %d gid %d mode %o", scratch.hdr.Typeflag, scratch.hdr.Uid, scratch.hdr.Gid, scratch.hdr.Mode)
+ }
+ binary, ok := top["usr/local/bin/carlos-media"]
+ if !ok {
+ t.Fatalf("no binary entry in %v", top)
+ }
+ if binary.hdr.Mode != 0o755 || binary.hdr.Uid != 0 || binary.hdr.Gid != 0 {
+ t.Fatalf("binary = mode %o uid %d gid %d", binary.hdr.Mode, binary.hdr.Uid, binary.hdr.Gid)
+ }
+ want, err := os.ReadFile(f.binary)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(binary.body, want) {
+ t.Fatal("the layer's binary is not the given binary")
+ }
+ var names []string
+ for name, e := range debs {
+ names = append(names, name)
+ if e.hdr.Uid != 0 || e.hdr.Gid != 0 || e.hdr.Uname != "" || e.hdr.Gname != "" {
+ t.Fatalf("%s is owned %d:%d %q:%q", name, e.hdr.Uid, e.hdr.Gid, e.hdr.Uname, e.hdr.Gname)
+ }
+ if got := e.hdr.ModTime.UTC().Format("2006-01-02T15:04:05Z"); got != testCreated {
+ t.Fatalf("%s mtime = %s", name, got)
+ }
+ }
+ m2, _ := readLayout(t, f.out)
+ var ordered []string
+ for _, e := range readLayer(t, f.out, m2.Layers[1].Digest) {
+ ordered = append(ordered, e.hdr.Name)
+ }
+ if !slices.IsSorted(ordered) {
+ t.Fatalf("deb layer is not sorted: %v", ordered)
+ }
+
+ var saved media.ImageInfo
+ readJSONFile(t, filepath.Join(f.out, "image.json"), &saved)
+ if saved != info || saved.BuiltAt != testCreated || saved.FFmpeg != "7:7.1.5-0+deb13u1" {
+ t.Fatalf("image.json = %+v, build said %+v", saved, info)
+ }
+ var index ociIndex
+ readJSONFile(t, filepath.Join(f.out, "index.json"), &index)
+ if saved.Digest != index.Manifests[0].Digest {
+ t.Fatalf("image.json digest %s, index %s", saved.Digest, index.Manifests[0].Digest)
+ }
+ var layout map[string]string
+ readJSONFile(t, filepath.Join(f.out, "oci-layout"), &layout)
+ if layout["imageLayoutVersion"] != "1.0.0" {
+ t.Fatalf("oci-layout = %v", layout)
+ }
+}
+
+// TestBuildReplacesOnlyALayout: --out may name an earlier build, never a
+// directory that holds something else.
+func TestBuildReplacesOnlyALayout(t *testing.T) {
+ f := newFixture(t)
+ f.build(t)
+ stale := filepath.Join(f.out, "stale")
+ if err := os.WriteFile(stale, []byte("x"), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := buildImage(t.Context(), f.options()); err != nil {
+ t.Fatalf("a rebuild over a layout: %v", err)
+ }
+ if _, err := os.Stat(stale); !errors.Is(err, os.ErrNotExist) {
+ t.Fatal("the rebuild kept a file of the old layout")
+ }
+
+ o := f.options()
+ o.Out = t.TempDir()
+ keep := filepath.Join(o.Out, "precious")
+ if err := os.WriteFile(keep, []byte("x"), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := buildImage(t.Context(), o); err == nil {
+ t.Fatal("a build replaced a directory that is not a layout")
+ }
+ if _, err := os.Stat(keep); err != nil {
+ t.Fatalf("the directory lost its file: %v", err)
+ }
+}
+
+func TestBuildRefusesABadCreatedTime(t *testing.T) {
+ f := newFixture(t)
+ f.write(t)
+ o := f.options()
+ o.Created = "yesterday"
+ if _, err := buildImage(t.Context(), o); err == nil {
+ t.Fatal("a build with no valid --created succeeded")
+ }
+}
+
+func TestBuildMovesMergedUsrEntries(t *testing.T) {
+ f := newFixture(t)
+ f.debs["libmoved"] = []fx{
+ dir("./bin/"), dir("./sbin/"), dir("./lib64/"),
+ file("./bin/tool", []byte("tool")),
+ file("./sbin/admin", []byte("admin")),
+ file("./lib64/extra", []byte("extra")),
+ // A relative link that must keep pointing at the same file once
+ // its own directory moved.
+ symlink("./bin/tool-link", "../usr/share/tool/real"),
+ // An alias of the file's own merged path, which would loop.
+ file("./usr/bin/same", []byte("same")),
+ symlink("./bin/same", "/usr/bin/same"),
+ }
+ f.build(t)
+ debs, _ := builtEntries(t, f.out)
+ for _, name := range []string{"usr/bin/tool", "usr/sbin/admin", "usr/lib64/extra", multiarch + "libavcodec.so.61.19.101"} {
+ if _, ok := debs[name]; !ok {
+ t.Errorf("no %s in the layer", name)
+ }
+ }
+ for name := range debs {
+ first, _, _ := strings.Cut(name, "/")
+ if first == "bin" || first == "sbin" || strings.HasPrefix(first, "lib") {
+ t.Errorf("%s stayed outside /usr", name)
+ }
+ }
+ if got := debs["usr/bin/tool-link"].hdr.Linkname; got != "../share/tool/real" {
+ t.Errorf("moved link points at %q, want ../share/tool/real", got)
+ }
+ if e := debs["usr/bin/same"]; e.hdr.Typeflag != tar.TypeReg || string(e.body) != "same" {
+ t.Errorf("usr/bin/same = type %c %q, want the file and not its alias", e.hdr.Typeflag, e.body)
+ }
+}
+
+func TestBuildNeverWritesADirectoryOverABaseSymlink(t *testing.T) {
+ f := newFixture(t)
+ f.base = append(f.base, dir("usr/share/real/"), symlink("usr/share/alias", "real"))
+ f.debs["libdirs"] = []fx{
+ dir("./lib/"), dir("./bin/"), dir("./usr/share/alias/"),
+ file("./usr/share/alias/data", []byte("data")),
+ }
+ f.build(t)
+ debs, _ := builtEntries(t, f.out)
+ for name, e := range debs {
+ if e.hdr.Typeflag != tar.TypeDir {
+ continue
+ }
+ clean := strings.TrimSuffix(name, "/")
+ if slices.Contains([]string{"bin", "lib", "sbin", "usr/lib", "usr/bin", "usr/share/alias"}, clean) {
+ t.Errorf("the layer holds a directory entry for %s", name)
+ }
+ }
+ if _, ok := debs["usr/share/real/data"]; !ok {
+ t.Error("a file under a base symlink did not follow it")
+ }
+ if _, ok := debs["usr/share/alias/data"]; ok {
+ t.Error("a file was written through the alias path")
+ }
+}
+
+func TestBuildMaterialisesHardlinks(t *testing.T) {
+ f := newFixture(t)
+ f.debs["libhard"] = []fx{
+ file("./usr/share/zz-target", []byte("shared")),
+ {name: "./usr/share/aa-link", typ: tar.TypeLink, mode: 0o644, link: "./usr/share/zz-target"},
+ }
+ f.build(t)
+ debs, _ := builtEntries(t, f.out)
+ e, ok := debs["usr/share/aa-link"]
+ if !ok || e.hdr.Typeflag != tar.TypeReg || string(e.body) != "shared" {
+ t.Fatalf("aa-link = %+v, want a regular copy of its target", e)
+ }
+}
+
+func TestBuildRefusesAnUnresolvedLibrary(t *testing.T) {
+ cases := map[string]func(t *testing.T, f *fixture){
+ "a library no package ships": func(t *testing.T, f *fixture) {
+ f.debs["ffmpeg"][2].body = arm(t, "libnowhere.so.1")
+ },
+ "a dangling soname link": func(t *testing.T, f *fixture) {
+ f.debs["libavcodec61"] = []fx{symlink("./usr/lib/aarch64-linux-gnu/libavcodec.so.61", "libavcodec.so.61.19.101")}
+ },
+ "a library of another architecture": func(t *testing.T, f *fixture) {
+ f.debs["libavcodec61"] = []fx{file("./usr/lib/aarch64-linux-gnu/libavcodec.so.61", elfBytes(t, elf.EM_X86_64))}
+ },
+ }
+ for name, mutate := range cases {
+ t.Run(name, func(t *testing.T) {
+ f := newFixture(t)
+ mutate(t, f)
+ if err := f.buildErr(t); !errors.Is(err, errUnresolvedLibrary) {
+ t.Fatalf("build = %v, want errUnresolvedLibrary", err)
+ }
+ })
+ }
+}
+
+// TestBuildLeavesOutTheUnloadablePlugin: libcaca0's OpenGL plugin needs
+// libraries the package does not depend on. Every other file stays.
+func TestBuildLeavesOutTheUnloadablePlugin(t *testing.T) {
+ f := newFixture(t)
+ f.debs["libcaca0"] = []fx{
+ file("./usr/lib/aarch64-linux-gnu/caca/libgl_plugin.so.0.0.0", arm(t, "libGLU.so.1", "libglut.so.3")),
+ symlink("./usr/lib/aarch64-linux-gnu/caca/libgl_plugin.so.0", "libgl_plugin.so.0.0.0"),
+ symlink("./usr/lib/aarch64-linux-gnu/caca/libgl_plugin.so", "libgl_plugin.so.0.0.0"),
+ file("./usr/lib/aarch64-linux-gnu/caca/libx11_plugin.so.0.0.0", arm(t, "libc.so.6")),
+ }
+ f.build(t)
+ debs, _ := builtEntries(t, f.out)
+ for name := range debs {
+ if strings.Contains(name, "libgl_plugin") {
+ t.Errorf("%s is in the image", name)
+ }
+ }
+ if _, ok := debs[multiarch+"caca/libx11_plugin.so.0.0.0"]; !ok {
+ t.Error("the plugin that can load was left out")
+ }
+}
+
+func TestBuildCreatesTheAlternativesLinks(t *testing.T) {
+ f := newFixture(t)
+ f.debs["ffmpeg"][2].body = arm(t, "libblas.so.3", "liblapack.so.3", "libavcodec.so.61", "libc.so.6")
+ // Debian ships each target as a symlink to the versioned file.
+ f.debs["libblas3"] = []fx{
+ file("./usr/lib/aarch64-linux-gnu/blas/libblas.so.3.12.1", arm(t, "libc.so.6")),
+ symlink("./usr/lib/aarch64-linux-gnu/blas/libblas.so.3", "libblas.so.3.12.1"),
+ }
+ f.debs["liblapack3"] = []fx{
+ file("./usr/lib/aarch64-linux-gnu/lapack/liblapack.so.3.12.1", arm(t, "libblas.so.3", "libc.so.6")),
+ symlink("./usr/lib/aarch64-linux-gnu/lapack/liblapack.so.3", "liblapack.so.3.12.1"),
+ }
+ f.build(t)
+ debs, _ := builtEntries(t, f.out)
+ if got := debs[multiarch+"libblas.so.3"].hdr.Linkname; got != "blas/libblas.so.3" {
+ t.Errorf("libblas.so.3 -> %q", got)
+ }
+ if got := debs[multiarch+"liblapack.so.3"].hdr.Linkname; got != "lapack/liblapack.so.3" {
+ t.Errorf("liblapack.so.3 -> %q", got)
+ }
+}
+
+func TestBuildRefusesAnAlternativeWhoseTargetIsGone(t *testing.T) {
+ f := newFixture(t)
+ f.debs["libblas3"] = []fx{file("./usr/share/doc/libblas3/copyright", []byte("c"))}
+ if err := f.buildErr(t); !errors.Is(err, errUnresolvedLibrary) {
+ t.Fatalf("build = %v, want errUnresolvedLibrary", err)
+ }
+}
+
+func TestBuildRefusesHostileDebEntries(t *testing.T) {
+ cases := map[string]struct {
+ files []fx
+ want error
+ }{
+ "parent traversal": {[]fx{file("./usr/../../etc/passwd", []byte("x"))}, errBadEntry},
+ "absolute path": {[]fx{file("/etc/passwd", []byte("x"))}, errBadEntry},
+ "whiteout": {[]fx{file("./usr/share/.wh.secret", []byte(""))}, errBadEntry},
+ "opaque whiteout": {[]fx{file("./usr/share/.wh..wh..opq", []byte(""))}, errBadEntry},
+ "device node": {[]fx{{name: "./dev/null", typ: tar.TypeChar, mode: 0o666}}, errBadEntry},
+ "hardlink outside": {[]fx{{name: "./usr/share/l", typ: tar.TypeLink, mode: 0o644, link: "./etc/shadow"}}, errBadEntry},
+ "file over a base directory": {[]fx{file("./usr/share", []byte("x"))}, errConflict},
+ "link over a base directory": {[]fx{symlink("./usr/local", "share")}, errConflict},
+ }
+ for name, c := range cases {
+ t.Run(name, func(t *testing.T) {
+ f := newFixture(t)
+ f.debs["libhostile"] = c.files
+ if err := f.buildErr(t); !errors.Is(err, c.want) {
+ t.Fatalf("build = %v, want %v", err, c.want)
+ }
+ })
+ }
+}
+
+func TestBuildRefusesTwoPackagesDisagreeingOnAFile(t *testing.T) {
+ f := newFixture(t)
+ f.debs["libone"] = []fx{file("./usr/share/clash", []byte("one"))}
+ f.debs["libtwo"] = []fx{file("./usr/share/clash", []byte("two"))}
+ if err := f.buildErr(t); !errors.Is(err, errConflict) {
+ t.Fatalf("build = %v, want errConflict", err)
+ }
+
+ same := newFixture(t)
+ same.debs["libone"] = []fx{file("./usr/share/agree", []byte("same"))}
+ same.debs["libtwo"] = []fx{file("./usr/share/agree", []byte("same"))}
+ same.build(t)
+}
+
+func TestBuildRefusesAnImageThatCannotRun(t *testing.T) {
+ t.Run("no ffprobe", func(t *testing.T) {
+ f := newFixture(t)
+ f.debs["ffmpeg"] = slices.Delete(slices.Clone(f.debs["ffmpeg"]), 3, 4)
+ if err := f.buildErr(t); !errors.Is(err, errMissingExecutable) {
+ t.Fatalf("build = %v, want errMissingExecutable", err)
+ }
+ })
+ t.Run("ffmpeg for the wrong architecture", func(t *testing.T) {
+ f := newFixture(t)
+ f.debs["ffmpeg"][2].body = elfBytes(t, elf.EM_X86_64)
+ if err := f.buildErr(t); !errors.Is(err, errMissingExecutable) {
+ t.Fatalf("build = %v, want errMissingExecutable", err)
+ }
+ })
+ t.Run("a carlos-media for the wrong architecture", func(t *testing.T) {
+ f := newFixture(t)
+ if err := os.WriteFile(f.binary, elfBytes(t, elf.EM_X86_64), 0o755); err != nil {
+ t.Fatal(err)
+ }
+ if err := f.buildErr(t); !errors.Is(err, errMissingExecutable) {
+ t.Fatalf("build = %v, want errMissingExecutable", err)
+ }
+ })
+ t.Run("a lock with no ffmpeg", func(t *testing.T) {
+ f := newFixture(t)
+ f.debs["libother"] = f.debs["ffmpeg"]
+ delete(f.debs, "ffmpeg")
+ if err := f.buildErr(t); !errors.Is(err, errBadLock) {
+ t.Fatalf("build = %v, want errBadLock", err)
+ }
+ })
+}
+
+func TestBuildUnpacksAnXZDeb(t *testing.T) {
+ requireXZ(t)
+ data := arBytes(
+ fx{name: "debian-binary", body: []byte("2.0\n")},
+ fx{name: "control.tar.xz", body: xzBytes(t, tarBytes(t, nil))},
+ fx{name: "data.tar.xz", body: xzBytes(t, tarBytes(t, []fx{file("./usr/share/from-xz", []byte("xz"))}))},
+ )
+ got, err := readDeb(t.Context(), bytes.NewReader(data))
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer got.Close()
+ h, err := tar.NewReader(got).Next()
+ if err != nil || h.Name != "./usr/share/from-xz" {
+ t.Fatalf("first entry = %+v, %v", h, err)
+ }
+}
+
+// TestXZReaderReportsADamagedStream: a damaged package must fail the build,
+// not end its file list early.
+func TestXZReaderReportsADamagedStream(t *testing.T) {
+ requireXZ(t)
+ data := xzBytes(t, bytes.Repeat([]byte("carlos media "), 4096))
+ r, err := xzReader(t.Context(), bytes.NewReader(data[:len(data)/2]))
+ if err != nil {
+ t.Fatal(err)
+ }
+ defer r.Close()
+ if _, err := io.Copy(io.Discard, r); err == nil {
+ t.Fatal("a cut xz stream read to the end without an error")
+ }
+}
+
+func TestReadDebRefusesAnUnknownCompression(t *testing.T) {
+ data := arBytes(fx{name: "debian-binary", body: []byte("2.0\n")}, fx{name: "data.tar.zst", body: []byte("zstd")})
+ if _, err := readDeb(t.Context(), bytes.NewReader(data)); !errors.Is(err, errBadDeb) {
+ t.Fatalf("readDeb = %v, want errBadDeb", err)
+ }
+}
+
+func pushOptionsFor(reg *fakeRegistry, layout, tag string) pushOptions {
+ return pushOptions{Layout: layout, Repo: reg.host() + "/engine", Tag: tag, Password: "s3cret"}
+}
+
+func TestPushUnderTheReleaseTag(t *testing.T) {
+ f := newFixture(t)
+ info := f.build(t)
+ reg := newFakeRegistry(t)
+ reg.password = "s3cret"
+
+ digest, err := pushImage(t.Context(), pushOptionsFor(reg, f.out, "v0.40.0"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if digest != info.Digest {
+ t.Fatalf("push printed %s, the build made %s", digest, info.Digest)
+ }
+ if !slices.Equal(reg.puts, []string{"v0.40.0"}) {
+ t.Fatalf("manifest pushed as %v, want only the release tag", reg.puts)
+ }
+ m, _ := readLayout(t, f.out)
+ for _, d := range append([]ociDescriptor{m.Config}, m.Layers...) {
+ want, err := os.ReadFile(blobPath(f.out, d.Digest))
+ if err != nil {
+ t.Fatal(err)
+ }
+ if !bytes.Equal(reg.blobs[d.Digest], want) {
+ t.Fatalf("blob %s did not arrive intact", d.Digest)
+ }
+ }
+
+ // The same image under the same tag is a repeat of a finished push.
+ again, err := pushImage(t.Context(), pushOptionsFor(reg, f.out, "v0.40.0"))
+ if err != nil || again != info.Digest {
+ t.Fatalf("repeat push = %s, %v", again, err)
+ }
+ if len(reg.puts) != 1 {
+ t.Fatalf("a repeat push wrote the tag again: %v", reg.puts)
+ }
+}
+
+func TestPushRefusesAReusedTag(t *testing.T) {
+ f := newFixture(t)
+ f.build(t)
+ reg := newFakeRegistry(t)
+ reg.manifests["v0.40.0"] = []byte(`{"schemaVersion":2}`)
+ _, err := pushImage(t.Context(), pushOptionsFor(reg, f.out, "v0.40.0"))
+ if !errors.Is(err, errTagReused) {
+ t.Fatalf("push = %v, want errTagReused", err)
+ }
+ if len(reg.puts) != 0 {
+ t.Fatalf("the manifest was written: %v", reg.puts)
+ }
+}
+
+func TestPushVerifiesTheDigestTheRegistryHolds(t *testing.T) {
+ f := newFixture(t)
+ f.build(t)
+ reg := newFakeRegistry(t)
+ reg.tamper = true
+ _, err := pushImage(t.Context(), pushOptionsFor(reg, f.out, "v0.40.0"))
+ if !errors.Is(err, errDigestMismatch) {
+ t.Fatalf("push = %v, want errDigestMismatch", err)
+ }
+}
+
+func TestPushRefusals(t *testing.T) {
+ f := newFixture(t)
+ f.build(t)
+ reg := newFakeRegistry(t)
+ for name, mutate := range map[string]func(o *pushOptions){
+ "no password": func(o *pushOptions) { o.Password = "" },
+ "no tag": func(o *pushOptions) { o.Tag = "" },
+ "a digest as tag": func(o *pushOptions) { o.Tag = "sha256:abc" },
+ "no repository": func(o *pushOptions) { o.Repo = "engine" },
+ "plain http remote": func(o *pushOptions) { o.Repo = "http://registry.invalid/engine" },
+ } {
+ t.Run(name, func(t *testing.T) {
+ o := pushOptionsFor(reg, f.out, "v0.40.0")
+ mutate(&o)
+ if _, err := pushImage(t.Context(), o); !errors.Is(err, errBadPush) {
+ t.Fatalf("push = %v, want errBadPush", err)
+ }
+ if len(reg.puts) != 0 || len(reg.blobs) != 0 {
+ t.Fatal("a refused push reached the registry")
+ }
+ })
+ }
+}
+
+func TestPushRefusesACorruptLayout(t *testing.T) {
+ f := newFixture(t)
+ f.build(t)
+ m, _ := readLayout(t, f.out)
+ if err := os.WriteFile(blobPath(f.out, m.Layers[2].Digest), []byte("tampered"), 0o644); err != nil {
+ t.Fatal(err)
+ }
+ reg := newFakeRegistry(t)
+ if _, err := pushImage(t.Context(), pushOptionsFor(reg, f.out, "v0.40.0")); !errors.Is(err, errBadHash) {
+ t.Fatalf("push = %v, want errBadHash", err)
+ }
+ if len(reg.puts) != 0 {
+ t.Fatalf("the manifest was written: %v", reg.puts)
+ }
+}
+
+// TestCommandLine drives the commands as make and an operator do.
+func TestCommandLine(t *testing.T) {
+ f := newFixture(t)
+ f.write(t)
+ reg := newFakeRegistry(t)
+ reg.password = "from-the-environment"
+ getenv := func(name string) string {
+ if name == "CARLOS_REGISTRY_PASSWORD" {
+ return reg.password
+ }
+ return ""
+ }
+ var out, errs bytes.Buffer
+ err := run(t.Context(), []string{"build", "--lock", f.lock, "--binary", f.binary, "--created", testCreated, "--cache", f.cache, "--out", f.out}, &out, &errs, getenv)
+ if err != nil {
+ t.Fatalf("build: %v (%s)", err, errs.String())
+ }
+ digest := strings.TrimSpace(out.String())
+ if !strings.HasPrefix(digest, "sha256:") {
+ t.Fatalf("build printed %q", digest)
+ }
+ out.Reset()
+ err = run(t.Context(), []string{"push", "--layout", f.out, "--repo", reg.host() + "/engine", "--tag", "v0.40.0"}, &out, &errs, getenv)
+ if err != nil {
+ t.Fatalf("push: %v (%s)", err, errs.String())
+ }
+ if got := strings.TrimSpace(out.String()); got != digest {
+ t.Fatalf("push printed %q, want %q", got, digest)
+ }
+ for _, args := range [][]string{nil, {"unknown"}, {"build", "stray"}, {"push", "--no-such-flag"}} {
+ if err := run(t.Context(), args, &out, &errs, getenv); !errors.Is(err, errUsage) {
+ t.Errorf("run(%v) = %v, want errUsage", args, err)
+ }
+ }
+}
+
+func TestPushErrorsCarryNoPassword(t *testing.T) {
+ f := newFixture(t)
+ f.build(t)
+ reg := newFakeRegistry(t)
+ reg.password = "the-right-one"
+ o := pushOptionsFor(reg, f.out, "v0.40.0")
+ o.Password = "wrong-s3cret-value"
+ _, err := pushImage(t.Context(), o)
+ if err == nil {
+ t.Fatal("a push with the wrong password succeeded")
+ }
+ if strings.Contains(err.Error(), o.Password) {
+ t.Fatalf("the error carries the password: %v", err)
+ }
+}
diff --git a/cmd/mediaimage/oci.go b/cmd/mediaimage/oci.go
new file mode 100644
index 000000000..ed1191a16
--- /dev/null
+++ b/cmd/mediaimage/oci.go
@@ -0,0 +1,454 @@
+package main
+
+import (
+ "context"
+ "crypto/sha256"
+ "encoding/hex"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io"
+ "net"
+ "net/http"
+ "net/url"
+ "os"
+ "path/filepath"
+ "regexp"
+ "strings"
+ "time"
+)
+
+const (
+ mediaTypeOCIManifest = "application/vnd.oci.image.manifest.v1+json"
+ mediaTypeOCIIndex = "application/vnd.oci.image.index.v1+json"
+ mediaTypeOCIConfig = "application/vnd.oci.image.config.v1+json"
+ mediaTypeOCILayer = "application/vnd.oci.image.layer.v1.tar+gzip"
+ mediaTypeDockerManifest = "application/vnd.docker.distribution.manifest.v2+json"
+ mediaTypeDockerList = "application/vnd.docker.distribution.manifest.list.v2+json"
+ mediaTypeDockerLayer = "application/vnd.docker.image.rootfs.diff.tar.gzip"
+
+ // maxManifestBytes bounds a manifest, an index or an image config.
+ maxManifestBytes = 4 << 20
+ // requestTimeout bounds one registry or archive call, a whole layer's
+ // transfer included.
+ requestTimeout = 30 * time.Minute
+ retryAttempts = 5
+)
+
+var (
+ // errBadHash is content whose sha256 is not the pinned one.
+ errBadHash = errors.New("sha256 mismatch")
+ // errBadBase is a base image this tool cannot use.
+ errBadBase = errors.New("bad base image")
+)
+
+type ociPlatform struct {
+ Architecture string `json:"architecture"`
+ OS string `json:"os"`
+ Variant string `json:"variant,omitempty"`
+}
+
+type ociDescriptor struct {
+ MediaType string `json:"mediaType"`
+ Digest string `json:"digest"`
+ Size int64 `json:"size"`
+ Platform *ociPlatform `json:"platform,omitempty"`
+}
+
+type ociManifest struct {
+ SchemaVersion int `json:"schemaVersion"`
+ MediaType string `json:"mediaType"`
+ Config ociDescriptor `json:"config"`
+ Layers []ociDescriptor `json:"layers"`
+}
+
+type ociIndex struct {
+ SchemaVersion int `json:"schemaVersion"`
+ MediaType string `json:"mediaType"`
+ Manifests []ociDescriptor `json:"manifests"`
+}
+
+type ociImageConfig struct {
+ User string `json:"User,omitempty"`
+ Env []string `json:"Env,omitempty"`
+ Entrypoint []string `json:"Entrypoint,omitempty"`
+ Cmd []string `json:"Cmd,omitempty"`
+ Volumes map[string]struct{} `json:"Volumes,omitempty"`
+ Labels map[string]string `json:"Labels,omitempty"`
+}
+
+type ociRootFS struct {
+ Type string `json:"type"`
+ DiffIDs []string `json:"diff_ids"`
+}
+
+type ociConfig struct {
+ Created string `json:"created,omitempty"`
+ Architecture string `json:"architecture"`
+ OS string `json:"os"`
+ Config ociImageConfig `json:"config"`
+ RootFS ociRootFS `json:"rootfs"`
+}
+
+// imageRef is an image pinned by digest.
+type imageRef struct{ Host, Repo, Digest string }
+
+var imageRefPattern = regexp.MustCompile(`^([a-zA-Z0-9.-]+(?::[0-9]+)?)/([a-z0-9._/-]+)@(sha256:[0-9a-f]{64})$`)
+
+// parseImageRef reads <registry>/<repo>@sha256:<digest>. A tag is refused:
+// a build's inputs are pinned.
+func parseImageRef(s string) (imageRef, error) {
+ m := imageRefPattern.FindStringSubmatch(s)
+ if m == nil {
+ return imageRef{}, fmt.Errorf("%w: %q is not <registry>/<repo>@sha256:<digest>", errBadBase, s)
+ }
+ return imageRef{Host: m[1], Repo: m[2], Digest: m[3]}, nil
+}
+
+// isLoopback reports whether host (with or without a port) is this machine.
+func isLoopback(host string) bool {
+ if h, _, err := net.SplitHostPort(host); err == nil {
+ host = h
+ }
+ if host == "localhost" {
+ return true
+ }
+ ip := net.ParseIP(host)
+ return ip != nil && ip.IsLoopback()
+}
+
+// registryBase is a registry's URL root. Only this machine is spoken to in
+// the clear.
+func registryBase(host string) string {
+ switch {
+ case host == "docker.io":
+ return "https://registry-1.docker.io"
+ case isLoopback(host):
+ return "http://" + host
+ }
+ return "https://" + host
+}
+
+var httpClient = &http.Client{Transport: &http.Transport{
+ Proxy: http.ProxyFromEnvironment,
+ TLSHandshakeTimeout: 30 * time.Second,
+ ResponseHeaderTimeout: 2 * time.Minute,
+ IdleConnTimeout: 90 * time.Second,
+}}
+
+// statusError is an HTTP answer other than the one a call expected. It
+// names the status alone: a registry's body is not repeated.
+type statusError struct {
+ Op string
+ Code int
+}
+
+func (e *statusError) Error() string { return fmt.Sprintf("%s: HTTP %d", e.Op, e.Code) }
+
+// withRetry repeats f over passing failures, waiting longer each time.
+func withRetry(ctx context.Context, f func() error) error {
+ delay := time.Second
+ for attempt := 1; ; attempt++ {
+ err := f()
+ if err == nil || attempt == retryAttempts || !retryable(err) {
+ return err
+ }
+ timer := time.NewTimer(delay)
+ select {
+ case <-ctx.Done():
+ timer.Stop()
+ return ctx.Err()
+ case <-timer.C:
+ }
+ delay *= 2
+ }
+}
+
+func retryable(err error) bool {
+ if errors.Is(err, errBadHash) || errors.Is(err, context.Canceled) {
+ return false
+ }
+ var status *statusError
+ if errors.As(err, &status) {
+ return status.Code == http.StatusTooManyRequests || status.Code >= 500
+ }
+ return true
+}
+
+// timedBody cancels its request's deadline when the body is closed.
+type timedBody struct {
+ io.ReadCloser
+ cancel context.CancelFunc
+}
+
+func (b timedBody) Close() error {
+ err := b.ReadCloser.Close()
+ b.cancel()
+ return err
+}
+
+// httpGet fetches a public URL. The caller closes the body.
+func httpGet(ctx context.Context, target string) (io.ReadCloser, error) {
+ ctx, cancel := context.WithTimeout(ctx, requestTimeout)
+ req, err := http.NewRequestWithContext(ctx, http.MethodGet, target, nil)
+ if err != nil {
+ cancel()
+ return nil, err
+ }
+ resp, err := httpClient.Do(req)
+ if err != nil {
+ cancel()
+ return nil, err
+ }
+ if resp.StatusCode != http.StatusOK {
+ resp.Body.Close()
+ cancel()
+ return nil, &statusError{Op: "GET " + target, Code: resp.StatusCode}
+ }
+ return timedBody{ReadCloser: resp.Body, cancel: cancel}, nil
+}
+
+// blobStore keeps content by sha256 under <cache>/blobs/sha256.
+type blobStore struct{ dir string }
+
+func openStore(cache string) (blobStore, error) {
+ dir := filepath.Join(cache, "blobs", "sha256")
+ if err := os.MkdirAll(dir, 0o755); err != nil {
+ return blobStore{}, err
+ }
+ return blobStore{dir: dir}, nil
+}
+
+// path takes a bare sha256 or a sha256: digest.
+func (s blobStore) path(digest string) string {
+ return filepath.Join(s.dir, strings.TrimPrefix(digest, "sha256:"))
+}
+
+// verify hashes a stored blob.
+func (s blobStore) verify(digest string) error {
+ f, err := os.Open(s.path(digest))
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+ h := sha256.New()
+ if _, err := io.Copy(h, f); err != nil {
+ return err
+ }
+ if got, want := hex.EncodeToString(h.Sum(nil)), strings.TrimPrefix(digest, "sha256:"); got != want {
+ return fmt.Errorf("%w: %s holds %s, want %s", errBadHash, s.path(digest), got, want)
+ }
+ return nil
+}
+
+// ensure makes the blob present and verified, calling get to download it
+// when it is absent. At most limit bytes are read from get, and content
+// that does not hash to digest is never kept.
+func (s blobStore) ensure(ctx context.Context, digest string, limit int64, get func(context.Context) (io.ReadCloser, error)) error {
+ if _, err := os.Stat(s.path(digest)); err == nil {
+ return s.verify(digest)
+ }
+ want := strings.TrimPrefix(digest, "sha256:")
+ return withRetry(ctx, func() error {
+ body, err := get(ctx)
+ if err != nil {
+ return err
+ }
+ defer body.Close()
+ tmp, err := os.CreateTemp(s.dir, ".download-*")
+ if err != nil {
+ return err
+ }
+ defer os.Remove(tmp.Name())
+ defer tmp.Close()
+ h := sha256.New()
+ if _, err := io.Copy(io.MultiWriter(tmp, h), io.LimitReader(body, limit+1)); err != nil {
+ return err
+ }
+ if got := hex.EncodeToString(h.Sum(nil)); got != want {
+ return fmt.Errorf("%w: downloaded %s, want %s", errBadHash, got, want)
+ }
+ if err := tmp.Close(); err != nil {
+ return err
+ }
+ if err := os.Chmod(tmp.Name(), 0o644); err != nil {
+ return err
+ }
+ return os.Rename(tmp.Name(), s.path(digest))
+ })
+}
+
+// registry is a v2 registry client for one repository.
+type registry struct {
+ base, repo string
+ basic string // Authorization value for a push; empty for a pull
+ bearer string // the anonymous pull token, once fetched
+}
+
+func (r *registry) url(path string) string { return r.base + "/v2/" + r.repo + "/" + path }
+
+// do sends a request. An anonymous GET answered 401 fetches the token the
+// challenge names and is sent once more.
+func (r *registry) do(req *http.Request) (*http.Response, error) {
+ if r.basic != "" {
+ req.Header.Set("Authorization", r.basic)
+ } else if r.bearer != "" {
+ req.Header.Set("Authorization", "Bearer "+r.bearer)
+ }
+ resp, err := httpClient.Do(req)
+ if err != nil || resp.StatusCode != http.StatusUnauthorized || r.basic != "" || r.bearer != "" || req.Method != http.MethodGet {
+ return resp, err
+ }
+ challenge := resp.Header.Get("WWW-Authenticate")
+ resp.Body.Close()
+ token, err := fetchToken(req.Context(), challenge)
+ if err != nil {
+ return nil, err
+ }
+ r.bearer = token
+ retry := req.Clone(req.Context())
+ retry.Header.Set("Authorization", "Bearer "+token)
+ return httpClient.Do(retry)
+}
+
+var challengeParam = regexp.MustCompile(`([a-z]+)="([^"]*)"`)
+
+// fetchToken answers a Bearer challenge anonymously.
+func fetchToken(ctx context.Context, challenge string) (string, error) {
+ scheme, rest, _ := strings.Cut(challenge, " ")
+ if !strings.EqualFold(scheme, "bearer") {
+ return "", fmt.Errorf("%w: the registry asked for %q sign-in", errBadBase, scheme)
+ }
+ params := map[string]string{}
+ for _, m := range challengeParam.FindAllStringSubmatch(rest, -1) {
+ params[m[1]] = m[2]
+ }
+ realm, err := url.Parse(params["realm"])
+ if err != nil || (realm.Scheme != "https" && !isLoopback(realm.Host)) {
+ return "", fmt.Errorf("%w: the registry's token address is not https", errBadBase)
+ }
+ q := realm.Query()
+ for _, name := range []string{"service", "scope"} {
+ if params[name] != "" {
+ q.Set(name, params[name])
+ }
+ }
+ realm.RawQuery = q.Encode()
+ body, err := httpGet(ctx, realm.String())
+ if err != nil {
+ return "", err
+ }
+ defer body.Close()
+ var answer struct {
+ Token string `json:"token"`
+ AccessToken string `json:"access_token"`
+ }
+ if err := json.NewDecoder(io.LimitReader(body, maxManifestBytes)).Decode(&answer); err != nil {
+ return "", fmt.Errorf("token answer: %w", err)
+ }
+ if answer.Token != "" {
+ return answer.Token, nil
+ }
+ return answer.AccessToken, nil
+}
+
+// get fetches a manifest or blob path. The caller closes the body.
+func (r *registry) get(ctx context.Context, path string) (io.ReadCloser, error) {
+ ctx, cancel := context.WithTimeout(ctx, requestTimeout)
+ req, err := http.NewRequestWithContext(ctx, http.MethodGet, r.url(path), nil)
+ if err != nil {
+ cancel()
+ return nil, err
+ }
+ req.Header.Set("Accept", strings.Join([]string{mediaTypeOCIIndex, mediaTypeOCIManifest, mediaTypeDockerList, mediaTypeDockerManifest}, ", "))
+ resp, err := r.do(req)
+ if err != nil {
+ cancel()
+ return nil, err
+ }
+ if resp.StatusCode != http.StatusOK {
+ resp.Body.Close()
+ cancel()
+ return nil, &statusError{Op: "GET " + path, Code: resp.StatusCode}
+ }
+ return timedBody{ReadCloser: resp.Body, cancel: cancel}, nil
+}
+
+// baseImage is the arm64 image of a pinned base, with every blob verified
+// in the store.
+type baseImage struct {
+ Manifest ociManifest
+ Config ociConfig
+}
+
+// loadBase resolves ref to its arm64 image. Anything the store lacks comes
+// from the registry; everything is checked against ref's digest chain.
+func loadBase(ctx context.Context, store blobStore, ref imageRef) (baseImage, error) {
+ reg := &registry{base: registryBase(ref.Host), repo: ref.Repo}
+ manifestBlob := func(digest string) ([]byte, error) {
+ err := store.ensure(ctx, digest, maxManifestBytes, func(ctx context.Context) (io.ReadCloser, error) {
+ return reg.get(ctx, "manifests/"+digest)
+ })
+ if err != nil {
+ return nil, err
+ }
+ return os.ReadFile(store.path(digest))
+ }
+ data, err := manifestBlob(ref.Digest)
+ if err != nil {
+ return baseImage{}, fmt.Errorf("base image: %w", err)
+ }
+ var index ociIndex
+ if err := json.Unmarshal(data, &index); err != nil {
+ return baseImage{}, fmt.Errorf("%w: %w", errBadBase, err)
+ }
+ if len(index.Manifests) > 0 {
+ digest := ""
+ for _, m := range index.Manifests {
+ if m.Platform != nil && m.Platform.Architecture == "arm64" && m.Platform.OS == "linux" {
+ digest = m.Digest
+ break
+ }
+ }
+ if digest == "" {
+ return baseImage{}, fmt.Errorf("%w: no linux/arm64 image", errBadBase)
+ }
+ if data, err = manifestBlob(digest); err != nil {
+ return baseImage{}, fmt.Errorf("base image: %w", err)
+ }
+ }
+ var base baseImage
+ if err := json.Unmarshal(data, &base.Manifest); err != nil {
+ return baseImage{}, fmt.Errorf("%w: %w", errBadBase, err)
+ }
+ blob := func(d ociDescriptor) error {
+ return store.ensure(ctx, d.Digest, d.Size, func(ctx context.Context) (io.ReadCloser, error) {
+ return reg.get(ctx, "blobs/"+d.Digest)
+ })
+ }
+ if err := blob(base.Manifest.Config); err != nil {
+ return baseImage{}, fmt.Errorf("base config: %w", err)
+ }
+ config, err := os.ReadFile(store.path(base.Manifest.Config.Digest))
+ if err != nil {
+ return baseImage{}, err
+ }
+ if err := json.Unmarshal(config, &base.Config); err != nil {
+ return baseImage{}, fmt.Errorf("%w: %w", errBadBase, err)
+ }
+ if base.Config.Architecture != "arm64" || base.Config.OS != "linux" {
+ return baseImage{}, fmt.Errorf("%w: the image is %s/%s", errBadBase, base.Config.OS, base.Config.Architecture)
+ }
+ if len(base.Config.RootFS.DiffIDs) != len(base.Manifest.Layers) {
+ return baseImage{}, fmt.Errorf("%w: %d layers and %d diff ids", errBadBase, len(base.Manifest.Layers), len(base.Config.RootFS.DiffIDs))
+ }
+ for _, layer := range base.Manifest.Layers {
+ if layer.MediaType != mediaTypeOCILayer && layer.MediaType != mediaTypeDockerLayer {
+ return baseImage{}, fmt.Errorf("%w: layer type %s", errBadBase, layer.MediaType)
+ }
+ if err := blob(layer); err != nil {
+ return baseImage{}, fmt.Errorf("base layer: %w", err)
+ }
+ }
+ return base, nil
+}
diff --git a/cmd/mediaimage/push.go b/cmd/mediaimage/push.go
new file mode 100644
index 000000000..10faad7a0
--- /dev/null
+++ b/cmd/mediaimage/push.go
@@ -0,0 +1,269 @@
+package main
+
+import (
+ "bytes"
+ "context"
+ "crypto/sha256"
+ "encoding/base64"
+ "encoding/hex"
+ "encoding/json"
+ "errors"
+ "fmt"
+ "io"
+ "net/http"
+ "net/url"
+ "os"
+ "path/filepath"
+ "regexp"
+ "strings"
+)
+
+// registryPasswordEnv holds the registry password; the user is always AWS,
+// as ECR's get-login-password expects.
+const registryPasswordEnv = "CARLOS_REGISTRY_PASSWORD"
+
+var (
+ // errBadPush is a push refused before it reaches the registry.
+ errBadPush = errors.New("push refused")
+ // errTagReused is a release tag that already names another image.
+ errTagReused = errors.New("tag already holds another image")
+ // errDigestMismatch is a registry holding other bytes than were pushed.
+ errDigestMismatch = errors.New("the registry holds a different image")
+)
+
+var (
+ tagPattern = regexp.MustCompile(`^[A-Za-z0-9_][A-Za-z0-9._-]{0,127}$`)
+ repoPattern = regexp.MustCompile(`^([a-zA-Z0-9.-]+(?::[0-9]+)?)/([a-z0-9._/-]+)$`)
+)
+
+// pushOptions are the push command's flags and the registry password.
+type pushOptions struct {
+ Layout, Repo, Tag, Password string
+}
+
+// pushImage copies a layout into a repository under a release tag and
+// returns the manifest digest, after reading back what the registry holds.
+// The repository's tags are immutable, so a tag is written once: the same
+// image under the same tag is a finished push, another image is refused.
+func pushImage(ctx context.Context, o pushOptions) (string, error) {
+ reg, err := pushRegistry(o)
+ if err != nil {
+ return "", err
+ }
+ manifest, digest, blobs, err := readLayoutForPush(o.Layout)
+ if err != nil {
+ return "", err
+ }
+ held, err := fetchManifest(ctx, reg, o.Tag)
+ if err != nil {
+ return "", err
+ }
+ if held != nil {
+ if got := digestBytes(held); got != digest {
+ return "", fmt.Errorf("%w: %s is %s, this image is %s", errTagReused, o.Tag, got, digest)
+ }
+ return digest, nil
+ }
+ for _, blob := range blobs {
+ err := withRetry(ctx, func() error { return uploadBlob(ctx, reg, o.Layout, blob) })
+ if err != nil {
+ return "", fmt.Errorf("blob %s: %w", blob.Digest, err)
+ }
+ }
+ if err := putManifest(ctx, reg, o.Tag, manifest); err != nil {
+ return "", err
+ }
+ for _, ref := range []string{digest, o.Tag} {
+ held, err := fetchManifest(ctx, reg, ref)
+ if err != nil {
+ return "", err
+ }
+ if held == nil || digestBytes(held) != digest {
+ return "", fmt.Errorf("%w: %s after the push, want %s", errDigestMismatch, ref, digest)
+ }
+ }
+ return digest, nil
+}
+
+// pushRegistry validates the options before anything reaches the network.
+func pushRegistry(o pushOptions) (*registry, error) {
+ if o.Password == "" {
+ return nil, fmt.Errorf("%w: %s is not set", errBadPush, registryPasswordEnv)
+ }
+ if !tagPattern.MatchString(o.Tag) {
+ return nil, fmt.Errorf("%w: --tag must be a release tag", errBadPush)
+ }
+ m := repoPattern.FindStringSubmatch(o.Repo)
+ if m == nil {
+ return nil, fmt.Errorf("%w: --repo must be <registry>/<repo>", errBadPush)
+ }
+ auth := base64.StdEncoding.EncodeToString([]byte("AWS:" + o.Password))
+ return &registry{base: registryBase(m[1]), repo: m[2], basic: "Basic " + auth}, nil
+}
+
+func digestBytes(data []byte) string {
+ sum := sha256.Sum256(data)
+ return "sha256:" + hex.EncodeToString(sum[:])
+}
+
+// readLayoutForPush reads the layout's one manifest and verifies every
+// blob, so a damaged layout sends nothing.
+func readLayoutForPush(layout string) (manifest []byte, digest string, blobs []ociDescriptor, err error) {
+ data, err := os.ReadFile(filepath.Join(layout, "index.json"))
+ if err != nil {
+ return nil, "", nil, err
+ }
+ var index ociIndex
+ if err := json.Unmarshal(data, &index); err != nil {
+ return nil, "", nil, fmt.Errorf("index.json: %w", err)
+ }
+ if len(index.Manifests) != 1 {
+ return nil, "", nil, fmt.Errorf("%w: the layout holds %d manifests", errBadPush, len(index.Manifests))
+ }
+ digest = index.Manifests[0].Digest
+ store := blobStore{dir: filepath.Join(layout, "blobs", "sha256")}
+ if err := store.verify(digest); err != nil {
+ return nil, "", nil, err
+ }
+ if manifest, err = os.ReadFile(store.path(digest)); err != nil {
+ return nil, "", nil, err
+ }
+ var m ociManifest
+ if err := json.Unmarshal(manifest, &m); err != nil {
+ return nil, "", nil, fmt.Errorf("manifest: %w", err)
+ }
+ blobs = append([]ociDescriptor{m.Config}, m.Layers...)
+ for _, blob := range blobs {
+ if err := store.verify(blob.Digest); err != nil {
+ return nil, "", nil, err
+ }
+ }
+ return manifest, digest, blobs, nil
+}
+
+// send makes one registry call under the request deadline and hands the
+// response to read, which is given no body to close.
+func send(ctx context.Context, reg *registry, method, target, contentType string, body io.Reader, size int64, read func(*http.Response) error) error {
+ ctx, cancel := context.WithTimeout(ctx, requestTimeout)
+ defer cancel()
+ req, err := http.NewRequestWithContext(ctx, method, target, body)
+ if err != nil {
+ return err
+ }
+ if contentType != "" {
+ req.Header.Set("Content-Type", contentType)
+ }
+ req.Header.Set("Accept", strings.Join([]string{mediaTypeOCIManifest, mediaTypeDockerManifest}, ", "))
+ if body != nil {
+ req.ContentLength = size
+ }
+ resp, err := reg.do(req)
+ if err != nil {
+ return err
+ }
+ defer resp.Body.Close()
+ return read(resp)
+}
+
+// fetchManifest returns the manifest a reference names, nil when absent.
+func fetchManifest(ctx context.Context, reg *registry, ref string) ([]byte, error) {
+ var data []byte
+ err := send(ctx, reg, http.MethodGet, reg.url("manifests/"+ref), "", nil, 0, func(resp *http.Response) error {
+ switch resp.StatusCode {
+ case http.StatusOK:
+ var err error
+ data, err = io.ReadAll(io.LimitReader(resp.Body, maxManifestBytes))
+ return err
+ case http.StatusNotFound:
+ return nil
+ }
+ return &statusError{Op: "read manifest " + ref, Code: resp.StatusCode}
+ })
+ return data, err
+}
+
+// expect turns any other status into an error.
+func expect(op string, want int) func(*http.Response) error {
+ return func(resp *http.Response) error {
+ if resp.StatusCode != want {
+ return &statusError{Op: op, Code: resp.StatusCode}
+ }
+ return nil
+ }
+}
+
+// uploadBlob sends one blob the registry does not hold yet: open a session,
+// send the bytes in one PATCH, close it with the digest.
+func uploadBlob(ctx context.Context, reg *registry, layout string, blob ociDescriptor) error {
+ present := false
+ err := send(ctx, reg, http.MethodHead, reg.url("blobs/"+blob.Digest), "", nil, 0, func(resp *http.Response) error {
+ switch resp.StatusCode {
+ case http.StatusOK:
+ present = true
+ return nil
+ case http.StatusNotFound:
+ return nil
+ }
+ return &statusError{Op: "check blob", Code: resp.StatusCode}
+ })
+ if err != nil || present {
+ return err
+ }
+
+ next := func(current string, resp *http.Response) (string, error) {
+ base, err := url.Parse(current)
+ if err != nil {
+ return "", err
+ }
+ loc, err := base.Parse(resp.Header.Get("Location"))
+ if err != nil {
+ return "", fmt.Errorf("upload location: %w", err)
+ }
+ return loc.String(), nil
+ }
+ start := reg.url("blobs/uploads/")
+ location := ""
+ err = send(ctx, reg, http.MethodPost, start, "", nil, 0, func(resp *http.Response) error {
+ if resp.StatusCode != http.StatusAccepted {
+ return &statusError{Op: "start upload", Code: resp.StatusCode}
+ }
+ var err error
+ location, err = next(start, resp)
+ return err
+ })
+ if err != nil {
+ return err
+ }
+
+ f, err := os.Open(filepath.Join(layout, "blobs", "sha256", strings.TrimPrefix(blob.Digest, "sha256:")))
+ if err != nil {
+ return err
+ }
+ defer f.Close()
+ current := location
+ err = send(ctx, reg, http.MethodPatch, current, "application/octet-stream", f, blob.Size, func(resp *http.Response) error {
+ if resp.StatusCode != http.StatusAccepted {
+ return &statusError{Op: "upload", Code: resp.StatusCode}
+ }
+ var err error
+ location, err = next(current, resp)
+ return err
+ })
+ if err != nil {
+ return err
+ }
+
+ final, err := url.Parse(location)
+ if err != nil {
+ return err
+ }
+ q := final.Query()
+ q.Set("digest", blob.Digest)
+ final.RawQuery = q.Encode()
+ return send(ctx, reg, http.MethodPut, final.String(), "application/octet-stream", nil, 0, expect("finish upload", http.StatusCreated))
+}
+
+// putManifest writes the manifest under the tag.
+func putManifest(ctx context.Context, reg *registry, tag string, manifest []byte) error {
+ return send(ctx, reg, http.MethodPut, reg.url("manifests/"+tag), mediaTypeOCIManifest, bytes.NewReader(manifest), int64(len(manifest)), expect("write manifest", http.StatusCreated))
+}
diff --git a/deploy/media-image/README.md b/deploy/media-image/README.md
new file mode 100644
index 000000000..5381f97bd
--- /dev/null
+++ b/deploy/media-image/README.md
@@ -0,0 +1,69 @@
+# The media engine image
+
+This is the arm64 container image that converts video and audio. It holds Debian 13’s slim base image, Debian’s ffmpeg with the libraries it needs, and the `carlos-media` binary. `debs.lock` pins every package by version and sha256, and it pins the base image by digest.
+
+`cmd/mediaimage` assembles the image directly, with no container runtime. The same commit and lock give the same image digest when built with the same Go version.
+
+## Build the image
+
+```sh
+make media-image
+```
+
+You need Go and `xz`. The first build downloads the packages into `dist/media-image-cache`; later builds reuse them. The image lands in `dist/media-image`, and `dist/media-image/image.json` records its digest, build time and ffmpeg version.
+
+The build stops if a download doesn’t match the lock, or if any program in the image needs a library the image doesn’t hold.
+
+## Push it to a deployment
+
+Each deployment has its own image repository. Push under the release tag:
+
+```sh
+export CARLOS_REGISTRY_PASSWORD="$(aws ecr get-login-password --profile <profile> --region <region>)"
+go run ./cmd/mediaimage push \
+ --layout dist/media-image \
+ --repo <account>.dkr.ecr.<region>.amazonaws.com/<repository> \
+ --tag <release-tag>
+```
+
+The command prints the image digest once it has read the image back from the registry. Tags in these repositories can’t be changed, so give each release its own tag. Pushing the same image under the same tag again is safe. Pushing a different image under a used tag is refused.
+
+Dev goes first, then flagship.
+
+## Pin the image in the deployment’s root
+
+Copy the three values from `image.json` into the `media-engine` module:
+
+```hcl
+image_digest = "sha256:..." # digest
+image_built_at = "2026-11-18T00:00:00Z" # built_at
+image_ffmpeg = "7:7.1.5-0+deb13u1" # ffmpeg
+```
+
+Applying that change is a production infrastructure change, so it needs the usual scoped approval.
+
+## Roll back
+
+Set the three values back to the previous image’s and apply.
+
+## Refresh the packages
+
+Debian’s security fixes reach the image through a new lock. Once a week, on a branch named `media-image-lock-<date>`:
+
+```sh
+make media-image-lock
+```
+
+Commit only `debs.lock`. The next platform release builds an image from it. `carlos system media status` warns when the running image is more than 30 days old.
+
+The weekly run belongs to an amadan scheduled job if amadan CI has schedules. If it doesn’t, it belongs to a Paseo schedule on docs-t1. The media conversion spike report settles which one, and the first release sets it up.
+
+To move to a newer Debian base image as well, name its digest:
+
+```sh
+make media-image-lock MEDIA_IMAGE_BASE=docker.io/library/debian@sha256:<digest>
+```
+
+## When a build stops on a library
+
+Debian’s install scripts don’t run here, so links they would have made are missing. If a new package reaches a library through `update-alternatives`, add the link to `alternativeLinks` in `cmd/mediaimage/build.go`. If a package ships an optional plugin that can never load, add it to `unloadableFiles` in the same file.
diff --git a/deploy/media-image/debs.lock b/deploy/media-image/debs.lock
new file mode 100644
index 000000000..54ac04ef5
--- /dev/null
+++ b/deploy/media-image/debs.lock
@@ -0,0 +1,208 @@
+# snapshot 20261117T000000Z
+# base docker.io/library/debian@sha256:a72b4433de1cf7d6bae0c4cee74d0547f58601a643b3375f070c51600d63b6b2
+ffmpeg 7:7.1.5-0+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/ffmpeg/ffmpeg_7.1.5-0+deb13u1_arm64.deb 6ec9c42306df30803c731c9e53300627257fd59d2f5a80b394c14cec5fd6d5ef 1989836
+fontconfig 2.15.0-2.3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/fontconfig/fontconfig_2.15.0-2.3_arm64.deb f899e800435bc3bd3ecc6139bfcb2b45b3dbd2ffa59c4b9b3cc246e9661052af 463008
+fontconfig-config 2.15.0-2.3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/fontconfig/fontconfig-config_2.15.0-2.3_arm64.deb 10f643f467b51cf25fc18d1945bc61246dd8d8d1fe6bc712a2b1712c74ebc4d6 318304
+fonts-dejavu-core 2.37-8 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/fonts-dejavu/fonts-dejavu-core_2.37-8_all.deb 86635b3d25b3655fc11cb3ecc3af59f0bf19643b02b94f2de48bd10253cdba12 840460
+fonts-dejavu-mono 2.37-8 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/fonts-dejavu/fonts-dejavu-mono_2.37-8_all.deb 3003e98a5debfdeadc7040a7f715fe9fe6fb67f68deacf6049b54e30f07fc014 488808
+libaom3 3.12.1-1+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/a/aom/libaom3_3.12.1-1+deb13u1_arm64.deb 552e2bd21772a39713a0c63e814039f558b355d048f0d0bfc4009658253cc1e9 1670644
+libasound2-data 1.2.14-1+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/a/alsa-lib/libasound2-data_1.2.14-1+deb13u1_all.deb 04688afdff3769c0f685541daed7b2f6f0cb946799ddf1d5847ddf11fe245559 21188
+libasound2t64 1.2.14-1+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/a/alsa-lib/libasound2t64_1.2.14-1+deb13u1_arm64.deb 9c808d819ccddc37c793dd3186c2ecd858b2feb2474cebb883f70386e7890d39 341632
+libass9 1:0.17.3-1+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/liba/libass/libass9_0.17.3-1+deb13u1_arm64.deb 849fbb86d5fa8b3cac38b80ff577ff3d1f85e6fdcb95313db4639593069843e2 101336
+libasyncns0 0.8-6+b5 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/liba/libasyncns/libasyncns0_0.8-6+b5_arm64.deb 818bbcaa7ada536a1bdd5b1c26b77608606403f5c15557691e83d0b4433b89ef 11672
+libatomic1 14.2.0-19 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/g/gcc-14/libatomic1_14.2.0-19_arm64.deb 7ccff90234484bf21ae5ecb79d25b6a84b2f4038f65dd139085b2e3a937cd8dc 10128
+libavc1394-0 0.5.4-5+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/liba/libavc1394/libavc1394-0_0.5.4-5+b2_arm64.deb 3fb347cbe7782e595a94cc53697bcaf0ba9b5978ac319e4b8832b89f9e89bc52 17940
+libavcodec61 7:7.1.5-0+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/ffmpeg/libavcodec61_7.1.5-0+deb13u1_arm64.deb dca58c157a2a0434b4c371b14b52f7922625147453b3d3cc165a2bb08157b31d 5394940
+libavdevice61 7:7.1.5-0+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/ffmpeg/libavdevice61_7.1.5-0+deb13u1_arm64.deb 6fd5173b6d147aab1b79b21cca8ea76e6d151da6853d4c79e82e208ee6ecb687 123040
+libavfilter10 7:7.1.5-0+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/ffmpeg/libavfilter10_7.1.5-0+deb13u1_arm64.deb 42d9544cf6082b231906a3bd0d5f9dc5c3b0bdc049b61a219b659319c66ed2e3 3697424
+libavformat61 7:7.1.5-0+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/ffmpeg/libavformat61_7.1.5-0+deb13u1_arm64.deb c14f4cfbb3d377108ff7d28000c3f99feed936dd2348f7a253947ea87ad2cfb6 1140316
+libavutil59 7:7.1.5-0+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/ffmpeg/libavutil59_7.1.5-0+deb13u1_arm64.deb 74c613a9c4674a251aa1808927f1b3b7dcd07f92b1724974e81ffabda81d0760 391996
+libblas3 3.12.1-6 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/l/lapack/libblas3_3.12.1-6_arm64.deb 33ed1d0770978f11493d24e0416a51ea7de77ede8c23d179a8ad88802a167be2 104092
+libbluray2 1:1.3.4-1+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libb/libbluray/libbluray2_1.3.4-1+b2_arm64.deb 14da09203931bdbff17b129d447850daecc8c72b87b296e3f7d0e0beb56e9f50 125560
+libbrotli1 1.1.0-2+deb13u1 https://snapshot.debian.org/archive/debian-security/20261117T000000Z/pool/updates/main/b/brotli/libbrotli1_1.1.0-2+deb13u1_arm64.deb a8caceeddd3a407888234ef488e0a773299e05fac703c8695166a0a9bc86587f 293896
+libbs2b0 3.1.0+dfsg-8+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libb/libbs2b/libbs2b0_3.1.0+dfsg-8+b1_arm64.deb 6041677fd23ee86179348846e058b40c4c8dbdd7ace50d772a4e5b56a80b08db 11432
+libcaca0 0.99.beta20-5+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libc/libcaca/libcaca0_0.99.beta20-5+deb13u1_arm64.deb 29534fbb3881e2c6181806d1f50cc511841553c5556146dfcbc8503e6093f761 196352
+libcairo-gobject2 1.18.4-1+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/c/cairo/libcairo-gobject2_1.18.4-1+b1_arm64.deb 470185fcc3aa8e3fea4e0108bc842ce9179918da44d4d0cf7d67598d3470fd1a 130204
+libcairo2 1.18.4-1+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/c/cairo/libcairo2_1.18.4-1+b1_arm64.deb de0e190f4566b51942387fb84fe85f064d23da896b8e2080930d53879a11630d 483084
+libcdio-cdda2t64 10.2+2.0.2-1+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libc/libcdio-paranoia/libcdio-cdda2t64_10.2+2.0.2-1+b1_arm64.deb 582a783ff88cdc8c78e4dd322456f3e604e39fae7fc7df5ec1b7429b874c4571 17172
+libcdio-paranoia2t64 10.2+2.0.2-1+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libc/libcdio-paranoia/libcdio-paranoia2t64_10.2+2.0.2-1+b1_arm64.deb 3d3d040c8bd0856c06e35234587dd0adb856eada9ab8fb61bfd4a3a3291c6410 16512
+libcdio19t64 2.2.0-4.1~deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libc/libcdio/libcdio19t64_2.2.0-4.1~deb13u1_arm64.deb 3c76de181f7018ca14e29f75ba6992cf5ec9099e3c3ee304d9d64454af48062f 59316
+libchromaprint1 1.5.1-7 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/c/chromaprint/libchromaprint1_1.5.1-7_arm64.deb 4ad44ffa6d4c2af857e3bc4fba69d55373126ab23ba1e841dc69fe937246929c 38896
+libcjson1 1.7.18-3.1+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/c/cjson/libcjson1_1.7.18-3.1+deb13u1_arm64.deb f8a6ce78b0d4b1db40b16e0330fb1dfcd54a15c4a1f6798afd631e99f30fe707 28968
+libcodec2-1.2 1.2.0-3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/c/codec2/libcodec2-1.2_1.2.0-3_arm64.deb 33e971eb87601c32b330dc1915b92f3fd88ea74380a30a2d10b657065d36e920 8163476
+libcom-err2 1.47.2-3+b12 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/e/e2fsprogs/libcom-err2_1.47.2-3+b12_arm64.deb 1acba7e14a17a3f4b8008454e1a75840a5cdff4259d3c1d369092d82089ea0d8 24932
+libdatrie1 0.2.13-3+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libd/libdatrie/libdatrie1_0.2.13-3+b1_arm64.deb d513d0602836c4df782c15dc9472c17ab5a815343aabc9ebe7dc9604c0acfaa0 37596
+libdav1d7 1.5.1-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/d/dav1d/libdav1d7_1.5.1-1_arm64.deb bcb430fa4c5f05bc3fa4dd9f18b7b0498ec9701c23e83bf57a29996216c3a245 252128
+libdbus-1-3 1.16.2-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/d/dbus/libdbus-1-3_1.16.2-2_arm64.deb ca6bb5f2047ad58d274cb7d14216035a07d8e5aae6f6a0122c4f6293c9c39515 169068
+libdc1394-25 2.2.6-5 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libd/libdc1394/libdc1394-25_2.2.6-5_arm64.deb 9a4e7781af978fefd50672c22582c7fe166d7c1488bbc79605e04218c1d61305 105860
+libdecor-0-0 0.2.2-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libd/libdecor-0/libdecor-0-0_0.2.2-2_arm64.deb 34c0db59390767ef7b1cb5594f78f142b0673a5e7788e068cdd323f9c16f9207 15204
+libdeflate0 1.23-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libd/libdeflate/libdeflate0_1.23-2_arm64.deb ddd23094f9608f2ff9ea2256df2e917e315524371a6a82cb9daa921557c5a595 42376
+libdrm-amdgpu1 2.4.124-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libd/libdrm/libdrm-amdgpu1_2.4.124-2_arm64.deb e36c72774cc215818b48ee2174c7ad1d9a2bf89a09cdee7a7a128d288d8eef43 21828
+libdrm-common 2.4.124-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libd/libdrm/libdrm-common_2.4.124-2_all.deb 9a8a6c65c165e9964f106fb4ac710959b5d33e0790227e3ab6b27c4742d1254a 8288
+libdrm2 2.4.124-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libd/libdrm/libdrm2_2.4.124-2_arm64.deb b535506630bb6a9a616bc07caf3b29915f980d8c3437852fb96ea64fb1a8a3f8 38304
+libdvdnav4 6.1.1-3+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libd/libdvdnav/libdvdnav4_6.1.1-3+b1_arm64.deb 42c7fbfbb8c048f64c5099d3a9174ebb510ef591022c0bbb0c6a03c5acd7c51c 41000
+libdvdread8t64 6.1.3-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libd/libdvdread/libdvdread8t64_6.1.3-2_arm64.deb 92d848dcdb5c44bf14b4448c0d8a05c7397069888d9df0189191fa4d9706758c 81196
+libedit2 3.1-20250104-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libe/libedit/libedit2_3.1-20250104-1_arm64.deb 496c31df89fac9cb7e98102fcc21daf887376dcd9914f6322c86dd5bd4360ff1 89296
+libelf1t64 0.192-4 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/e/elfutils/libelf1t64_0.192-4_arm64.deb 815b4265c7d6c89c5bbad456bdeed7af893da6912c9d16cf4c581001927c0e37 189080
+libexpat1 2.9.0-1~deb13u1 https://snapshot.debian.org/archive/debian-security/20261117T000000Z/pool/updates/main/e/expat/libexpat1_2.9.0-1~deb13u1_arm64.deb d9e1c50fcdad079fe16d77f1578adcc763be1bf7f2da7fa8adca7010b0c84c83 113920
+libffi8 3.4.8-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libf/libffi/libffi8_3.4.8-2_arm64.deb d84a783b818f2386627604e64b793eb4ac5bb9ea1ba321a194a1c9c82fe09a01 21260
+libfftw3-double3 3.3.10-2+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/fftw3/libfftw3-double3_3.3.10-2+b1_arm64.deb afdec5b3cdc381b1c9e80892ba12a054dbf6e529e8a8a518a8611064fdafaa0e 336668
+libflac14 1.5.0+ds-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/flac/libflac14_1.5.0+ds-2_arm64.deb 11800827306e56fcbd1a65ea67d9d13126fc02bf87fdfecd35e0f48a145b3c59 179768
+libflite1 2.2-7 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/flite/libflite1_2.2-7_arm64.deb 2cfee9289cee3b2b3e3eecd7f37bff2330f9c51f4ae6d0c3a66fc1ef370bd03d 12824376
+libfontconfig1 2.15.0-2.3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/fontconfig/libfontconfig1_2.15.0-2.3_arm64.deb 872781cf62926b68c34a4302a3caae334ff8d4d83a2b2477f8fb454460aadc99 387092
+libfreetype6 2.13.3+dfsg-1+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/freetype/libfreetype6_2.13.3+dfsg-1+deb13u1_arm64.deb 0c426e83f1af816b9a4df9056fd2238463d1cd07969ee640965da9fb6ecaf107 422284
+libfribidi0 1.0.16-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/fribidi/libfribidi0_1.0.16-1_arm64.deb 5f5bfdf6ef126b0a38f8ebb8751cbbb845fe2cd4e1dd5258d241be243e09897f 26460
+libgbm1 25.0.7-2+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/m/mesa/libgbm1_25.0.7-2+deb13u1_arm64.deb 2beb8d20ca715a01b7b2352c1167c0d7097c9d8a486704a9a966f95d4077cdfc 44144
+libgdk-pixbuf-2.0-0 2.42.12+dfsg-4+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/g/gdk-pixbuf/libgdk-pixbuf-2.0-0_2.42.12+dfsg-4+deb13u1_arm64.deb 2090d2ee768d27c3bfad89d34b6915453d3034fa778d4bf15f5144a3fb4a0c78 131480
+libgdk-pixbuf2.0-common 2.42.12+dfsg-4+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/g/gdk-pixbuf/libgdk-pixbuf2.0-common_2.42.12+dfsg-4+deb13u1_all.deb 9f0c64e33cf5bb3226a5a6ddf630dd76530596e476e6b47a8b27da444ff43a03 311852
+libgfortran5 14.2.0-19 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/g/gcc-14/libgfortran5_14.2.0-19_arm64.deb 5f771ed84bf8779d4598e66b719121ab1413c11412c87629e50c79d26b042612 361252
+libgl1 1.7.0-1+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libg/libglvnd/libgl1_1.7.0-1+b2_arm64.deb 7943f99962aa3316515760bf44e66f0c15a3c813ad750b784b43e319fa2e6003 90876
+libgl1-mesa-dri 25.0.7-2+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/m/mesa/libgl1-mesa-dri_25.0.7-2+deb13u1_arm64.deb 628245ff9d8e4f11edb66c0854915018402853e0eb588343d472111f6c4fb582 45852
+libglib2.0-0t64 2.84.4-3~deb13u5 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/g/glib2.0/libglib2.0-0t64_2.84.4-3~deb13u5_arm64.deb d446f0ea85fb9dc411219ce861e59e5eabe1981c796918771a7d2aa97cc72481 1428508
+libglvnd0 1.7.0-1+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libg/libglvnd/libglvnd0_1.7.0-1+b2_arm64.deb 29ec7b8cf1c9a47055de643eb0a1921854e762b4789a7f3bc3b0dea498fd4da9 41588
+libglx-mesa0 25.0.7-2+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/m/mesa/libglx-mesa0_25.0.7-2+deb13u1_arm64.deb 18c02afcdd88f547ba66d3ae9290f93ab155381bf8d96b0127f9028374acfc64 142320
+libglx0 1.7.0-1+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libg/libglvnd/libglx0_1.7.0-1+b2_arm64.deb 0245aafaac5e68ca9511f23c5bebf010327e63c65790c03dbb80bf14d485956d 31080
+libgme0 0.6.3-7+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/g/game-music-emu/libgme0_0.6.3-7+b2_arm64.deb 800d180f08f676cfad4db078c10e0b304dc54d62c05a7f32d79896879a0a3eaf 120416
+libgnutls30t64 3.8.9-3+deb13u4 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/g/gnutls28/libgnutls30t64_3.8.9-3+deb13u4_arm64.deb 337ef41ab360015d051d6a07f85f8aa6706b35712e3dea23157eba9c902196e2 1378804
+libgomp1 14.2.0-19 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/g/gcc-14/libgomp1_14.2.0-19_arm64.deb 43e84cb7971d8a4d8870cab6204e998ea4f23ee1339bb0ff556dd881bac82d25 123520
+libgraphite2-3 1.3.14-2+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/g/graphite2/libgraphite2-3_1.3.14-2+deb13u1_arm64.deb b0c3414b113de62be1dc28fa2c899ac0856256e2f094d92c36c3275a5053311a 70348
+libgsm1 1.0.22-1+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libg/libgsm/libgsm1_1.0.22-1+b2_arm64.deb dc9a761c9cca7d886db0474fe28b9697e72d376fa2112590cf5f7ed737944f6c 27260
+libgssapi-krb5-2 1.21.3-5+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/k/krb5/libgssapi-krb5-2_1.21.3-5+deb13u1_arm64.deb 70803e8f5b9dd0a7167671bdd0b3cd05642384c1fc49e8270d340d85bf6c7d4c 127624
+libharfbuzz0b 10.2.0-1+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/h/harfbuzz/libharfbuzz0b_10.2.0-1+deb13u1_arm64.deb 3ff928f981b54b491ee12e4cf68558cc5d61c652bdab276cd4c4c3fbbcee16ca 441932
+libhwy1t64 1.2.0-2+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/h/highway/libhwy1t64_1.2.0-2+b2_arm64.deb 05d6a112f091902db1155b8ebf355e78f92889d97394eef242736ec326199da3 499300
+libidn2-0 2.3.8-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libi/libidn2/libidn2-0_2.3.8-2_arm64.deb d2e5cef812f15db1eeb35f0a193158ee102a9e94284036c0e293521f2761d2d7 107232
+libiec61883-0 1.2.0-7 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libi/libiec61883/libiec61883-0_1.2.0-7_arm64.deb d8c098b0fcee27a96a46d31155d63101e9d1e830e632127f6e26b241fb09c49e 29116
+libjack-jackd2-0 1.9.22~dfsg-4 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/j/jackd2/libjack-jackd2-0_1.9.22~dfsg-4_arm64.deb c6bd35ff8a539a24957b95bae936aeed868a7865ff7227c0ec8dcccd69cebbda 265068
+libjbig0 2.1-6.1+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/j/jbigkit/libjbig0_2.1-6.1+b2_arm64.deb dbecef09dbafd82ff6444aa1cb45053b6331985b20ab2590eff052d7d6b1bb18 30360
+libjpeg62-turbo 1:2.1.5-4 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libj/libjpeg-turbo/libjpeg62-turbo_2.1.5-4_arm64.deb e4989073bb0bac8a6ec043c7adb80e1dfe601d8552233da48bb24ab45d1a1d4a 172784
+libjxl0.11 0.11.2-0.1~deb13u3 https://snapshot.debian.org/archive/debian-security/20261117T000000Z/pool/updates/main/j/jpeg-xl/libjxl0.11_0.11.2-0.1~deb13u3_arm64.deb b2a7a44db46cc9519b8ec60ee4c274e2bf1d2029a0d591e57e2885dced4e4080 886772
+libk5crypto3 1.21.3-5+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/k/krb5/libk5crypto3_1.21.3-5+deb13u1_arm64.deb 2453e8d4fa3b91b868d5bc10e84a15ad9c7bc4e4cb49379cb1f560bdce50db4a 81416
+libkeyutils1 1.6.3-6 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/k/keyutils/libkeyutils1_1.6.3-6_arm64.deb 5e680f317a6613161986417fb3ed63007c9228343f5ac2348551b103cc7fd7b4 9716
+libkrb5-3 1.21.3-5+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/k/krb5/libkrb5-3_1.21.3-5+deb13u1_arm64.deb 1f5c46480abf894f662d894696c8a6c6510c2b20616cd453e88b27b11d3be25d 308256
+libkrb5support0 1.21.3-5+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/k/krb5/libkrb5support0_1.21.3-5+deb13u1_arm64.deb 6381bcb54e58854f9ebac2dfa580c3d6112d01b4ca3f725e7263b9374f79608e 32508
+liblapack3 3.12.1-6 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/l/lapack/liblapack3_3.12.1-6_arm64.deb b1375f31fd6977f0cdacdd1de44a5f5081433d91737ea8fe9d0e64ab2ccfab12 1820060
+liblcms2-2 2.16-2+deb13u2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/l/lcms2/liblcms2-2_2.16-2+deb13u2_arm64.deb 6636997fc488327a8d0951a038df6e5178a52b3f5e5cc2386d42655621f5672d 151540
+liblerc4 4.0.0+ds-5 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/l/lerc/liblerc4_4.0.0+ds-5_arm64.deb db015dc1888371e490594f8aaaaa55356313478d744fa69e242e034e4c2a0019 146184
+liblilv-0-0 0.24.26-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/l/lilv/liblilv-0-0_0.24.26-1_arm64.deb eb14f680a7c639a9dce34928a2a560468baa25f03a79cb76b6acc9b35226b54e 41672
+libllvm19 1:19.1.7-3+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/l/llvm-toolchain-19/libllvm19_19.1.7-3+b1_arm64.deb 8a48e1a49f7fcc3be74e697767d72902f4b03041401d1529bcfad1849df39148 23285344
+libmbedcrypto16 3.6.6-0.1~deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/m/mbedtls/libmbedcrypto16_3.6.6-0.1~deb13u1_arm64.deb 5b30446d96fac946849bfc74c67c85b0d30c1f760eea0bd08a2ee14956f304c7 351428
+libmp3lame0 3.100-6+b3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/l/lame/libmp3lame0_3.100-6+b3_arm64.deb ed3563722129ffa4def03b7af0b589fa20eef972bdcc4599202ddb1ac654c58e 354760
+libmpg123-0t64 1.32.10-1+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/m/mpg123/libmpg123-0t64_1.32.10-1+deb13u1_arm64.deb d284df39ff3b64f1cdf274352613c52534c55eed82c3a2ff0fc7ba154acd7bf0 143208
+libmysofa1 1.3.3+dfsg-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libm/libmysofa/libmysofa1_1.3.3+dfsg-1_arm64.deb 691ae51a7b5643fb9f7c81c917d12c1dc71c74eb1cf2073f0d3f71141fbffa8a 1156924
+libncursesw6 6.5+20250216-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/n/ncurses/libncursesw6_6.5+20250216-2_arm64.deb 72121aeb08be2d915da321ddfae74f62a0764286f336279b2c2609ba07496d6d 124048
+libnorm1t64 1.5.9+dfsg-3.1+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/n/norm/libnorm1t64_1.5.9+dfsg-3.1+b2_arm64.deb 5e814795f4cb6ba23c5bb091ecabe1ef1e3336f128e2bacf0f64ad593f918168 205272
+libnuma1 2.0.19-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/n/numactl/libnuma1_2.0.19-1_arm64.deb 23bd0d4ecdc8cb44438791c10aab969bc9eb11a4b635aae573376c4e23994ff5 21612
+libogg0 1.3.5-3+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libo/libogg/libogg0_1.3.5-3+b2_arm64.deb d59a83ab352bf0c16ce9513fdf264f87214813ca8c628c652801ef476ece8286 23580
+libopenal-data 1:1.24.2-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/o/openal-soft/libopenal-data_1.24.2-1_all.deb 003fb223f6ccd387adc28357021c243c604591806afb84dc46e906b911d8de38 167780
+libopenal1 1:1.24.2-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/o/openal-soft/libopenal1_1.24.2-1_arm64.deb 2431891da0bce880529768817087a7789000f07d24e201f13ff07a1ace9b40b5 577344
+libopenjp2-7 2.5.3-2.1~deb13u2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/o/openjpeg2/libopenjp2-7_2.5.3-2.1~deb13u2_arm64.deb e27f4d03d4b5836473be3210b16567aa9435a337f8c4537868773a123f9c9e57 189464
+libopenmpt0t64 0.7.13-1+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libo/libopenmpt/libopenmpt0t64_0.7.13-1+b1_arm64.deb 29e78a3abedd46155a241d64eba0baae5a7a4ba836faac412da94954cc56be7e 745204
+libopus0 1.5.2-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/o/opus/libopus0_1.5.2-2_arm64.deb 1d980e8a4717074805a98dbe07671cb3bee068c25709315f3de836980c629836 2812952
+libp11-kit0 0.25.5-3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/p/p11-kit/libp11-kit0_0.25.5-3_arm64.deb 78bfc746e68a5217e845f488f69100ed89d10c8886fbd3ffce937acb6a7d88fb 409108
+libpango-1.0-0 1.56.3-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/p/pango1.0/libpango-1.0-0_1.56.3-1_arm64.deb 5c5c6061afdff84a76418c9c2cf8bd4f3b6174aa7bf39ddf58bfa7702a59d3f2 212956
+libpangocairo-1.0-0 1.56.3-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/p/pango1.0/libpangocairo-1.0-0_1.56.3-1_arm64.deb 1bb68c8dfa0f829cf9834a2dec4af49f82a8dd211e3a9c1fa0446b3f32fa6991 33676
+libpangoft2-1.0-0 1.56.3-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/p/pango1.0/libpangoft2-1.0-0_1.56.3-1_arm64.deb f0e32d579c7b40dee0ed43355dd832857cf5d477cfb50b0bda56097eca8a81c0 52940
+libpgm-5.3-0t64 5.3.128~dfsg-2.1+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libp/libpgm/libpgm-5.3-0t64_5.3.128~dfsg-2.1+b1_arm64.deb 6db0a545d79fd0c5009fa4c31bd90beae50fb02b413ec71bb0fc482219b83a9f 151800
+libpixman-1-0 0.44.0-3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/p/pixman/libpixman-1-0_0.44.0-3_arm64.deb b502cd8b1ece222f42b44c42c33a300d84152c20089660167b9422ad2ebb6132 168440
+libplacebo349 7.349.0-3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libp/libplacebo/libplacebo349_7.349.0-3_arm64.deb 6ab590a2bd40c7d0c988accc10f794a1733cdc085d45431e3ff9e78da8348245 2275192
+libpng16-16t64 1.6.48-1+deb13u6 https://snapshot.debian.org/archive/debian-security/20261117T000000Z/pool/updates/main/libp/libpng1.6/libpng16-16t64_1.6.48-1+deb13u6_arm64.deb 57177299a638e30032a7191cc32a1b25fe4de7565164d770685d6d7f56771317 275220
+libpocketsphinx3 0.8+5prealpha+1-15+b4 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/p/pocketsphinx/libpocketsphinx3_0.8+5prealpha+1-15+b4_arm64.deb d0a2b514f8859912fc09d7cd39a80f3c1359d5172535cece37df2f4f124fc911 114512
+libpostproc58 7:7.1.5-0+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/ffmpeg/libpostproc58_7.1.5-0+deb13u1_arm64.deb ea17487d3003cd99a8dbdb7988e2b8f5b60cd73c750b135e86d75eb0bfe2f67d 86924
+libpulse0 17.0+dfsg1-2+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/p/pulseaudio/libpulse0_17.0+dfsg1-2+b1_arm64.deb 2de5610e3affe69cfb11110f890375261b47c9e0fc1a81eef7ecc4d6d2dc9a6d 236376
+librabbitmq4 0.15.0-1+deb13u2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libr/librabbitmq/librabbitmq4_0.15.0-1+deb13u2_arm64.deb 5407e9b4347ac405211c5719898aedcaf2d701c45977ec49704f3dc2ad281e2f 41500
+librav1e0.7 0.7.1-9+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/r/rust-rav1e/librav1e0.7_0.7.1-9+b2_arm64.deb 1b81b3c3494033bb32573442ce49f253dc76e262de8b28d4bfa3f433cd9783d4 661792
+libraw1394-11 2.1.2-2+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libr/libraw1394/libraw1394-11_2.1.2-2+b2_arm64.deb 23af99af78c3eaac033f14e62958f83a2748e8df1467c32840957431bacef911 38112
+librist4 0.2.11+dfsg-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libr/librist/librist4_0.2.11+dfsg-1_arm64.deb c0614f5e8696430801e201d958bc00d442008e9bd58915313a314cac475b295c 69008
+librsvg2-2 2.60.0+dfsg-1+deb13u1 https://snapshot.debian.org/archive/debian-security/20261117T000000Z/pool/updates/main/libr/librsvg/librsvg2-2_2.60.0+dfsg-1+deb13u1_arm64.deb f0ce936ee724964f62d7c31a4f826a5f13e13b7d44cd44ccae2f241c1b08ad2b 1583652
+librubberband2 3.3.0+dfsg-2+b3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/r/rubberband/librubberband2_3.3.0+dfsg-2+b3_arm64.deb ae06e140bb236367c99e9b03fb5ec0ad2cd3fcc491506ba8403197a5e2e4b2de 122784
+libsamplerate0 0.2.2-4+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libs/libsamplerate/libsamplerate0_0.2.2-4+b2_arm64.deb 5d9fad694b249d48d8457e1242ab60e04db6a30d7d56f80c6ae463ff122147ec 944716
+libsdl2-2.0-0 2.32.4+dfsg-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libs/libsdl2/libsdl2-2.0-0_2.32.4+dfsg-1_arm64.deb 6312ccbc29645ac5cc9dde9f9ed8bd5c85a0233690c270c83c963b49f8cd49d5 602568
+libsensors-config 1:3.6.2-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/l/lm-sensors/libsensors-config_3.6.2-2_all.deb 3056da80c7d963af795dab480ab6f6f4b154ad4ac39f522dc52d17c834fea253 16236
+libsensors5 1:3.6.2-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/l/lm-sensors/libsensors5_3.6.2-2_arm64.deb 7469f1ccce8afdba33d3b11847d0ecdf2221805a0694dee21ee4d622e8f72145 36444
+libserd-0-0 0.32.4-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/s/serd/libserd-0-0_0.32.4-1_arm64.deb 01205ff5c346ae395ec3066034e151e8100e46f596afc65d9bba7a80cce129ae 45596
+libsharpyuv0 1.5.0-0.1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libw/libwebp/libsharpyuv0_1.5.0-0.1_arm64.deb 5a37f40f806df4b67a2bdaa750add7a9ff29abd3119a8ceac773b886cbf3d9f9 114456
+libshine3 3.1.1-2+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/s/shine/libshine3_3.1.1-2+b2_arm64.deb d54a5f7154c0e826338bb18c34c69de9a036f3264adf59cef39bc30f07baa6d0 24584
+libslang2 2.3.3-5+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/s/slang2/libslang2_2.3.3-5+b2_arm64.deb ac285fde2e049ef3397c427d93d9fc7c08c688ef2643e4a6b2d5468957ca9100 506348
+libsnappy1v5 1.2.2-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/s/snappy/libsnappy1v5_1.2.2-1_arm64.deb b307da3076ad257cd8adec2faa5ad051fa9bd54edc1f473ecaf69b1456fdebd2 28320
+libsndfile1 1.2.2-2+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libs/libsndfile/libsndfile1_1.2.2-2+deb13u1_arm64.deb 6c94f17e1f02778f98b96bb9ae19ff30085662e96685898a018c26bfd4bfc3f2 185528
+libsodium23 1.0.18-1+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libs/libsodium/libsodium23_1.0.18-1+deb13u1_arm64.deb d94fc46204b65a965e356ebc19f9f88aeb20a9c777cb9a6569e75f75d0ae5523 120444
+libsord-0-0 0.16.18-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/s/sord/libsord-0-0_0.16.18-1_arm64.deb d2a648495869e680c7ecd107dad0c716590fec427817db703f3bebf719b37f59 17284
+libsoxr0 0.1.3-4+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libs/libsoxr/libsoxr0_0.1.3-4+b2_arm64.deb 1dc754a7d84c5a79d9cdd04c85760e735e2fe7cec7535f9991251a5a8ab851a1 54908
+libspeex1 1.2.1-3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/s/speex/libspeex1_1.2.1-3_arm64.deb 20e12b5754792b5d2c4386c4f405d652c4d6f91ec4e6f68b0c70a48bf3095a28 50368
+libsphinxbase3t64 0.8+5prealpha+1-21+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/s/sphinxbase/libsphinxbase3t64_0.8+5prealpha+1-21+b1_arm64.deb 408f2ac2ad4550e646b29741580ff5398e0b717d5b59a4d5d96116a07e6f7b18 111896
+libsratom-0-0 0.6.18-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/s/sratom/libsratom-0-0_0.6.18-1_arm64.deb 5ebc866e3632741477cc225a3a927ddacae432238494e73c50b07c00420d2406 16040
+libsrt1.5-gnutls 1.5.4-1+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/s/srt/libsrt1.5-gnutls_1.5.4-1+deb13u1_arm64.deb 9241d9103847ec59e96699533daceb4ac95d18d7d652df6e56218f2d77f1e8c9 301436
+libssh-4 0.11.5-0+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libs/libssh/libssh-4_0.11.5-0+deb13u1_arm64.deb bc70c157a3850050e256d293be0e5a851b1f98ae6dd4e31b2c7d237b670eb1c9 199476
+libsvtav1enc2 2.3.0+dfsg-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/s/svt-av1/libsvtav1enc2_2.3.0+dfsg-1_arm64.deb 9b7de4fcdaba3fdc0fe8eed956cd5ce270158c858493db901bfcb9bd4a432fb6 1557884
+libswresample5 7:7.1.5-0+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/ffmpeg/libswresample5_7.1.5-0+deb13u1_arm64.deb ab19f630592925e70e9f8d6e12fc53d756d292d28d4f6154f1c3e393c3a87aa3 102248
+libswscale8 7:7.1.5-0+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/f/ffmpeg/libswscale8_7.1.5-0+deb13u1_arm64.deb c091c8c7d7c4519280a33464eadf9280eaf9287486a5339e237ad39faa8c337c 214504
+libtasn1-6 4.20.0-2+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libt/libtasn1-6/libtasn1-6_4.20.0-2+deb13u1_arm64.deb e421da949cd26245f24c594265d6a01900b5e060e80793f68b977f7bfaa009ef 47304
+libthai-data 0.1.29-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libt/libthai/libthai-data_0.1.29-2_all.deb fd38d40602834d510a29140bd27fd48485105e834f03dccab1c02e2edaa794dd 167504
+libthai0 0.1.29-2+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libt/libthai/libthai0_0.1.29-2+b1_arm64.deb 4ea5b9d09449023a30e4d5237b8a69e19d6b3e576e36570818c87a093e2b5eec 48440
+libtheoradec1 1.2.0~alpha1+dfsg-6 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libt/libtheora/libtheoradec1_1.2.0~alpha1+dfsg-6_arm64.deb e233aa1a1d345e6db838040f0ced479c5cda3fcc04d6637468275c398f585924 52560
+libtheoraenc1 1.2.0~alpha1+dfsg-6 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libt/libtheora/libtheoraenc1_1.2.0~alpha1+dfsg-6_arm64.deb b09a5ad17f11b0f90b7d0f0262dc363b6ec59625a9b55d1cdc2a6feb7c7f349e 99108
+libtiff6 4.7.0-3+deb13u3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/t/tiff/libtiff6_4.7.0-3+deb13u3_arm64.deb 208e9fdc14ed88a30f31fdfb993d1e8ab19f9ab29f3cd8546ffb4ea3f74f5a3f 325232
+libtwolame0 0.4.0-2+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/t/twolame/libtwolame0_0.4.0-2+b2_arm64.deb e83981a1c10e43b09c1b8b6624a2d814b7d0c965f0d9ddf771606feb7cd29b72 49288
+libudfread0 1.1.2-1+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libu/libudfread/libudfread0_1.1.2-1+b2_arm64.deb badab108ac953987ced64c4b25a38c75ac391e6f4815cca4880619f313b4da22 17312
+libunibreak6 6.1-3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libu/libunibreak/libunibreak6_6.1-3_arm64.deb 8689f3761d5ac0dd9119f187561dd61dbb8b273d3a684fc57fbcc3de9daac9ed 21464
+libunistring5 1.3-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libu/libunistring/libunistring5_1.3-2_arm64.deb 4847467a0e47039837895e88f5a99a4a86a3d8266be40c3c896fc7c10d552dc7 452856
+libusb-1.0-0 2:1.0.28-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libu/libusb-1.0/libusb-1.0-0_1.0.28-1_arm64.deb 1eed4dc72f3e6fe22dc8c20aba32f0c0c596a51d3e1c1e4c401937005e78ef11 56108
+libva-drm2 2.22.0-3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libv/libva/libva-drm2_2.22.0-3_arm64.deb 18e556968a0f4bffd321d67b01fa5e445177c0849bef96a741aa7ed3a11dcc8b 18544
+libva-x11-2 2.22.0-3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libv/libva/libva-x11-2_2.22.0-3_arm64.deb a2c63e408e4adaa0ee8da79e2c439cc2b0b644460dba84637e8cef466ed6c884 23004
+libva2 2.22.0-3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libv/libva/libva2_2.22.0-3_arm64.deb 7a5e7cbaaddf1f39973c10f9daae6769b704e0d6d72fe752d64003929272cbcf 74212
+libvdpau1 1.5-3+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libv/libvdpau/libvdpau1_1.5-3+b1_arm64.deb 2ec2bf9930e402330e6b165645cdcb1e5b8528ac9782651d0217e4f827bf1451 24356
+libvidstab1.1 1.1.0-2+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libv/libvidstab/libvidstab1.1_1.1.0-2+b2_arm64.deb 2089ffc9e6f69a0ae0abac293428120cf64b62550dd6ad2a43c1ccea5c93498d 36752
+libvorbis0a 1.3.7-3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libv/libvorbis/libvorbis0a_1.3.7-3_arm64.deb 6e8e64ebe692dd2d019af7f914f2e3b81bf13d4b1ce2516fb4248a0310ef7cf6 83772
+libvorbisenc2 1.3.7-3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libv/libvorbis/libvorbisenc2_1.3.7-3_arm64.deb 4a477b3ae19ba50a288f036c8176d61cd9f3836ba65472f88b95e3f6b3bf2dd3 75532
+libvorbisfile3 1.3.7-3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libv/libvorbis/libvorbisfile3_1.3.7-3_arm64.deb 6eea69ab6f851955736abe56002551e304eb36cffdc9e9a1a21fb578ca3632ff 20136
+libvpx9 1.15.0-2.1+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libv/libvpx/libvpx9_1.15.0-2.1+deb13u1_arm64.deb 96b7d384a6f090cf11f4634a9ad443a767ce7fa930b9b3136c27886a17e21d41 1158384
+libvulkan1 1.4.309.0-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/v/vulkan-loader/libvulkan1_1.4.309.0-1_arm64.deb f5f576d8b9e5703702a9f3254c8c5d130bef17da9db4aecd46ba86cec7a08930 126808
+libwayland-client0 1.23.1-3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/w/wayland/libwayland-client0_1.23.1-3_arm64.deb 8abdc649e46470548c545f827e16f52e1bc16d05d4a3794e6dedb2d74ce58c9a 26140
+libwayland-cursor0 1.23.1-3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/w/wayland/libwayland-cursor0_1.23.1-3_arm64.deb 824c1ca46458530a670bfd003f1c083e66e395e1800c294a22af38641ccdc11a 11732
+libwayland-egl1 1.23.1-3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/w/wayland/libwayland-egl1_1.23.1-3_arm64.deb fe01fb2f3c5d5b54784563d9826fa505fab61dc30333d71343352bddd3812b18 5952
+libwayland-server0 1.23.1-3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/w/wayland/libwayland-server0_1.23.1-3_arm64.deb 062702d57cf07b42ab7f0fa1aac8bc3f605eb47f2f0b9ecb1614674140d79f1b 33656
+libwebp7 1.5.0-0.1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libw/libwebp/libwebp7_1.5.0-0.1_arm64.deb d5ebdb920770ee135c4e319babb2bcef61e9f37283a37a8cb4e673769dd0d676 271148
+libwebpmux3 1.5.0-0.1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libw/libwebp/libwebpmux3_1.5.0-0.1_arm64.deb 84a98af076003c5a502afb95b2a1412e14dbe029e10272ddcdf2ac6f75d8c0d1 124504
+libx11-6 2:1.8.12-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libx11/libx11-6_1.8.12-1_arm64.deb 646f2d3f2165c8eebceb7f4aaca31e97a818bb11a045964833a9f764b738bac2 794952
+libx11-data 2:1.8.12-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libx11/libx11-data_1.8.12-1_all.deb c54f87069888f80ba4da586da6147d74c7598ccdd8b90906dbc4271fa414c738 343072
+libx11-xcb1 2:1.8.12-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libx11/libx11-xcb1_1.8.12-1_arm64.deb 1eafaa4295e129d6a81e742ab8da43194daa6b916199923c8cef8ad358985894 247336
+libx264-164 2:0.164.3108+git31e19f9-2+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/x/x264/libx264-164_0.164.3108+git31e19f9-2+b1_arm64.deb e062e2ed96d60fdc3ebba5714957e4bfc76e1c87ff6cfa7c022cea3052573f94 453616
+libx265-215 4.1-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/x/x265/libx265-215_4.1-2_arm64.deb c786ffe37393781b39fa99100aaa93891436dc0d8e0a4a5209cc1102679ebe22 1856972
+libxau6 1:1.0.11-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxau/libxau6_1.0.11-1_arm64.deb ac1061728670f4626adaa1288953a0e6fb801c9cae72ee1c3231e63e2609d23a 20576
+libxcb-dri3-0 1.17.0-2+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxcb/libxcb-dri3-0_1.17.0-2+b1_arm64.deb 247bf758dd78d6c285fdd47942ddacf4a3189fd50de4f0891c9bd9aea12da3a1 107068
+libxcb-glx0 1.17.0-2+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxcb/libxcb-glx0_1.17.0-2+b1_arm64.deb a0d96ab5faea8fa1f3e095d6236597622a6b763f061f8f9fa23b77733608fdbc 122608
+libxcb-present0 1.17.0-2+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxcb/libxcb-present0_1.17.0-2+b1_arm64.deb 73521d715554a2230901d1d480465d6358b3083a5ce8801639595ffde6f31441 105784
+libxcb-randr0 1.17.0-2+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxcb/libxcb-randr0_1.17.0-2+b1_arm64.deb dbeb78d1d032959fe65548758ab12bfc6bb5919ec2984c3d871496b52aef929a 116736
+libxcb-render0 1.17.0-2+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxcb/libxcb-render0_1.17.0-2+b1_arm64.deb 7d6faf0afad0b27a047bbf320bf80999e94b7e6a0f73e42069e8b08958910466 114896
+libxcb-shape0 1.17.0-2+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxcb/libxcb-shape0_1.17.0-2+b1_arm64.deb 49f24031f68b9188524954fd1cc237d7cbfe9392d91624cef88d06be13c8075f 105784
+libxcb-shm0 1.17.0-2+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxcb/libxcb-shm0_1.17.0-2+b1_arm64.deb e9e871dc5d2f9265eb5d3028f0d0545cb6f8b748a68997b4c43f5a9416c7ead7 105480
+libxcb-sync1 1.17.0-2+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxcb/libxcb-sync1_1.17.0-2+b1_arm64.deb eb428ac77daac9e5eea8a4e9ba48d1d78cc8ca400e415c8e4628cc729c6f4749 108792
+libxcb-xfixes0 1.17.0-2+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxcb/libxcb-xfixes0_1.17.0-2+b1_arm64.deb 19cdb8502827bc010993e69eaba09c670024976f7edd35b2b504bd646b141b0a 109644
+libxcb1 1.17.0-2+b1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxcb/libxcb1_1.17.0-2+b1_arm64.deb d0178198e80ed4cacdececabe2c112ec88c7a9258cc11a55b8e267ab14a90d82 143168
+libxcursor1 1:1.2.3-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxcursor/libxcursor1_1.2.3-1_arm64.deb 76d13a27c444f88c44cf50e209e8f9dc5088da330680bd35f6eba0430662a4b5 39252
+libxdmcp6 1:1.1.5-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxdmcp/libxdmcp6_1.1.5-1_arm64.deb e10bbb0802181992ecf091e9425171850eee16068729c109214ba4924f81fb52 27752
+libxext6 2:1.3.4-1+b3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxext/libxext6_1.3.4-1+b3_arm64.deb 27cf208c6d2924b22ed3b9ceff304b992e1f07ef7b0ef00239585595581dac99 49244
+libxfixes3 1:6.0.0-2+b4 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxfixes/libxfixes3_6.0.0-2+b4_arm64.deb d29134cbb9230a50ba1d097743d4d4fcf7826c6b48a2d8a303a0e3fc20b837e6 20456
+libxi6 2:1.8.2-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxi/libxi6_1.8.2-1_arm64.deb b7148d371c908fa81bf45153fdcb3e7d178fe11e15f9907e29ce6e9ed9aaad24 77768
+libxkbcommon0 1.7.0-2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxkbcommon/libxkbcommon0_1.7.0-2_arm64.deb 866888d3cfeb32388dd88a2615c4f78ebf8dd7b272821a83494cba260d8fa7d1 106024
+libxml2 2.12.7+dfsg+really2.9.14-2.1+deb13u3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxml2/libxml2_2.12.7+dfsg+really2.9.14-2.1+deb13u3_arm64.deb a66b9c960acef8ed9653223cbd00b155a92ebb758ea13a788c41609246c23bc7 631428
+libxrandr2 2:1.5.4-1+b3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxrandr/libxrandr2_1.5.4-1+b3_arm64.deb 607a23d6d2cb920e000b24870531a86821cf4e141a4eb0bf38212b47b892d597 35932
+libxrender1 1:0.9.12-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxrender/libxrender1_0.9.12-1_arm64.deb 28396c96e460288d5851913121b053609f7ff34f996d78d7a38c1d2b6ab9f006 27024
+libxshmfence1 1.3.3-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxshmfence/libxshmfence1_1.3.3-1_arm64.deb 34b494c83cebcf138d1f87c2cbdd5ee8efe9da2befbd69c2a025b0e214c64d2d 11104
+libxss1 1:1.2.3-1+b3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxss/libxss1_1.2.3-1+b3_arm64.deb ffbdfe7ee0644984dfe7577a22edee74f1e3b2dd76721417c8e45aed9388a220 17088
+libxv1 2:1.0.11-1.1+b3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxv/libxv1_1.0.11-1.1+b3_arm64.deb 2f03e7ab18a58c0a85f22b6b12b51fcf7c376abae6d270ea7b8d7a9bf450fec2 23252
+libxvidcore4 2:1.3.7-1+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/x/xvidcore/libxvidcore4_1.3.7-1+b2_arm64.deb 82ec04ee5561e5f01e0c93c4a7feb68252cd14a2cddf6622c006a01ea6bb0471 202032
+libxxf86vm1 1:1.1.4-1+b4 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/libx/libxxf86vm/libxxf86vm1_1.1.4-1+b4_arm64.deb 9ed4bb25e311486207eeaa609decc3905aa9071c4c7f2a605829e3a79ec88b83 19176
+libz3-4 4.13.3-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/z/z3/libz3-4_4.13.3-1_arm64.deb 29a7b924a5a38c9ac4e2a64aa11586a9c54f26b579b18e4f75adf8f7c1106e45 7506868
+libzimg2 3.0.5+ds1-1+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/z/zimg/libzimg2_3.0.5+ds1-1+b2_arm64.deb 5f71dc6a1c7b91df4564a41b299e216b574e94e99afc49ff3f334be3816e3d5a 116636
+libzix-0-0 0.6.2-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/z/zix/libzix-0-0_0.6.2-1_arm64.deb 6848ea4b2911b670c8b7bf106c932eabd715c56819af4998f77a09a6be69a479 22532
+libzmq5 4.3.5-1+b3 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/z/zeromq3/libzmq5_4.3.5-1+b3_arm64.deb 6a83a68a091963c59b00ea68b5ed78180206fb2d93fe32432c5be5dc9d624d1f 253096
+libzvbi-common 0.2.44-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/z/zvbi/libzvbi-common_0.2.44-1_all.deb 98ab88223df2380c79d048c6bd276449c64603eef4e43aa99d52406877ebee59 71436
+libzvbi0t64 0.2.44-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/z/zvbi/libzvbi0t64_0.2.44-1_arm64.deb ce0fa37ceeffcf844bbee9b00eba8e8dcffc1bf1a772007c8710ac6491598941 262392
+lsb-base 11.6 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/l/lsb/lsb-base_11.6_all.deb f8bedd167280e76636df3a1bc023cd2906d458916c1af4c1d7912c5b971fc642 4584
+mesa-libgallium 25.0.7-2+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/m/mesa/mesa-libgallium_25.0.7-2+deb13u1_arm64.deb a27576030704ff305adaef8bd143954b281680861d5bfe21aabd7d376a939149 8032536
+ocl-icd-libopencl1 2.3.3-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/o/ocl-icd/ocl-icd-libopencl1_2.3.3-1_arm64.deb eadc1b9341c36dbac2ad2f1ae159f55533512cec888425d53e42abacd814742b 42684
+shared-mime-info 2.4-5+b2 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/s/shared-mime-info/shared-mime-info_2.4-5+b2_arm64.deb a68086d0fdffc32fa05b1768f67b83d06344b026a855e29daa7ff02d64deec59 756268
+x11-common 1:7.7+24+deb13u1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/x/xorg/x11-common_7.7+24+deb13u1_all.deb 57a981938506b26dc552f19cafeaa8c04e9b59dc7508509151f8507a9d4e5f24 216864
+xkb-data 2.42-1 https://snapshot.debian.org/archive/debian/20261117T000000Z/pool/main/x/xkeyboard-config/xkb-data_2.42-1_all.deb 196ff18533382f64e057ea49df2bb486bd4275a4cc0917361edb560b8756dada 789736
+zlib1g 1:1.3.dfsg+really1.3.1-1+deb13u1 https://snapshot.debian.org/archive/debian-security/20261117T000000Z/pool/updates/main/z/zlib/zlib1g_1.3.dfsg+really1.3.1-1+deb13u1_arm64.deb 0e41b3d7ad8ad7fcd36dd4d61ca91a70018478fc4af652e044f4be770784ddff 85028
diff --git a/docs/superpowers/notes/media-conversion-copy-deck.md b/docs/superpowers/notes/media-conversion-copy-deck.md
index feb4987e4..71ef861db 100644
--- a/docs/superpowers/notes/media-conversion-copy-deck.md
+++ b/docs/superpowers/notes/media-conversion-copy-deck.md
@@ -595,6 +595,31 @@ prints nothing.
| `engine.codec.error_unwritten` | `codec: the result naming %s could not be written` (pending Luna pass; plan 3 Task 6). `%s` is the job error code |
| `engine.codec.unexpected` | `codec: an unexpected %T ends the job` (pending Luna pass; plan 3 Task 6). `%T` is a Go error type, never its text |
+### Image tool: `mediaimage` (plan 3 Task 8)
+
+Operator-facing text from `cmd/mediaimage`, which builds and pushes the engine image. Its success output is a path or an image digest, on stdout.
+
+| Key | Text |
+|---|---|
+| `image.usage` | `usage: mediaimage <lock\|build\|push> [flags]` (pending Luna pass; plan 3 Task 8) |
+| `image.error` | `mediaimage: %s`, the prefix of every failure on stderr (pending Luna pass; plan 3 Task 8) |
+| `image.flags` | `snapshot.debian.org timestamp, YYYYMMDDTHHMMSSZ`; `base image, docker.io/library/debian@sha256:<digest>`; `lock file to write`; `directory that keeps downloads between runs`; `lock file`; `carlos-media built for linux/arm64`; `image creation time, RFC 3339`; `directory to write the OCI layout to`; `OCI layout written by build`; `image repository, <registry>/<repo>`; `release tag; each release has its own, never reused` (pending Luna pass; plan 3 Task 8) |
+| `image.lock.refused` | `bad lock file: line %d: %s`, the reason one of `the snapshot is not YYYYMMDDTHHMMSSZ`, `the base is not pinned by digest`, `the lock starts with # snapshot and # base`, `packages are not sorted`, `a package line has five columns`, `the size is not a positive number`, `the sha256 is not 64 hex digits`, `the url is not https`, `the package or version is empty`; `bad lock file: no packages`; `bad lock file: no ffmpeg package`; `bad lock file: --snapshot is not YYYYMMDDTHHMMSSZ`; `bad lock file: --out is required` (pending Luna pass; plan 3 Task 8) |
+| `image.lock.unresolved` | `unresolved dependency: no package %s in the snapshot`; `unresolved dependency: %s depends on %s` (pending Luna pass; plan 3 Task 8) |
+| `image.base.refused` | `bad base image: %q is not <registry>/<repo>@sha256:<digest>`; `bad base image: no linux/arm64 image`; `bad base image: the image is %s/%s`; `bad base image: %d layers and %d diff ids`; `bad base image: layer type %s`; `bad base image: the base image has no var/lib/dpkg/status`; `bad base image: the registry asked for %q sign-in`; `bad base image: the registry's token address is not https` (pending Luna pass; plan 3 Task 8) |
+| `image.hash` | `sha256 mismatch: %s holds %s, want %s`; `sha256 mismatch: downloaded %s, want %s` (pending Luna pass; plan 3 Task 8) |
+| `image.deb.refused` | `bad deb: not an ar archive`; `bad deb: no data member`; `bad deb: a member header is damaged`; `bad deb: a member size is damaged`; `bad deb: a member is cut short`; `bad deb: %s is not a compression this tool reads` (pending Luna pass; plan 3 Task 8) |
+| `image.entry.refused` | `refused package entry: %s leaves the root`; `refused package entry: %s would delete files from a lower layer`; `refused package entry: hard link %s has no target in its package`; `refused package entry: %s is not a file, directory or link` (pending Luna pass; plan 3 Task 8) |
+| `image.conflict` | `conflicting paths: two packages ship different %s`; `conflicting paths: a package directory %s covers a base file`; `conflicting paths: a package entry %s covers a base directory` (pending Luna pass; plan 3 Task 8) |
+| `image.library` | `unresolved library: /%s needs %s`, joined by `; ` when there are several; `unresolved library: %s no longer ships %s` (pending Luna pass; plan 3 Task 8) |
+| `image.executable` | `missing executable: /%s is not an arm64 program` (pending Luna pass; plan 3 Task 8) |
+| `image.build.refused` | `--out, --binary and --cache are required`; `--created: %s`; `%s exists and is not an image layout` (pending Luna pass; plan 3 Task 8) |
+| `image.push.refused` | `push refused: CARLOS_REGISTRY_PASSWORD is not set`; `push refused: --tag must be a release tag`; `push refused: --repo must be <registry>/<repo>`; `push refused: the layout holds %d manifests` (pending Luna pass; plan 3 Task 8) |
+| `image.push.tag` | `tag already holds another image: %s is %s, this image is %s` (pending Luna pass; plan 3 Task 8) |
+| `image.push.digest` | `the registry holds a different image: %s after the push, want %s` (pending Luna pass; plan 3 Task 8) |
+| `image.http` | `%s: HTTP %d`, the operation one of `GET %s`, `read manifest %s`, `check blob`, `start upload`, `upload`, `finish upload`, `write manifest`. The registry's own answer is never repeated (pending Luna pass; plan 3 Task 8) |
+| `image.readme` | The whole of `deploy/media-image/README.md` (pending Luna pass; plan 3 Task 8) |
+
### Rollout checks: `selftest`, `drill` and the endpoint drill script (plan 3 Task 7)
Operator-facing text the rollout reads (R2-R4): one-off tasks' logs and