Skip to content

sow repo

Create, list, inspect, migrate, and remove standard repositories, each with its own package pool, indexes, and build history.

A standard repository is one directory tree in the workspace with its own package pool (pool/), indexes (dists/), database, and build history. Its Dists share the pool, so a package used by several Dists is stored once. sow repo creates, lists, inspects, upgrades, and removes these repositories. Put packages in separate repositories when they need separate signing, deletion protection, or publication targets; otherwise add Dists to one repository with sow dist.

Synopsis

sow repo ls [-C DIR] [--json]
sow repo new NAME [-C DIR] [-T DUR | -N] [--json] [--passfile PATH]
sow repo show [NAME] [-C DIR] [-r NAME] [--json]
sow repo migrate [NAME] [--abort] [-j N] [-C DIR] [-r NAME] [-T DUR | -N] [--json] [--passfile PATH]
sow repo rm NAME [-f|--force] [-C DIR] [-T DUR | -N] [--json] [--passfile PATH]

repo new, repo migrate, and repo rm accept --passfile for signing checks, signing, or recovery of an interrupted operation. repo ls and repo show do not read password files.

Examples

Create the repositories for a two-tier layout:

sow repo new infra
sow repo new pgsql

Create a repository without waiting for a held lock:

sow repo new nightly -N

Print each repository’s name, state, and Generation:

sow repo ls --json | jq -r '.result.repositories[] | "\(.name)\t\(.status)\tgen=\(.generation)"'

Naming

A repository name must match [a-z0-9][a-z0-9._-]*. It may not be ., .., .sow, pool, or dists, or collide with a reserved workspace file. SOW creates the repository at <workspace>/<NAME>/.

sow repo new .sow
operation rejected: managed: operation rejected: name ".sow" must match [a-z0-9][a-z0-9._-]*

sow repo ls

Lists every repository in the workspace. Read-only.

sow repo ls
NAME	PROTECTED	DISTS	GENERATION	STATUS	PACKAGES	MEMBERSHIPS
infra	true	1	1	clean	0	0
pgsql	false	2	2	clean	0	0
Flag Description Default
-C, --workdir DIR Workspace discovery start directory current directory
--json Output JSON false

STATUS is clean, dirty, recovering, or error. Transactions & Recovery explains what each means for clients.

sow repo new

Adds the repository to sow.yml, then creates <workspace>/<NAME>/{pool,dists}, its SQLite database, and its private state. A new repository starts at Generation 0, clean.

sow repo new pigsty
created pigsty: path=/srv/repo/pigsty protected=false dists=0 generation=0 status=clean packages=0 memberships=0
Flag Description Default
-C, --workdir DIR Workspace discovery start directory current directory
-T, --timeout DUR Maximum lock wait; 0 waits indefinitely 0
-N, --no-wait Fail immediately when the lock is held false
--passfile PATH Password file for this invocation per-key config, then SOW_GPG_PASSFILE
--json Output JSON false

Running it again for an existing repository prints the current state and creates nothing.

sow repo show

Shows one repository in detail. Read-only. Without NAME, the usual repository selection applies.

sow repo show pigsty
repository pigsty:
  path: /srv/repo/pigsty
  protected: false
  dists: 2
  generation: 6
  desired_revision: 6
  status: clean
  packages: 5
  memberships: 8
  config: {"protected":false,"signing":{"rpm":{"packages":{"mode":"never"}}},"dists":{"el9":{"format":"rpm","architectures":["x86_64","aarch64"],"limit":1,"exclude":[{"kind":["debuginfo","debugsource"]}]},"trixie":{"format":"deb","architectures":["x86_64","aarch64"],"limit":0,"exclude":null}}}
  dirty_reasons: []
  recent_operation: id=4142220455201181493 kind=add state=done error_class= created_at=2026-08-04T04:09:24.995538Z updated_at=2026-08-04T04:09:25.332772Z
Flag Description Default
-C, --workdir DIR Workspace discovery start directory current directory
-r, --repo NAME Select the repository when NAME is omitted selection rules
--json Output JSON false

If you pass both NAME and -r, they must name the same repository:

sow repo show demo -r empty
operation rejected: repo show NAME "demo" and --repo "empty" select different repositories

sow repo rm

Removes a repository completely: its sow.yml entry, database, package files in pool/, indexes in dists/, and private state. Without -f, only an empty repository can be removed, one with no Dists, no memberships, and no package objects:

sow repo rm infra
removed repository infra
sow repo rm pgsql
operation rejected: managed: operation rejected: repository "pgsql" is not empty; use --force

