2.1 KiB
2.1 KiB
OCI import — internals
Advanced reading. This document describes implementation details of the OCI import pipeline. It is not needed for day-to-day use of
banger image pull. User-facing documentation is indocs/oci-import.md.
Architecture
internal/imagepull/ owns the mechanics:
Pullwrapsgo-containerregistry'sremote.Imagewith thelinux/amd64platform pinned. Layer blobs cache under/var/cache/banger/oci/blobs/(system install) or~/.cache/banger/oci/blobs/(dev mode) and populate lazily during flatten.Flattenreplays layers oldest-first into a staging directory, applies whiteouts, rejects unsafe paths plus filenames that banger's debugfs ownership fixup cannot encode safely. Returns aMetadatamap of per-file uid/gid/mode from tar headers.BuildExt4runsmkfs.ext4 -F -d <staging> -E root_owner=0:0at the size of the pre-truncated file — no mount, no sudo, no loopback. Requirese2fsprogs ≥ 1.43.ApplyOwnershipstreams a batchedset_inode_fieldscript todebugfs -wto rewrite per-file uid/gid/mode to the captured tar- header values.InjectGuestAgentsuses the samedebugfsscripting to drop banger's guest assets into the ext4 with root ownership: vsock agent binary, network bootstrap + unit, first-boot script + unit,multi-user.target.wantssymlinks, vsock modules-load config,/var/lib/banger/first-boot-pendingmarker.
internal/daemon/images_pull.go orchestrates pullFromOCI:
- Parse + validate the OCI ref, derive a default name when
--nameis omitted (debian-bookwormfromdocker.io/library/debian:bookworm). - Resolve kernel info via
resolveKernelInputs(auto-pulls fromkernelcatif--kernel-refnames a catalog entry that isn't yet local). - Stage at
<ImagesDir>/<id>.staging; extract layers to a temp tree under$TMPDIR. BuildExt4→ApplyOwnership→InjectGuestAgents.imagemgr.StageBootArtifactsstages the kernel triple alongside.- Atomic
os.Renamepublishes the artifact dir. - Persist a
model.Image{Managed: true, …}record.