Skip to content

sow create

Generate RPM and DEB indexes beside package files.

sow create writes RPM and DEB indexes beside the package files in a directory. Use it for a flat repository that does not need a managed Workspace. DIR defaults to the current directory.

Synopsis

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

--passfile PATH requires --sign-with; SOW_GPG_PASSFILE supplies a default password-file path but does not enable signing by itself. Use one nonempty line: SOW strips an optional UTF-8 BOM and one final LF or CRLF without trimming whitespace. Regular files, symlinks, and named pipes (2-second writer deadline) are supported. Relative paths start at the current directory, and SOW searches no default location. See Password files.

sow create replaces an existing repomd.xml. SOW does not carry independent metadata such as groups (comps), updateinfo, or modules into the new index. From SOW 0.7.0, create reports those data types as a warning on standard error in human output, or in the dropped_metadata result field with --json. It does not report alternate package-index encodings (*_db, *_zck). 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 rejects such an index instead.

Type reporting requires a readable, valid prior index within the 16 MiB inspection limit. Create can still replace an oversized or malformed index without listing its data types; prune rejects an oversized prior index.

Use sow prune to keep only the latest version per package name and architecture in a flat RPM repository.

Description

create reads the top-level regular package files in DIR. For RPMs, it generates repodata/. For DEBs, it generates Packages and Packages.gz. A mixed directory gets both formats. Architectures come from the package headers; Plain mode accepts all architectures found in the packages.

Indexes use relative package paths: the filename for RPM, and ./<filename> for DEB. Serve the package directory through HTTP or use it as a local file:// source.

By default, create updates its indexes and preserves the package files. --pigsty can delete matching packages, and --sign-with can replace RPMs with signed copies.

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 —

Scan rules

  • SOW considers only top-level regular files ending in .rpm or .deb.
  • No recursion, no symlink following, no Workspace config. create rejects running inside a managed .sow workspace ancestor.
  • By default, corrupt or unreadable packages, source RPMs (src/nosrc), and coordinate conflicts (including Debian version-equivalent conflicts such as 1.0-1 vs 1.00-1) are skipped with a warning so remaining valid packages still enter the index. With --pigsty, exclusion filtering runs before duplicate-filename checks.
  • If every candidate of one format fails, SOW preserves that format’s previous index, history, and completion state while still publishing valid packages of the other format (including in fresh --pigsty directories).
  • Human output prints warnings to stderr. Successful --json output includes warnings and skipped in the stdout envelope and leaves stderr empty.
  • Pass --strict to fail before writing on any skipped package, coordinate conflict, or empty directory (without --pigsty).
sow create /srv/empty --strict
plain: scan /srv/empty: no supported top-level regular RPM or DEB packages

Package I/O and final validation

Keep the input directory unchanged while create runs. SOW scans the packages, then checks for file changes before replacing the indexes. A detected change returns exit code 5. Use --jobs to set the number of parallel package-processing workers.

Deterministic output and idempotence

Without forced package re-signing, the rendered metadata is byte-stable for a given input set and timestamp: gzip output is deterministic. repomd.xml carries <revision>0</revision> and data timestamps defaulting to 0; --metadata-timestamp overrides the latter. Repeating the same options on an unchanged directory rewrites nothing and reports noop=true:

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

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

Keep the previous RPM indexes

SOW keeps the checksum-named RPM metadata referenced by the current and immediately previous repomd.xml. A client that fetched the previous index can still retrieve those metadata files after an update. An unchanged run does not advance this retention window.

The hidden .sow-plain-rpm-history.json file records these references. Keep it with the directory when rebuilding a working copy. It is a retention record, not a recovery journal. Plain mode still recovers by rebuilding.

This window does not retain removed package files or every older index. If client caches span several updates, keep the required packages and metadata in your publication layer.

The repo_complete gate

If the directory contains repo_complete (or an interrupted .sow-prune-repo-complete marker left by sow prune), use --pigsty to refresh it with the indexes. Running without --pigsty returns an error:

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

To keep using the completion marker, rerun with --pigsty. If you no longer use it, move the marker out of the directory first.

Publication time for existing YUM repositories

--metadata-timestamp sets the RPM repomd data timestamps. It does not change package files, compressed XML streams, or DEB indexes. The default is 0, and the accepted range is 0..253402300799 Unix seconds. This option was added in SOW 0.5.0.

EL7 YUM rejects metadata whose maximum data timestamp is older than its cached copy. When replacing an existing metadata generator, choose a timestamp at least as large as the highest value previously published. For changed content, advance it by at least one second to distinguish updates.

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

Record the publication time and pass it on every update. Omitting the option resets it to 0. Restoring older package content is a new publication, so keep the timestamp increasing. Use seconds, not milliseconds, and avoid future dates.

If clients verify repomd.xml.asc, regenerate that signature after repomd changes. create neither signs repomd nor updates or removes its old detached signature.

See Migrating an Existing YUM Repository for the complete procedure.

–pigsty

--pigsty applies these 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. After all indexes render successfully, write repo_complete: the SHA-256 of every remaining top-level RPM/DEB, sorted by basename byte order, formatted <sha256><two spaces><basename>.
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 applies only to top-level regular package files that parsed successfully and matched a rule.

SOW retains documentation packages such as annobin-docs unless they match one of those rules.

SOW removes the existing repo_complete before replacing indexes. It then deletes the packages matched by the cleanup rules and writes the new marker last. A missing marker means the build is incomplete.

Signing RPMs

-S/--sign-with KEY signs RPM package files through the local RPM/GPG environment. Use a 16-digit hexadecimal key ID or a 40- or 64-digit fingerprint. An optional 0x or 0X prefix is accepted. Make the private key available in that environment before running the command. For a protected key, use --passfile PATH or set SOW_GPG_PASSFILE to its password-file path.

  • Default: SOW signs only RPMs that have 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 requires --sign-with and switches to rpm --resign over every retained RPM.
  • SOW signs a temporary copy, cryptographically verifies the resulting OpenPGP signature (supporting both RPM v4 and RPM v6 tag 278, including multi-signed RPMs) and checks that package identity and content are unchanged, then replaces the original RPM. The indexes describe the final signed file.
  • At least one top-level RPM must remain after --pigsty cleanup, and rpm must be on PATH.
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
plain: sign rpm: --sign-with requires at least one retained top-level RPM package
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

Locking, staging and overwrite rebuild

create locks the target directory while it updates the indexes and releases the parent directory lock immediately after binding (and before waiting on a busy target), so concurrent runs on sibling flat directories do not block each other. Use --timeout or --no-wait to control lock waiting.

An interruption can leave only part of the index set updated. Rerun sow create with the same intended options to rebuild from the current packages. Plain mode rebuilds from scratch; the result field recovered remains false.

For --pigsty, expose the repository only after repo_complete appears. Use Managed mode when you need journaled recovery.

Examples

Index a mixed directory:

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

Machine-readable result:

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":[]}

Build a Pigsty flat 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}"

The caller records this time and signs the resulting repomd.xml when clients require it.

Failure envelope:

sow create /srv/empty --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 regular RPM or DEB packages"}]}

Exit codes

Code Trigger
0 Indexes written, or unchanged input produced a no-op
1 Directory unreadable or missing, package parse failure, renderer failure, signing tool failure, or a missing/unreadable/malformed password file when signing needs it
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 Managed .sow workspace ancestor, repo_complete / .sow-prune-repo-complete gate hit, --sign-with on a DEB-only directory, or under --strict: empty directory, skipped package, or coordinate conflict

See also

Table reader