sow repo rm pgsql -f
removed repository pgsql
Flag Description Default
-f, --force Remove a non-empty unprotected repository false
-C, --workdir DIR Workspace discovery start directory current directory
-T, --timeout DUR Maximum lock wait; 0 waits indefinitely 0
-N, --no-wait Fail immediately when the lock is held false
--passfile PATH Password file for this invocation per-key config, then SOW_GPG_PASSFILE
--json Output JSON false

Force removal

-f lifts only the emptiness check. It does not override protected.

protected

protected: true in sow.yml blocks repository deletion outright, -f included:

sow repo rm alpha -f
operation rejected: managed: operation rejected: repository "alpha" is protected

To remove a protected repository, set protected: false in sow.yml, run sow config check, and retry. Protection covers repository deletion only; add, rm, build, and dist rm keep working:

sow dist rm el9 -r alpha -f
removed dist el9 from alpha

sow repo migrate

repo migrate brings a repository’s database and layout up to the current schema (v13) and resumes or abandons an unfinished layout transition. Only workspaces from early releases need it; the upgrade guide says which. In 0.9.0, sow status can inspect schema v12 and returns 5 for v8 or v10. sow build exits 6 and requests migration on all three. See Troubleshooting after an upgrade.

  1. Stop all workspace writers.
  2. Back up the whole workspace, preserving hard links.
  3. Migrate each configured repository.
  4. Run build and check for each repository.
rsync -aH /srv/sow/ /srv/sow.backup-before-0.9.0/
sow repo migrate pigsty -C /srv/sow
sow build -r pigsty -C /srv/sow
sow check -r pigsty -C /srv/sow

Repeat the last three commands for each repository. The result reports the layout and schema before and after (schema_from and schema_to in JSON); on a repository that is already current it is a no-op:

sow repo migrate pigsty -C /srv/sow
migrated repository pigsty: single-payload-v1 -> single-payload-v1 schema=13->13 generation=00000000000000000007 phase=done complete=true

Migration also applies the state and publication repairs that older layouts need. After a C2 layout migration, SOW binds the migration anchor to the newly migrated Generation, so later build, add, check, gc, and repo rm commands do not report an anchor mismatch. To return to a release that uses an older schema, restore the backup.

If a completed migration leaves stage files whose ownership SOW cannot prove, it keeps them under .sow/<repo>/abandoned/ and reports the path. Rerun sow repo migrate NAME to clear that state and unblock local GC, and inspect the retained files before you delete them.

Flag Description Default
-j, --jobs N Parallel verification/render workers logical CPUs
--abort Abandon a maintenance attempt before its commit decision false
-C, --workdir DIR Workspace discovery start directory current directory
-r, --repo NAME Select the repository when NAME is omitted selection rules
-T, --timeout DUR Maximum lock wait; 0 waits indefinitely 0
-N, --no-wait Fail immediately when the lock is held false
--passfile PATH Password file for this invocation per-key config, then SOW_GPG_PASSFILE
--json Output JSON false

Abandon a transition with –abort

--abort abandons an unfinished layout plan before its commit decision; once commit intent is recorded, only forward recovery is possible. It never undoes a completed schema migration, and the public tree stays unchanged. Without a resumable transition it fails with exit 6.

  • For an earlier C2 transition, SOW checks the repository identity and the journal and database control records that exist. Conflicting records stop the abort, and a journal-bound plan also needs its recorded base manifest.
  • An abort can complete before the first journal or base manifest was written, as long as the trusted transition marker exists. SOW keeps that marker so a later sow repo migrate NAME can plan and resume the transition.
  • A non-empty temporary stage is moved intact into .sow/<repo>/abandoned/. Retained paths and cleanup problems are printed to stderr and listed in JSON warnings; a cleanup warning does not prevent the abort. Inspect the reported paths before removing anything.

A fresh development-era C2 repository cannot start a migration. If a previous abort removed the trusted marker, restore a complete matching backup or import the original packages into a new workspace.

Exit codes

Code Trigger
0 Listed, created, shown, migrated, abandoned a pre-commit transition, or removed; or repo new reported an existing repository
1 Runtime I/O error creating or removing the tree
2 Usage error (including -r on repo ls, repo new, or repo rm), workspace not found, or an ambiguous repository selection
4 Workspace lock held and --no-wait given or --timeout expired
5 Integrity or recovery error in the workspace journal
6 Invalid or reserved name, unknown repository, non-empty without -f, protected, NAME conflicting with -r, migration required before a write, or --abort with nothing to abandon

See also

Table reader