Skip to content

sow create

Turn a directory of RPM and DEB files into a YUM/APT repository: options, scan rules, Pigsty cleanup, RPM signing, and exit codes.

sow create writes YUM and APT indexes next to the packages in one directory, which turns that directory into a simple repository that dnf and apt can install from directly. Reach for it when the directory itself is the repository: an offline bundle, a mirror you fill by other means, or a replacement for a createrepo_c script. It indexes every valid version it finds and keeps no build history; use sow prune to drop superseded RPMs, and a standard repository when you need several Dists, version limits, build history, or publication.

Synopsis

sow create [DIR] [-j N] [--metadata-timestamp SECONDS] [--pigsty] [--strict] [-S KEY [--overwrite] [--passfile PATH]] [-T DUR | -N] [--json]

DIR defaults to the current directory. --passfile requires --sign-with, and SOW_GPG_PASSFILE alone does not turn signing on; see Password files for the file format.

Options

Flag Description Default
-j, --jobs N Parallel package-processing workers logical CPU count
--metadata-timestamp SECONDS Unix seconds from 0 to 253402300799 for RPM repomd data timestamps; leaves DEB, package times and gzip headers unchanged 0
--pigsty Enable Pigsty cleanup and the repo_complete gate off
--strict Fail non-zero on corrupt, unreadable, source, or conflicting packages (or empty non-Pigsty directory) instead of skipping with a warning off
-S, --sign-with KEY Sign unsigned RPMs with a GPG key ID or fingerprint off
--passfile PATH Password file for --sign-with SOW_GPG_PASSFILE, then existing RPM/GPG behavior
--overwrite Re-sign every RPM; requires --sign-with off
-T, --timeout DUR Maximum lock wait; 0 waits indefinitely 0
-N, --no-wait Fail immediately when the lock is held false
--json Output JSON false
-h, --help Show help —

Examples

Index a directory that holds both RPMs and DEBs:

sow create /srv/flat
created /srv/flat: rpm=3 deb=1 signed=0 removed=0 marker=false noop=false recovered=false
ls /srv/flat
centos-release-6-0.el6.centos.5.x86_64.rpm
centos-release-7-2.1511.el7.centos.2.10.x86_64.rpm
epel-release-7-5.noarch.rpm
libpq5_18.3-1_amd64.deb
Packages
Packages.gz
repodata

Run it again whenever packages change. On an unchanged directory it writes nothing:

sow create /srv/flat
created /srv/flat: rpm=3 deb=1 signed=0 removed=0 marker=false noop=true recovered=false

The same result for a script:

sow create /srv/flat --json
{"schema":"sow.cli/v1","command":"create","ok":true,"repository":null,"operation":null,"result":{"dir":"/srv/flat","rpm":3,"deb":1,"kept":["centos-release-6-0.el6.centos.5.x86_64.rpm","centos-release-7-2.1511.el7.centos.2.10.x86_64.rpm","epel-release-7-5.noarch.rpm","libpq5_18.3-1_amd64.deb"],"removed":[],"marker":false,"noop":true,"recovered":false},"errors":[]}

Rebuild a Pigsty offline repository with eight workers and a publication time chosen from its history:

sow create /www/pigsty -j 8 --pigsty --metadata-timestamp "${PUBLISH_TIME:?Set the verified publication time}"

You record PUBLISH_TIME yourself, and sign the resulting repomd.xml if clients require it; see Publication time.

Inputs and outputs

create reads only the top level of DIR: entries ending in .rpm or .deb whose target is a regular file. A symlink to a package file counts; subdirectories and sow.yml are ignored, and create refuses to run inside a workspace. Format and architecture come from each package header, and every architecture found is indexed.

Packages found Indexes written
RPM repodata/
DEB Packages and Packages.gz
Both Both sets

Indexes refer to packages by relative path, the file name for RPM and ./<filename> for DEB, so the directory can be served over HTTP as is or used as a file:// source. The DEB side is a flat APT repository, with no dists/ hierarchy and no Release file, so APT clients list it as deb [trusted=yes] URL ./. Package files stay untouched, except that --pigsty deletes matching packages and --sign-with replaces RPMs with signed copies.

By default, create warns and skips corrupt or unreadable packages and source RPMs (src and nosrc). The --pigsty cleanup rules run before the package coordinate check.

For a given package name, architecture, and version, the index uses the first valid file in basename order. Debian versions 1.0-1 and 1.00-1, for example, compare equal. A subsequent file with a different SHA-256 is skipped with a warning. Byte-identical copies both appear in kept and, with --pigsty, in the completion marker. They share one index entry.

