Simple Repositories
Often the packages already exist in a directory: the output of a CI job, an offline bundle
for hosts without Internet access, or a repository that createrepo_c has maintained for
years. What you need is for dnf and apt to install from it, without adopting a
configuration file, a database, or a new directory layout.
A simple repository gives you exactly that. It is a directory of RPM and DEB files that
sow create indexes in place: SOW reads each package once, writes YUM and APT indexes beside the
packages, and keeps no other state, so the directory is the whole repository. Because the
indexes depend only on the package bytes and the options you pass, running the command
again is always the right move. On an unchanged directory it changes nothing; after you add
or remove files it brings the indexes up to date; after an interruption it rebuilds whatever
was left incomplete. Core concepts compares it with
a standard repository.
Create and update
Point sow create at the directory:
The directory now has repodata/ for its RPMs and Packages and Packages.gz for its DEBs,
next to the package files. Serve it over HTTP or use it as a local file:// source.
To update the repository, change the files and run the same command again. If nothing
changed, the new indexes are byte-for-byte identical to the old ones, so SOW leaves the
existing files in place and reports noop=true:
That determinism is deliberate. By default the indexes carry no build time (repomd.xml
uses revision 0 and data timestamp 0) and gzip output is reproducible, so a rerun with
nothing new gives rsync, mirrors, and CDN caches nothing to transfer.
Each package is read once: the same pass computes the SHA-256 recorded in the index and
parses the package header. --jobs sets the number of parallel workers and defaults to the
logical CPU count. Before replacing any index, SOW checks the package list, file identity,
mode, size, and modification time again. If another program changed a package during the
build, the command stops with exit code 5 and replaces nothing, so keep other writers out
of the directory while sow create runs.
Prune superseded RPMs
A directory that receives every CI build keeps every version, and sow create indexes all
of them. sow prune keeps only the highest version of each RPM
name and architecture, and deletes the rest. Preview first:
Versions compare by RPM’s own rules (epoch, version, release, including ~ pre-releases
and ^ snapshots), for both RPM v4 and v6 packages. --protect NAME keeps every version of
an exact package name. In a mixed directory, prune touches only RPMs and leaves the DEB index
as it is.
prune publishes an index that names the retained packages, then removes superseded files. Clients with the previous index may still request those files. For a live repository, prune the publication source and keep old files on the server until client caches expire.
Prune is stricter than create about what it accepts: a live run refuses a signed
repodata/ or a repomd.xml that registers metadata SOW does not generate, such as group.
See Supported repositories.
Inputs and outputs
SOW reads only top-level files whose names end in .rpm or .deb; a symlink to a package
file counts. It does not descend into subdirectories, and it takes each package’s name, version,
and architecture from the package header, not from the file name. Every valid version is
indexed; use sow prune to keep only the newest.
| Input | Generated files |
|---|---|
| RPM | repodata/repomd.xml and gzip-compressed primary, filelists, and other XML |
| DEB | Packages and Packages.gz |
| Both formats | Both sets of indexes |
Index entries point at packages by relative path: an RPM location is the bare file name and
a DEB Filename is ./<file name>. The directory therefore works at any URL, as long as
indexes and packages stay together. A YUM baseurl names the directory itself; on the APT
side it is a flat APT repository with no dists/ hierarchy, so the source line has the form
deb URL ./.
When the last package of a format leaves the directory, SOW deletes that format’s indexes.
Without options, sow create never touches package files or unrelated files; only --pigsty
deletes packages and only --sign-with replaces RPMs. Generated directories get mode 0755 and
generated files 0644.
Publication time for EL7 clients
The zero timestamp that makes output reproducible matters in one case. EL7 YUM rejects metadata whose data timestamp is older than the copy in its cache. When SOW takes over a repository that EL7 clients have already cached with a positive timestamp, pass a publication time in Unix seconds that is at least the last published value, and advance it with every changed update:
The value changes only repomd.xml; the compressed XML, the package files, and the DEB
indexes stay the same. Pass it on every later run, because omitting it resets the timestamp
to 0. Migrate an existing YUM repository shows how to
choose the starting value.
Pigsty cleanup and completion marker
--pigsty builds the simple repositories that Pigsty uses. It adds a fixed cleanup and a
completion marker that consumers can wait for:
- Cleanup deletes DEB packages whose parsed architecture is
i386, and RPM or DEB packages named exactlypatroniat upstream version exactly3.0.4. An RPM is never removed just for beingi386throughi686, and documentation packages such asannobin-docsstay unless a rule matches them. - Marker: after the indexes are in place, SOW writes
repo_complete, one line per retained package in the form<sha256> <file name>(two spaces), sorted by file name.
SOW deletes the old marker before it replaces any public file and writes the new one last.
A directory without repo_complete is therefore incomplete: consumers should wait for the
marker, and the operator should rerun the same --pigsty command. Once a directory has a
marker, sow create without --pigsty refuses to rebuild it (exit 6), so an ordinary run
cannot silently drop the marker. To stop using it, move the marker out of the directory first.
RPM package signing
Packages built in CI are often unsigned, and clients with gpgcheck=1 refuse them.
--sign-with KEY signs them as part of the build:
By default SOW signs only RPMs that have no parseable embedded signature, so packages signed
upstream keep their bytes; add --overwrite to re-sign every retained RPM. Signing needs the
host rpm command and the private key in the local GPG environment. SOW signs a temporary
copy, verifies the new signature and that the package identity and content are unchanged,
then replaces the original before it writes the indexes, so the index always describes the
signed file. This path reads package bytes more than once.
For a protected key, pass --passfile PATH or set SOW_GPG_PASSFILE; neither enables
signing without --sign-with. See Password files for
the file format.
A simple repository has no metadata signing, and sow create leaves an existing
repodata/repomd.xml.asc untouched. If clients verify that signature, sign the new
repomd.xml yourself after each run. For signed metadata and a package-signing policy, use
a standard repository; see Signing model.
Interrupted builds
SOW renders and checks every index in a staging directory before it touches public files, but it then replaces those files one by one, not in a single transaction across all RPM and DEB indexes. An interruption can leave the indexes mixed or incomplete.
Recovery is the same command: rerun it, and SOW removes its stale temporary files and
rebuilds from the packages currently in the directory. There is no journal, so the
recovered result field is always false. If clients read the directory while you
rebuild, build in a separate directory and switch the finished directory into service. When
you need journaled recovery, recorded membership, and build history, use a
standard repository.
Details
Skipped packages and --strict
By default sow create skips, with a warning, any file it cannot index: corrupt or
unreadable packages, source RPMs (src and nosrc), and coordinate conflicts, including
Debian versions that compare equal, such as 1.0-1 and 1.00-1. The remaining packages are
still indexed. Pass --strict to fail before writing anything instead.
- If every candidate of one format fails,
createpreserves its old index. A--pigstyupdate can proceed with the other format if there is no old index to preserve or its marker entries can be carried forward. Otherwise SOW warns and skips the update. - Removing all packages of a format clears its generated indexes on the next ordinary build. A fresh empty directory produces a warning by default and fails under
--strictunless--pigstyis set. - Text output prints warnings to stderr. A successful
--jsonrun reports diagnostics on stdout, with optionalresult.warningsandresult.skippedfields.
Existing repomd.xml and dropped metadata
sow create replaces an existing repomd.xml, so metadata that SOW does not generate, such
as group (comps), updateinfo, or modules, is dropped from the index. SOW names the
dropped types in a stderr warning, or in the dropped_metadata field with --json. Files SOW
did not generate, including an external repomd.xml.asc, stay on disk and must be refreshed
separately. See sow create before taking over such a repository.
RPM index history
SOW keeps the checksum-named RPM metadata of the current and the immediately previous
repomd.xml, so a client that fetched the previous index can still download its metadata
files after an update; older SOW-generated metadata is deleted. The hidden
.sow-plain-rpm-history.json file records the two sets, so keep it with the directory when
you copy it for further builds. Package files are not retained: keeping old packages for
clients with older cached indexes is up to you. See
Keep the previous RPM indexes.
When sow create refuses to run
Both cases exit with code 6:
- The directory is inside a workspace, that is, it or an ancestor holds
.sow/together withsow.ymlorsow.yaml. - The directory contains
repo_complete, or the.sow-prune-repo-completemarker that an interruptedsow pruneleaves, and--pigstyis not set.
Concurrent commands
sow create and sow prune lock the target directory and hold the parent’s lock only
while binding the target, so runs on sibling directories do not block each other. A second
command on the same directory waits for the lock by default; -N fails at once and -T 30s
waits at most 30 seconds, both with exit code 4.
Every option, result field, and exit code is listed in sow create
and sow prune.