# Image Pipeline

> Contributor tools that validate or offline-normalize qcow2 candidates for Barn's official Linux images.

---

LLMS index: [llms.txt](/v1.5/llms.txt)

---

This page is for contributors who build Barn's official Linux images; if you only use images, skip it. To share images of your own, [build a static repository](../../start/images/#build-a-static-repository) instead.

The tools live under `packaging/image-pipeline/` in the Barn source checkout. `build.sh` turns one downloaded `qcow2` with a known SHA-256 into a `testing` candidate bundle, either validated as it is or normalized offline; `build-official.py` runs it over the official matrix and assembles a candidate repository. The builder needs no network access or signing keys and leaves Barn's runtime state alone. Its output then goes through live smoke tests and release review.

- **Tools**: Python 3 and `qemu-img`; `offline` mode also needs working `libguestfs` tools (`virt-customize`, `virt-cat`). Override them with `--qemu-img`, `--virt-customize`, and `--virt-cat`, or with `QEMU_IMG`, `VIRT_CUSTOMIZE`, and `VIRT_CAT`.
- **Storage**: keep source images, RPM/DEB package caches, and output directories outside the Git working tree, which tracks only recipes and lockfiles.
- **Architecture**: `--arch` records the target architecture in the metadata; run `offline` customization where `libguestfs` can execute that architecture.

## Modes and profiles {#modes-and-profiles}

- **`validate`** copies and re-hashes the source, checks that it is a single-file `qcow2` with `qemu-img check`, and writes an evidence bundle without touching guest files or credentials.
- **`offline`** normalizes guest access on a staged copy with `virt-customize --no-network` and `virt-cat`: it confirms UID/GID `88` is free of unrelated accounts, configures the locked `dba`/`admin` identity, disables SSH password and root login, strips SSH host keys, shell history, machine-id, and `cloud-init` caches, restores SELinux labels, and reads back a deterministic guest marker.

The profile adds distribution-specific steps; `build.sh` defaults to `--profile base`:

| Profile | Normalization steps | Package inputs |
|---|---|---|
| `base` | Account, sudo, SSH, and cloud-init normalization only | None (package flags rejected) |
| `el8` | Base normalization plus Python 3, SSH drop-in include, legacy network cleanup, `chronyd`, and SELinux relabeling | Locked RPM dependency set |
| `el9` | Base normalization plus legacy network cleanup and SELinux relabeling | None (package flags rejected) |
| `el10` | Base normalization plus signed `kernel-modules` and `kernel-modules-extra` matching `kernel-core`, Docker bridge/iptables/overlay module verification, and SELinux relabeling | Locked RPM dependency set |
| `d12`, `d13` | Base normalization plus offline XFS userspace tools and `en_US.UTF-8` / `C.UTF-8` locale setup | Locked DEB dependency set |
{.wide .expand}

`validate` accepts only `--profile base`. In `offline` mode, `el8`, `el10`, `d12`, and `d13` require `--package-lock` and `--package-cache` matching the profile and architecture; `build-official.py` supplies both for official targets.

## Official candidate matrix {#official-candidate-matrix}

`build-official.py` builds the ten official targets, Debian 12 and 13 (`d12`, `d13`) and Rocky Linux 8, 9, and 10 (`el8`, `el9`, `el10`), each on `amd64` and `arm64`, from the upstream URLs, package locks, release versions, SHA-256 digests, and `SOURCE_DATE_EPOCH` pinned in `official-v1.json`. `--list` prints what your checkout pins. Ubuntu artifacts come from the same recipe run directly by `pipeline.py`, and need no offline package lock because Ubuntu cloud images already ship `xfsprogs`. [Debian source inspection and candidate tests](/v1.5/blog/design/image-refresh-20261203/) · [Rocky Linux image tests](/v1.5/blog/design/image-refresh-20261121/)

```bash
./packaging/image-pipeline/build-official.py --list

./packaging/image-pipeline/build-official.py \
  --source-cache /absolute/source-cache \
  --package-cache /absolute/package-cache \
  --output /absolute/existing-output-root \
  --target d13/arm64 --fetch
```

Create `--source-cache`, `--package-cache`, and `--output` beforehand and pass canonical absolute paths. `--fetch` downloads missing pinned HTTPS inputs and verifies their SHA-256 before `virt-customize --no-network` runs; without it, every locked input must already be cached. Omit `--target` to build all ten, or repeat it for a subset.

Once all ten bundles exist, assemble a candidate static repository from the **parent directory** that holds them, repeating `--assemble-from` for bundles spread over several parents:

```bash
./packaging/image-pipeline/build-official.py \
  --assemble-from /absolute/existing-output-root \
  --output /absolute/new-candidate-repository
```

Assembly requires exactly one bundle per target and a new `--output` path that does not exist yet. It runs `barn repo build` and `barn repo verify` with the `barn` on `PATH` or `--barn /absolute/path/to/barn`. The result maps channels to `candidate` (for example `d13:candidate`) with status `testing`, ready for live VM acceptance before promotion to `stable` and `supported`.

## Validate a single downloaded image {#validate-a-single-downloaded-image}

```bash
SOURCE_DATE_EPOCH=1796256000

./packaging/image-pipeline/build.sh \
  --mode validate \
  --source /absolute/debian-13-generic-amd64-20261130-2678.qcow2 \
  --expected-sha256 c0f41265017c18124897401ccdd335dd4e1a0c262092384d5e6723855acb7446 \
  --output /absolute/new/evidence-directory \
  --name d13 --release 20261130.2678.0 --arch amd64 \
  --source-user debian --boot uefi \
  --source-uri https://cloud.debian.org/images/cloud/trixie/20261130-2678/debian-13-generic-amd64-20261130-2678.qcow2 \
  --artifact-url 'https://images.example/d13/{sha256}.qcow2' \
  --license NOASSERTION \
  --source-date-epoch "$SOURCE_DATE_EPOCH" \
  --manifest-version 2026120301
```

`--source` must be a canonical absolute path to a regular file, not a symlink, of at most 16 GiB; that cap is the recipe's, while Barn checks runtime images against their catalog size ([local import](../images/#local-image-import)). `--output` must be a new path in an existing directory. The builder takes an adjacent lockfile, stages in a `0700` temporary directory, and renames the finished bundle into place; on failure it removes only its staging directory.

Each completed bundle contains:

| File | Purpose |
|---|---|
| `<name>-<release>-<arch>-<digest-prefix>.qcow2` | Validated read-only candidate `qcow2` image |
| `build-recipe.json` | Builder invocation, tool versions, and input digests |
| `manifest-candidate.json` | Unsigned candidate metadata (`status: "testing"`) |
| `provenance.intoto.json` | SLSA build provenance statement |
| `sbom.spdx.json` | SPDX software bill of materials covering declared pipeline inputs and injected packages |
| `validation.json` | Before/after `qcow2` checks, normalization marker results, and pending release gates |
| `checksums.txt` | SHA-256 checksums of the other files in the bundle |
| `package-lock.json` | Included when the profile installs locked RPM/DEB packages |
{.wide .expand}

## Promote a candidate {#promote-a-candidate}

With fixed inputs and tool versions, `validate` mode is byte-for-byte reproducible; for `offline` mode, build the candidate twice and compare the bundles as release evidence. To promote a candidate to a public `supported` release:

1. Run live VM smoke tests across the target host and guest combinations.
2. Update `repo.yaml` with the new catalog `revision` and `supported` status.
3. Run `barn repo build` and `barn repo verify`.
4. Sign `catalog.json` and publish its detached signature as `catalog.json.minisig`.
5. Verify the published repository endpoints.
{.steps}