If all candidates of one format fail, SOW keeps that format’s previous index and can still publish the other format. In --pigsty mode, keeping an existing index also requires its entries in the previous repo_complete. If SOW cannot carry them forward, it warns and skips the whole update. A fresh directory has no old index to preserve.

Removing the last package of a format has a different effect. On the next build SOW removes that format’s generated indexes. A fresh empty directory produces only a warning by default. With --pigsty, an empty directory gets an empty repo_complete.

Text output sends warnings to stderr. A successful --json run reports diagnostics on stdout. It includes result.warnings when there are warnings and result.skipped when files were skipped.

Pass --strict to make any skipped package, coordinate conflict, or empty directory (without --pigsty) fail before anything is written. A corrupt or unreadable package then exits 1; a source RPM, a coordinate conflict, or an empty directory exits 6:

sow create /srv/empty --strict
plain: scan /srv/empty: no supported top-level RPM or DEB packages

Deterministic output and idempotence

For the same packages and timestamp, create renders byte-identical metadata, unless --overwrite re-signs the packages. Gzip output is deterministic, and repomd.xml carries <revision>0</revision> and data timestamps of 0 unless --metadata-timestamp sets them. That is why a repeated run on an unchanged directory rewrites nothing and reports noop=true.

Keep the previous RPM indexes

A client that fetched repomd.xml just before an update still needs the checksum-named metadata files it points to. SOW therefore keeps the RPM metadata referenced by the current and the immediately previous repomd.xml; an unchanged run does not advance this window. The hidden file .sow-plain-rpm-history.json records those references, so keep it with the directory when you copy it elsewhere and rebuild. It is a retention record, not a recovery journal.

The window covers one previous index only, and it never keeps removed package files. If client caches span several updates, keep the packages and metadata they need in your publication layer.

Publication time for existing YUM repositories

--metadata-timestamp sets the data timestamps in repomd.xml, and nothing else: package files, compressed XML, and DEB indexes are unchanged. The default is 0; the accepted range is 0..253402300799 Unix seconds.

The value matters when SOW takes over an existing YUM repository, because EL7 YUM rejects metadata whose newest data timestamp is older than its cached copy. Choose a timestamp at least as high as the highest value already published, and advance it by at least one second whenever content changes:

sow create /srv/flat --metadata-timestamp "${PUBLISH_TIME:?Set the publication time}"

Record the time and pass it on every update; omitting the option resets it to 0. Restoring older package content is still a new publication, so keep the value increasing. Use seconds, not milliseconds, and no future dates. create neither signs repomd.xml nor updates or removes an old repomd.xml.asc; if clients verify that signature, regenerate it after each change. Migrate an Existing YUM Repository walks through the full procedure.

Signing RPMs

-S/--sign-with KEY signs RPMs through the local RPM/GPG setup. KEY is a 16-hex-digit key ID or a 40- or 64-hex-digit fingerprint, optionally prefixed with 0x or 0X. rpm and gpg must be on PATH and the private key must be available to them; for a protected key, pass --passfile PATH or set SOW_GPG_PASSFILE.

  • By default SOW signs only RPMs with no parseable embedded OpenPGP signature (native RPM 6 RPMSIGTAG_OPENPGP tag 278, RSA/DSA/ECDSA/EdDSA in signature header tag 267, or legacy PGP tags). Packages that are already signed keep their bytes.
  • --overwrite re-signs every retained RPM with rpm --resign. It requires --sign-with.
  • SOW signs a private copy, verifies the new OpenPGP signature cryptographically (RPM v4, and RPM v6 tag 278 including multi-signed packages), checks that package identity and content are unchanged, and only then replaces the original. The indexes describe the final signed file.
  • An RPM that needs signing but is a symlink or not a regular file is rejected rather than signed in place.
  • If no RPM remains after --pigsty cleanup, --sign-with only prints a warning; with --strict it fails.
sow create /srv/flat --overwrite
usage error: --overwrite requires --sign-with

sow create /srv/flat -S ZZZZ
usage error: --sign-with must be a 16, 40, or 64 hexadecimal GPG key ID/fingerprint

sow create /srv/flat -S 0123456789ABCDEF --overwrite
plain: sign rpm epel-release-7-5.noarch.rpm: rpm executable is required for --sign-with

sow create /srv/deb-only -S 0123456789ABCDEF --strict
plain: sign rpm: --sign-with requires at least one retained top-level RPM package

