banger/internal/imagepull
Thales Maciel bb95a0a273
banger internal make-bundle: build image bundles from flat rootfs tars
New hidden subcommand that turns a `docker export`-style rootfs tar
into a banger bundle (`rootfs.ext4` + `manifest.json`, tar+zstd):

  1. FlattenTar (new in imagepull) extracts the stream into a staging
     dir while capturing per-file uid/gid/mode into a Metadata record.
  2. imagepull.BuildExt4 produces the ext4 via `mkfs.ext4 -d`.
  3. imagepull.ApplyOwnership re-applies the captured metadata with
     `debugfs sif` so setuid/root-owned files keep their identity.
  4. imagepull.InjectGuestAgents drops the vsock agent + network
     bootstrap + first-boot service into the ext4.
  5. manifest.json is written with name/distro/arch/kernel_ref.
  6. Both files are packaged as .tar.zst with max compression.

Flags: --rootfs-tar (file or '-' for stdin), --name, --distro, --arch,
--kernel-ref, --description, --size, --out. Stdout prints bundle path,
sha256, and size so callers can patch the catalog.

Unit tests cover flag registration, required-arg validation, the
bundle tar round-trip, sha256HexFile, and dirSize. An end-to-end test
runs the full pipeline against a synthesized tiny rootfs tar; skips
gracefully when mkfs.ext4 / debugfs / companion binaries are missing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 15:17:50 -03:00
..
assets Generic kernel + init= boot path for OCI-pulled images 2026-04-16 20:12:56 -03:00
ext4.go Phase 1: imagepull package — pull, flatten, ext4 2026-04-16 17:22:13 -03:00
firstboot.go Phase B-3: first-boot sshd install 2026-04-16 18:20:33 -03:00
firstboot_test.go Generic kernel + init= boot path for OCI-pulled images 2026-04-16 20:12:56 -03:00
flatten.go banger internal make-bundle: build image bundles from flat rootfs tars 2026-04-17 15:17:50 -03:00
imagepull.go imagepull.Pull: don't eager-open layer readers 2026-04-16 19:03:52 -03:00
imagepull_test.go imagepull.Pull: don't eager-open layer readers 2026-04-16 19:03:52 -03:00
inject.go Phase B-3: first-boot sshd install 2026-04-16 18:20:33 -03:00
inject_test.go Phase B-3: first-boot sshd install 2026-04-16 18:20:33 -03:00
ownership.go Phase B-1: ownership fixup via debugfs pass 2026-04-16 18:04:22 -03:00