# Repository Commands

> Scan, build and verify a repository of qcow2 images, with optional metadata in repo.yaml.

---

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

---

A static repository has a flat `images/` directory and a generated `catalog.json`. In 1.5.0, `barn repo build` reads names, versions and architectures from filenames. Add `repo.yaml` for aliases, channels, nonstandard names or different boot settings. [Build a static repository](../../../start/images/#build-a-static-repository) · [Repository format](../../images/#static-repository-format)

```bash
barn repo scan /srv/barn     # inspect the files under images/
barn repo build /srv/barn    # write catalog.json
barn repo verify /srv/barn   # compare the catalog with the images and optional metadata
```

All three have been available since 1.1.0. Each takes one repository root and has no options beyond the [global options](/v1.5/docs/reference/commands/#global-options).

## `barn repo scan` {#barn-repo-scan}

```text
barn repo scan <root> [flags]
```

Report the state of every `qcow2` file without changing anything or needing `qemu-img`:

| State | Meaning |
|---|---|
| `tracked` | Selected by filename inference or `repo.yaml`, and present |
| `missing` | Referenced by `repo.yaml` but absent from `images/` |
| `untracked` | Present in `images/` but not referenced by `repo.yaml` |
| `unsafe` | Not a safe regular `qcow2` file |

`--json` returns `root` and the four arrays. The scan exits `0` whenever it completes, even with findings, so a script must check `missing` and `unsafe` itself:

```bash
barn --json repo scan /srv/barn | jq -e '(.missing + .unsafe) | length == 0'
```

## `barn repo build` {#barn-repo-build}

```text
barn repo build <root> [flags]
```

Inspect selected images with `qemu-img` and atomically write `catalog.json` with the final digests and sizes. A supplied `repo.yaml` controls selection. A missing or unsafe declared artifact fails the build.

With an explicit `revision`, increase it when the catalog changes. With the revision omitted, Barn assigns it automatically and preserves the previous bytes on an unchanged rebuild. Upload immutable images before publishing the catalog. [Signing and trust rules](../../repository-signing/)

```bash
barn repo build /srv/barn
barn --json repo build /srv/barn
```

## `barn repo verify` {#barn-repo-verify}

```text
barn repo verify <root> [flags]
```

Rebuild the catalog in memory from the filenames, optional `repo.yaml` and actual image bytes, and require a byte-for-byte match with the existing `catalog.json`. Requires `qemu-img`. Run it before publishing or after copying a repository. It checks consistency only; clients check signatures when they activate the catalog.

```bash
barn repo verify /srv/barn
barn --json repo verify /srv/barn
```

## Implementation {#implementation}

The [self-hosted repository guide](../../repository-signing/#user-repository) gives a two-command example.