–pigsty

--pigsty applies Pigsty’s cleanup rules and writes a completion marker:

  1. Delete DEB packages whose parsed architecture is i386. RPMs are not removed merely for carrying an i386/i486/i586/i686 architecture.
  2. Delete RPM/DEB whose binary package name is exactly patroni and whose upstream version is exactly 3.0.4. RPM compares VERSION, ignoring epoch and release; DEB strips epoch and Debian revision first. 3.0.4+foo is not a match.
  3. Write repo_complete with the SHA-256 of each retained package, sorted by basename in byte order, in the form <sha256><two spaces><basename>. Newly skipped inputs stay on disk and have no new entry. When SOW preserves a format’s old index it carries its previous marker entries forward.
sow create /srv/pigsty --pigsty
created /srv/pigsty: rpm=2 deb=0 signed=0 removed=2 marker=true noop=false recovered=false
cat /srv/pigsty/repo_complete
b4111ef2a51542eacc9bd1ebd080da02e53d400f9d172530c75a1e4ac06e7ead  centos-release-7-2.1511.el7.centos.2.10.x86_64.rpm
d6f332ed157de1d42058ec785b392a1cc4b5836c27830af8fbf083cce29ef0ab  epel-release-7-5.noarch.rpm

Cleanup touches only top-level regular package files that parsed successfully and match a rule; documentation packages such as annobin-docs stay unless they match one. SOW removes the old repo_complete before replacing the indexes, deletes the matched packages, and writes the new marker last. A missing marker therefore means the build is not finished: expose the repository only after repo_complete appears.

The repo_complete gate

A directory that contains repo_complete, or the .sow-prune-repo-complete marker that an interrupted sow prune leaves behind, belongs to the Pigsty workflow. Without --pigsty, create refuses to rebuild it, because the marker would then describe an older package set:

sow create /srv/pigsty
plain: marker gate /srv/pigsty/repo_complete: repo_complete exists; use --pigsty or remove it explicitly before rebuilding

Rerun with --pigsty to keep using the marker, or move the marker out of the directory first.

Metadata from other tools

create replaces an existing repomd.xml, and it does not carry over independent metadata that SOW does not generate, such as groups (comps), updateinfo, or modules. It reports the dropped data types as a warning on stderr, or in the dropped_metadata result field with --json. Alternate package-index encodings (*_db, *_zck) are dropped without a report. This keeps existing repositories rebuildable, including EL8/9 repositories that Pigsty v4.4.0 built with legacy module metadata. If clients still need the dropped records, keep maintaining that repository with the tool that produced them; sow prune refuses such an index instead.

Listing the dropped types requires a readable, valid previous index of at most 16 MiB. create still replaces a larger or malformed index, only without the list.

Locking and interrupted runs

create locks the target directory while it updates the indexes. It releases the parent directory’s lock as soon as it has bound the target, before waiting on a busy one, so runs on sibling directories do not block each other. --timeout and --no-wait control the wait.

Keep the directory unchanged while create runs. After scanning, SOW checks the packages again before it replaces the indexes and stops with exit 5 if anything changed.

An interruption can leave the index set partly updated. Rerun sow create with the same options: a simple repository is always rebuilt from its current packages, so the result field recovered stays false. Use a standard repository when you need journaled recovery.

Exit codes

Code Trigger
0 Indexes written, or unchanged input produced a no-op
1 Directory unreadable or missing, renderer failure, signing tool failure (including missing rpm or gpg), a missing/unreadable/malformed password file when signing needs it, or under --strict: a corrupt or unreadable package (including a broken symlink)
2 Usage error — invalid timestamp, --overwrite or --passfile without --sign-with, invalid/empty --passfile, malformed key, --no-wait with a non-zero --timeout
4 Directory write lock held and --no-wait given or --timeout expired
5 Input set/stat changed before publication, or a controlled output path failed an integrity check
6 Directory inside a workspace (a .sow ancestor), repo_complete / .sow-prune-repo-complete gate hit, symlinked or non-regular RPM that needs signing, or under --strict: empty directory, source RPM, coordinate conflict, or --sign-with with no retained RPM

A failed run with --json still prints the envelope, with ok false and the error class:

sow create /srv/empty --strict --json
{"schema":"sow.cli/v1","command":"create","ok":false,"repository":null,"operation":null,"result":null,"errors":[{"code":6,"class":"rejected","message":"operation rejected: plain: scan /srv/empty: no supported top-level RPM or DEB packages"}]}

See also

Table reader