Skip to content

This is the multi-page printable view of this section.

Return to the regular view of this page

Tutorials

Find the walkthrough for your situation: a new YUM or APT repository, a createrepo_c migration, signing, serving, or a multi-channel repository.

Each tutorial is a complete procedure. It starts from package files or an existing repository and ends with a client installing a package from the result. Pick the one that matches what you have and what you need. If SOW is not installed yet, start with Installation.

SOW builds two kinds of repository; Core concepts compares them. A simple repository is a directory of packages that sow create indexes in place. A standard repository lives in a workspace, where SOW maintains its package pool, Dists, recorded builds, and publication. The migration tutorial uses a simple repository; the others build standard repositories.

Which tutorial do I need

Your situation Tutorial
You have RPMs and want a repository that dnf hosts install from and that you keep updating Build a YUM repository
You have DEBs and want the same for apt hosts Build an APT repository
A createrepo_c script maintains your RPM repository, and SOW should take over without breaking clients that cached the old index Migrate an existing YUM repository
Clients must reject indexes or packages that you did not sign Sign your repository
A web server, object storage, or an offline network must receive the repository Serve and publish
You ship both formats for two architectures and need latest, stable, and monthly snapshot channels Build the pigsty-infra repository

If you are new to SOW

Follow this order. Each step assumes what the one before it taught, and the first two take a few minutes:

  1. Quick start: turn a directory of packages into a simple repository.
  2. Your first standard repository: a workspace, a shared package pool, and Dists.
  3. YUM or APT: membership policy, updates, and a real client.
  4. Signing, then serving: what you need before other hosts depend on the repository.
  5. pigsty-infra: a production-shaped repository with several channels.

The migration tutorial stands apart: it needs no workspace.

Follow the examples

Run commands in order. Replace uppercase placeholders and /path/to/ inputs with your own values. Examples under /srv need a directory your user can write to; a path under your home directory works as well.

A Dist is a named package set in a standard repository. Names such as el9, trixie, or rpm are labels you choose: a Dist name becomes the index directory under dists/ and, for APT, the Suites value clients configure. It does not change which operating systems the packages are built for.

The YUM and APT tutorials each start a new workspace. To keep both formats in one repository, create the second Dist in the existing pigsty repository instead of running sow init again, and merge its policy into sow.yml so both Dist definitions remain.

Each tutorial ends with a check that proves the result. For a command error or an interrupted operation, see Troubleshooting.

1 - Build a YUM Repository

Build a standard YUM repository with a version policy, install from it with dnf, and keep it updated.

You build or collect RPMs for EL hosts and want dnf install to work against your own repository, today and after every later update. This tutorial builds a YUM standard repository, which SOW maintains in a workspace: one package set, el9, with x86_64 and aarch64 indexes that share a single package pool, a policy that keeps only the newest version and drops debug packages, and a dnf client that installs from it.

You need:

  • SOW 0.9.0 (Installation) and Python 3 for the preview server.
  • RPM files built for your clients, here /path/to/packages/.
  • An empty /srv/sow directory your user can create and write to, or another path.
  • For step 5, an EL host with dnf. The preview listens on 127.0.0.1 only, so run the client on the same host or publish the repository first.

Create the workspace

mkdir -p /srv/sow
cd /srv/sow
sow init .
sow repo new pigsty
sow dist new el9 --format rpm -r pigsty

sow init makes /srv/sow a workspace: sow.yml plus private state. pigsty is the standard repository inside it, the directory tree you will serve. el9 is a Dist: one RPM package set with its own index for each architecture.

Set membership policy

Policy decides which of the packages you add each Dist actually publishes. Edit the generated sow.yml; this example keeps one version per package name and architecture and excludes debug and LLVM JIT packages:

schema: sow/v3
architectures: [x86_64, aarch64]
repos:
  pigsty:
    dists:
      el9:
        format: rpm
        limit: 1
        exclude:
          - kind: [debuginfo, debugsource, llvmjit]
targets: {}

Check the configuration:

sow config check

exclude runs before limit. noarch packages enter every enabled architecture view, and architectures takes CPU architecture names only. See Membership policy for the other filters.

Add RPMs

sow add /path/to/packages/*.rpm -r pigsty -d el9
sow check -r pigsty

add stores each accepted package once in the pool, updates membership, and builds the indexes. It reports one line per package: a file that the policy filters out is reported as excluded without failing the whole command.

The public tree has this shape:

  • /srv/sow/pigsty/
    • pool/
    • dists/el9/
      • x86_64/repodata/
      • aarch64/repodata/

Each repodata/ reaches the packages in pool/ through relative paths, so serve or copy the complete pigsty/ tree, never a single dists/ directory.

Preview over HTTP

Run this in a separate terminal and leave it running:

python3 -m http.server --bind 127.0.0.1 --directory /srv/sow/pigsty 8080

The preview serves the repository root to the same host only. For a persistent service or clients on other hosts, use Serve and publish.

Configure dnf

On the host running the preview, save this as /etc/yum.repos.d/pigsty.repo. For a remote client, publish the repository first and use its public base URL:

# /etc/yum.repos.d/pigsty.repo
[pigsty-el9]
name=Pigsty EL9
baseurl=http://127.0.0.1:8080/dists/el9/$basearch/
enabled=1
gpgcheck=0
repo_gpgcheck=0

dnf expands $basearch to x86_64 or aarch64, so the same file works on both architectures. Signature checks are off because nothing is signed yet.

Refresh and query the repository:

sudo dnf --disablerepo='*' --enablerepo=pigsty-el9 makecache --refresh
dnf --disablerepo='*' --enablerepo=pigsty-el9 list available

The repository works when makecache succeeds and list available shows the packages you added. After the preview, remove the source file and stop the Python server.

Publish or export

To give other hosts access, use sow publish with a filesystem or R2 target. It uploads packages and metadata in the order clients need. The same tutorial covers manual delivery to isolated hosts.

Some mirroring tools, including default dnf reposync, reject rpm-md package locations that climb to the shared pool. For those consumers, export a self-contained RPM leaf for one Dist and architecture:

mkdir -p /srv/export
sow export rpm-leaf el9 x86_64 /srv/export/pigsty-el9-x86_64 -r pigsty

The destination must be absent or empty, and its parent directory must already exist. Export reads the latest build, so run sow build first if membership changes are pending; otherwise it exits 5. sow export lists the full requirements. Export copies package files by default. --hardlink works only on the same filesystem, and the exported files then share storage with the pool, so keep them read-only.

Update the repository

sow add /path/to/new.rpm -r pigsty -d el9
sow check -r pigsty

add builds the update itself. With limit: 1, the newest version replaces the previous member for each package name and architecture. After you change sow.yml, run sow build -r pigsty to apply the new policy.

To withdraw a package, preview the selection with sow rm PACKAGE_NAME -r pigsty -d el9 --check, then repeat without --check. A package name selects all its versions and architectures; use a SHA-256 reference to select one package object.

Next

2 - Migrate an Existing YUM Repository

Move a createrepo_c repository to SOW as a simple repository without breaking clients that cached the old index or verify its signature.

Replacing the tool that writes repodata/ looks like a one-line change, but your clients already hold state from the old repository. They have cached its index, they may verify its signature, and they reach it through a fixed URL and repository ID. A new generator that ignores that state works on a fresh test host and fails on every existing one.

This tutorial covers a repository that is one directory of RPMs plus repodata/, as createrepo_c builds it. sow create indexes that directory in place, which makes it a simple repository: no workspace, no configuration file, no database. You choose a publication timestamp newer than anything clients have seen, build and sign a candidate copy, test it against an existing client cache, and then switch over.

You need:

  • SOW 0.9.0 on the build host, plus GPG and Python 3.
  • The live repository, here /srv/yum, and a backup of its packages and metadata.
  • The metadata signing key, if clients use repo_gpgcheck=1.
  • A test client that already has the old repository cached, with its existing .repo file.

What existing clients expect

Client state What fails after a careless switch What this procedure does
A cached repomd.xml EL7 YUM rejects an index whose largest data timestamp is older than the cached one, and sow create writes 0 by default Pass --metadata-timestamp newer than any published value
repo_gpgcheck=1 sow create rewrites repomd.xml but leaves the old repomd.xml.asc in place, so the signature no longer matches Sign repomd.xml after the final create run
gpgcheck=1 Packages must carry signatures the client trusts Keep valid upstream signatures, or deliberately re-sign with your key
A fixed URL and repository ID Changing either discards the cache you need to test against Test the candidate through the original URL and ID

sow create also writes less than createrepo_c in a few places. Check these before you start:

  • It indexes top-level regular RPM files only. Plan nested package layouts separately.
  • It writes primary, filelists, and other XML, with no SQLite databases and no module streams or profiles. Clients that rely on modular filtering keep their existing module_hotfixes=1 setting.
  • If the current repomd.xml lists independent metadata such as comps, updateinfo, or modules, sow create replaces the index without it and reports the dropped types as a warning on stderr, or in dropped_metadata with --json. If clients still need those records, keep that repository on the tool that produces them.

1. Prepare a working copy

Build the migration in a separate working copy, here /srv/yum.candidate, so the live repository stays untouched until you switch. Copy the RPM files rather than hard-linking them if you plan to re-sign them. Then check the binary:

cp -a /srv/yum /srv/yum.candidate
SOW="$(command -v sow)"
"$SOW" version

The version must be 0.9.0.

2. Choose the publication timestamp

Find the largest data timestamp clients may have seen. Read <data><timestamp> from the live repomd.xml and from any retained copies; for one file:

grep -o '<timestamp>[0-9]*</timestamp>' /srv/yum/repodata/repomd.xml |
  tr -cd '0-9\n' | sort -n | tail -1

Use data timestamps, not <revision> or file modification times. If a previous run reset the live index to 0, recover the value from older copies or publication records.

For changed content, the next publication time is:

next time = max(current Unix second, largest known publication time + 1)

EL7 also accepts an equal timestamp; the +1 makes each publication distinguishable. Have your maintenance script serialize updates and save the greatest published timestamp outside the served tree. Save the chosen value before switching the public index: a failed publication then leaves only a harmless gap in the sequence. Keep this record when you restore old content or move the repository to another directory.

For unchanged content, reuse the saved timestamp. create then reports a no-op and the existing signature stays valid. Passing the current time on every run changes repomd.xml each time, so nothing is ever a no-op and every run needs a new signature. The exception is a zero or regressed timestamp: replace it even when content is unchanged.

3. Build and sign a candidate

Set HISTORICAL_MAX to the verified maximum from step 2 and SIGN_KEY to the full fingerprint of your metadata signing key. The Python one-liner picks a strictly newer time:

set -euo pipefail
: "${SOW:?Set the path to the tested SOW binary}"
: "${HISTORICAL_MAX:?Set the verified historical maximum Unix second}"
: "${SIGN_KEY:?Set the full metadata signing fingerprint}"
PUBLISH_TIME=$(python3 -c 'import sys,time; h=int(sys.argv[1]); assert 0 <= h < 253402300799; print(max(int(time.time()), h+1))' "$HISTORICAL_MAX")

"$SOW" create /srv/yum.candidate --metadata-timestamp "$PUBLISH_TIME"
gpg --batch --yes --armor --detach-sign --local-user "$SIGN_KEY" \
  --output /srv/yum.candidate/repodata/repomd.xml.asc \
  /srv/yum.candidate/repodata/repomd.xml
gpg --verify /srv/yum.candidate/repodata/repomd.xml.asc \
  /srv/yum.candidate/repodata/repomd.xml

Record PUBLISH_TIME in your maintenance system before publishing the candidate, and check that the fingerprint gpg --verify reports is the key clients trust.

To sign packages as well, add --sign-with KEY to the create command. It signs unsigned RPMs and keeps existing signatures, including vendor signatures. Add --overwrite to replace every package signature with your key; this changes package bytes, so do it only in the candidate copy. create indexes the signed result, so always generate the detached repomd.xml.asc after the last create run.

For a protected package-signing key, pass --passfile PATH or set SOW_GPG_PASSFILE; see Password files. Those settings do not reach the separate gpg command. For unattended metadata signing, add --pinentry-mode loopback --passphrase-file PATH next to --batch, or use a key the GPG agent has already unlocked.

4. Test the candidate

Point the test client’s original repository URL at the candidate directory. Keep its old cache, repository ID, and signature settings. Refresh the index, then download and install a package. The test passes when the refresh reports no timestamp or signature error and the package installs: that proves cache compatibility, package paths, and signatures together.

If you are migrating an automated update script, also check two cases:

  1. With the same inputs, options, and timestamp, a repeat build reports noop=true, and the existing detached signature still verifies.
  2. After package content changes, the script advances the timestamp and the same client fetches the new package.

When you compare output with createrepo_c, compare dependency meaning and client behavior; XML formatting can differ. See Platforms & Integrations.

5. Publish the repository

sow create replaces several files in place; it cannot switch a whole directory atomically. Let your publication layer switch the tested candidate as a unit, packages and detached signature included, for example with the release-directory switch in Deliver to an isolated host.

SOW keeps the current and the immediately previous checksum-named RPM metadata sets, so a client that read the previous repomd.xml can still fetch its XML. Unchanged runs keep the same previous set. Keep .sow-plain-rpm-history.json when you copy the directory for further builds, because it records those sets. If clients cache indexes across several updates, retain the older metadata and packages they need in your publication layer.

Keep the original backup and the saved maximum publication time. To roll back package content, rebuild and sign it as a newer publication. Restoring an old repomd.xml beside changed RPMs brings the checksum and timestamp failures back.

After the migration

Later updates repeat steps 2 to 5: pick the next timestamp, run create on a candidate copy, sign, test, and switch.

To remove superseded RPM versions, run sow prune with the same --metadata-timestamp rule before signing. It refuses an index that still carries foreign metadata types, and a live run refuses repodata/ that contains repomd.xml.asc. Delete the old signature in the candidate copy, prune, then sign again.

A simple repository relies on the client checks above; sow check works only for standard repositories. Next, see sow create for every option and Sign your repository for how metadata and package signatures fit together. When one directory becomes hard to manage, Your first standard repository shows the alternative.

3 - Build an APT Repository

Build a standard APT repository with by-hash indexes, install from it with apt, and keep it updated.

You have DEBs for Debian or Ubuntu hosts and want apt install to work against your own repository, with the same update behavior clients expect from a public archive. This tutorial builds an APT standard repository, which SOW maintains in a workspace: one suite, trixie, with amd64 and arm64 indexes over a single package pool, and an apt client that installs from it.

You need:

  • SOW 0.9.0 (Installation) and Python 3 for the preview server.
  • DEB files built for your clients, here /path/to/packages/.
  • An empty /srv/sow directory your user can create and write to, or another path.
  • For step 5, a Debian or Ubuntu host with apt. The preview listens on 127.0.0.1 only, so run the client on the same host or publish the repository first.

Create the workspace

mkdir -p /srv/sow
cd /srv/sow
sow init .
sow repo new pigsty
sow dist new trixie --format deb -r pigsty

sow init makes /srv/sow a workspace: sow.yml plus private state. pigsty is the standard repository inside it, the directory tree you will serve. trixie is a Dist, one named package set; its name becomes the Suites value in the client’s source configuration.

Set membership policy

If you need filtering or version limits, edit the generated sow.yml. This example keeps one version per package name and architecture and excludes debug symbol packages:

schema: sow/v3
architectures: [x86_64, aarch64]
repos:
  pigsty:
    dists:
      trixie:
        format: deb
        limit: 1
        exclude:
          - kind: [dbgsym, dbg]
targets: {}

Then validate it:

sow config check

Configuration uses the canonical names x86_64 and aarch64 (amd64 and arm64 are accepted as aliases), and SOW writes the Debian amd64 and arm64 indexes from them. Architecture-independent all packages enter both views.

Add DEBs

sow add /path/to/packages/*.deb -r pigsty -d trixie
sow check -r pigsty

add stores each accepted package once in the pool and builds the indexes. The public tree is:

  • /srv/sow/pigsty/
    • pool/
    • dists/trixie/
      • Release
      • main/
        • binary-amd64/
          • Packages
          • Packages.gz
          • by-hash/SHA256/
        • binary-arm64/

The Filename paths in Packages are relative to the repository root, so serve the complete pigsty/ directory. Release declares Acquire-By-Hash: yes, and each index is also stored under by-hash/SHA256/. During an update, a client that already fetched the previous Release still downloads the Packages file that matches it.

Preview over HTTP

Run this in a separate terminal and leave it running:

python3 -m http.server --bind 127.0.0.1 --directory /srv/sow/pigsty 8080

The preview serves the repository root to the same host only. For a persistent service or clients on other hosts, use Serve and publish.

Configure APT

On the host running the preview, save this as /etc/apt/sources.list.d/pigsty.sources. Use arm64 in Architectures on ARM64 clients. For a remote client, publish the repository first and use its public URL:

# /etc/apt/sources.list.d/pigsty.sources
Types: deb
URIs: http://127.0.0.1:8080
Suites: trixie
Components: main
Architectures: amd64
Trusted: yes

URIs points at the repository root, not at dists/. Trusted: yes accepts this unsigned example; Sign your repository replaces it with Signed-By.

Refresh and query it:

sudo apt update
apt-cache policy

The repository works when apt update completes and apt-cache policy lists trixie/main as a package source. After the preview, remove the test source file and stop the Python server.

Publish the repository

To give other hosts access, use sow publish with a filesystem or R2 target. It uploads packages and indexes before it updates Release and its signatures. The same tutorial covers manual delivery to isolated hosts.

Update the repository

sow add /path/to/new.deb -r pigsty -d trixie
sow check -r pigsty

add builds the update itself. With limit: 1, the newest version replaces the previous member for each package name and architecture. After you change sow.yml, run sow build -r pigsty to apply the new policy.

To withdraw a package, preview the selection with sow rm PACKAGE_NAME -r pigsty -d trixie --check, then repeat without --check. A package name selects all its versions and architectures; use a SHA-256 reference to select one package object.

Next

4 - Sign Your Repository

Sign repository metadata and, optionally, RPM packages, then make dnf and apt reject anything you did not sign.

An unsigned repository trusts whoever controls the web server or the network path: a modified index or package installs without complaint. Clients close that gap with two independent checks, and you enable each one on its own:

  • Metadata signatures prove that the index came from you. The index records the checksum of every package, so a verified index also exposes a package that was swapped on the server. dnf checks repomd.xml.asc when repo_gpgcheck=1; apt checks InRelease or Release.gpg against the key named in Signed-By.
  • RPM package signatures live inside each RPM. dnf checks them when gpgcheck=1, and they still hold after the file leaves your repository. DEBs have no counterpart: APT trusts package hashes through the signed Release, so DEBs need no package signature.
What is signed SOW output Client setting
RPM metadata repodata/repomd.xml.asc repo_gpgcheck=1
APT metadata InRelease and Release.gpg Signed-By
RPM package Embedded RPM signature gpgcheck=1

In this tutorial you create a dedicated signing key, sign the metadata of the pigsty repository, optionally sign its RPMs, and turn on verification in dnf and apt. Start with metadata signing, which covers both formats; add package signing when clients require gpgcheck=1. Signing model explains the mechanism.

You need:

  • The pigsty standard repository in the /srv/sow workspace, from the YUM or APT tutorial. Run only the commands for the formats and Dists you created.
  • GPG, plus rpm if you sign RPM packages.
  • A client host and a way to publish the repository to it; see Serve and publish.

1. Create a dedicated key

These commands create an unencrypted test key and export it to a private directory outside the public repository tree. For a protected key, see the password note in step 2.

SIGNING_UID='SOW Repository <repo@example.com>'
gpg --batch --pinentry-mode loopback --passphrase '' \
  --quick-generate-key "$SIGNING_UID" rsa3072 sign 2y

FPR="$(gpg --batch --with-colons --list-secret-keys "$SIGNING_UID" \
  | awk -F: '$1 == "fpr" {print $10; exit}')"
test -n "$FPR"

sudo install -d -m 0700 /srv/sow-secrets
sudo chown "$(id -u):$(id -g)" /srv/sow-secrets
gpg --batch --pinentry-mode loopback --passphrase '' --armor \
  --export-secret-keys "$FPR" > /srv/sow-secrets/repo-signing.asc
gpg --armor --export "$FPR" > /srv/sow-secrets/repo-signing.pub
chmod 600 /srv/sow-secrets/repo-signing.asc

SOW reads the private key from /srv/sow-secrets. If SOW runs under a different service account, give that account access to the directory. repo-signing.pub is what you distribute to clients.

2. Configure metadata signing

In /srv/sow/sow.yml, merge these entries into the repository’s existing signing block. Keep its package policy and Dist definitions, and include only the formats you use:

repos:
  pigsty:
    signing:
      rpm:
        metadata:
          key: file:///srv/sow-secrets/repo-signing.asc
      deb:
        metadata:
          key: file:///srv/sow-secrets/repo-signing.asc
    dists:
      # existing Dist definitions remain here

A protected key needs a password source before you check or build. Add passfile: /run/secrets/gpg-password next to key, run export SOW_GPG_PASSFILE=/run/secrets/gpg-password, or pass it for one invocation, as in sow build -r pigsty --passfile /run/secrets/gpg-password. The same works for agent://FINGERPRINT keys. The file holds the password itself on one line; keep it outside the repository, normally with mode 0600. sow.yml stores only the reference, never the secret. Password files gives the priority order and exact format; existing passphrase references keep working.

Validate, rebuild, and check:

cd /srv/sow
sow config check
sow build -r pigsty
sow check -r pigsty

A new key marks the affected Dists dirty, so build signs their metadata again. Metadata signing is in place when sow check passes: it verifies every metadata signature.

3. Optional: inspect the metadata signer

To see the signer with GPG, run the commands for your Dists:

gpg --verify \
  pigsty/dists/el9/x86_64/repodata/repomd.xml.asc \
  pigsty/dists/el9/x86_64/repodata/repomd.xml

gpg --verify pigsty/dists/trixie/InRelease
gpg --verify \
  pigsty/dists/trixie/Release.gpg \
  pigsty/dists/trixie/Release

The fingerprint shown must match the public key you distribute to clients.

4. Optional: sign RPM package bodies

SOW signs an RPM while add imports it and never re-signs packages already in the pool: build only checks stored RPMs against the policy. So in a new repository, configure package signing before you import RPMs. Add this block under the existing signing.rpm configuration:

repos:
  pigsty:
    signing:
      rpm:
        packages:
          mode: fill
          key: agent://REPLACE_WITH_THE_FINGERPRINT
        metadata:
          key: file:///srv/sow-secrets/repo-signing.asc

Replace the placeholder with the 40-hex fingerprint in $FPR. SOW signs through the host rpm command, so install rpm and gpg and make the secret key available in the GPG keyring that rpm uses.

fill signs each newly imported package unless its signature already verifies against the configured key or a key in trusted_keys. SOW verifies both RPM v4 and RPM v6 signatures; Signing model lists the formats, and the configuration reference describes the other modes. SOW signs a private copy, so your input file stays unchanged.

For a protected package-signing key, set passfile under signing.rpm.packages or use SOW_GPG_PASSFILE; a passfile under metadata applies only to the metadata key. config check validates the package-signing prerequisites but does not sign anything, so the password is first tested when an add actually signs a package.

If the pool already holds RPMs, check their signatures before you enable fill, and put trusted upstream public keys in trusted_keys. Unsigned or untrusted stored packages stay as they are: replace them with correctly signed packages that have new versions and file names, or configure signing in a new repository and import the originals there.

Import a new package and check the result:

sow config check
sow add /path/to/new.rpm -r pigsty -d el9
sow check -r pigsty

To inspect a signed package independently, run rpmkeys --checksig on its file in pigsty/pool/.

5. Enable DNF verification

First publish the signed repository. Then transfer the public key to the client through a trusted channel and import it:

sudo install -m 0644 /path/to/repo-signing.pub /etc/pki/rpm-gpg/RPM-GPG-KEY-pigsty
sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-pigsty

Enable the checks that match what you signed:

[pigsty-el9]
name=Pigsty EL9
baseurl=https://repo.example.com/pigsty/dists/el9/$basearch/
enabled=1
repo_gpgcheck=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-pigsty

If you signed only metadata, use repo_gpgcheck=1 and gpgcheck=0. With package checks on, install the key of every upstream vendor whose signatures you kept, as well as your own. Then run sudo dnf makecache --refresh and install a package; both succeed only if the signatures verify.

6. Enable APT verification

After publishing the signed repository, install its public key on the client as a dedicated keyring:

sudo gpg --dearmor --yes \
  --output /usr/share/keyrings/pigsty-archive-keyring.gpg /path/to/repo-signing.pub
sudo chmod 0644 /usr/share/keyrings/pigsty-archive-keyring.gpg

Reference it from the deb822 source and remove Trusted: yes:

Types: deb
URIs: https://repo.example.com/pigsty
Suites: trixie
Components: main
Architectures: amd64
Signed-By: /usr/share/keyrings/pigsty-archive-keyring.gpg

On ARM64 clients, set Architectures to arm64. Run sudo apt update and install a package. If verification fails, compare the fingerprint of the client keyring with the signer gpg --verify reports.

RPM signing in a simple repository

In a simple repository, sow create can sign the RPM package bodies, but not the metadata, and a simple repository has no APT Release to sign:

sow create /srv/flat --sign-with 0123456789ABCDEF

Replace 0123456789ABCDEF with your key ID or fingerprint; the matching private key must be available to rpm and GPG. SOW keeps existing signatures, including upstream ones. To replace every signature with your key, add --overwrite on a separate working copy. For a protected key, add --passfile /run/secrets/gpg-password or set SOW_GPG_PASSFILE; a separate gpg command still needs its own credentials. See sow create for key formats.

For an existing YUM repository, the migration guide shows how to keep the publication timestamp and sign repomd.xml after the final create run.

Key changes

To rotate a metadata key, distribute the new public key to clients first, then update the key reference and run build, check, and publish. The changed key marks the affected Dists dirty.

For RPM package keys, use fill and keep the old public key in trusted_keys until the packages it signed are withdrawn or replaced; clients need the old key for that period too. Existing package objects never change. Signing model has the full rotation sequence.

Next

Test the final repository with the dnf and apt versions your users run; see Platforms & Integrations for what is covered automatically. Then serve and publish it.

5 - Serve and Publish Repositories

Publish a standard repository to a filesystem target in client-safe order, serve it with Nginx, and deliver updates or offline copies.

Putting a repository on a web server is more than copying a directory. While an update is in flight, a client can read the new index before its packages arrive, or keep using a cached index after you deleted the packages it names. Both show up as 404 or checksum errors in dnf and apt. A hand-written copy script also cannot resume a half-finished upload or tell you what the server actually holds.

For a standard repository, sow publish handles this for you:

  • Client-safe order. It copies package files first, then metadata with content-specific file names, and replaces the entry points that clients read first, repomd.xml and Release, last.
  • Resumable. It records progress, so rerunning the same command finishes an interrupted publication. Rerunning it after success is a no-op.
  • Cache grace before deletion. Files that the new build no longer needs stay on the target for the cache lifetime you declare, so clients holding an old index can still download what it names. Only then can sow gc remove them.
  • Verified delivery. It reads the published files back through the public endpoint before it records the publication.

In this tutorial you publish the local repository to a directory, serve that directory with Nginx, check it from a client, and publish an update. A final section covers hosts that SOW cannot reach.

You need:

  • The local repository and its el9 and bookworm Dists from Your first standard repository, in the /srv/sow workspace.
  • Nginx on the serving host, and sudo to create /srv/repo-public.
  • A dnf or apt client that can reach the server.

The source tree is /srv/sow/local; the public copy will be /srv/repo-public/local. Both hold the complete pool/ and dists/ tree. sow.yml and the private .sow/ state stay outside the server root.

1. Build and check

cd /srv/sow
sow build -r local
sow check -r local

publish delivers the last completed build, so build pending changes first. Continue when check succeeds.

2. Add a filesystem target

Create the target’s parent directory and give the account that runs sow publish, here your own, write access to it:

sudo install -d -m 0755 /srv/repo-public
sudo chown "$(id -u):$(id -g)" /srv/repo-public

The endpoint must already exist as a real directory; SOW rejects a path with a symlink component. Add the target to /srv/sow/sow.yml:

targets:
  public:
    repository: local
    provider: filesystem
    endpoint: file:///srv/repo-public
    prefix: local
    public_endpoint: file:///srv/repo-public/local/
    max_cache_ttl: 0s
    authoritative_workspace: true
    single_writer: true
    exclusive_write_authority: true

SOW creates /srv/repo-public/local from endpoint and prefix. The three authority fields declare that this workspace is the source of truth and the only writer for that path. They default to true when omitted, and an explicit false is rejected. Give other tools their own prefix; sibling targets with distinct prefixes under the same parent directory do not block each other.

public_endpoint and max_cache_ttl tell SOW where clients read the files and how long they may cache them. This example checks the files through file:// and declares no cache, so superseded files get no grace period. Once clients cache older indexes, or you put a proxy or CDN in front, set public_endpoint to the public repository URL and max_cache_ttl to the longest cache lifetime, then apply the change with sow publish public --rebind.

Publish the repository:

sow publish public

For the sample repository, the first run and a repeat print:

published local generation=00000000000000000004 to public (filesystem): phase=grace objects=28
publication local generation=00000000000000000004 to public is already current (noop)

The Generation number and object count depend on your repository. Exit status 0 means the target holds the current build.

3. Configure Nginx

Install Nginx and add a server block like this one, with your hostname in place of repo.example.com:

server {
    listen 80;
    server_name repo.example.com;

    root /srv/repo-public;
    autoindex off;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ (^|/)\. {
        deny all;
    }
}

The last location keeps hidden files, including temporary files, private. Check and reload the configuration:

sudo nginx -t
sudo nginx -s reload

reload assumes Nginx is already running. On a new installation, start it through your service manager once nginx -t succeeds.

Clients use these addresses:

Client Address
DNF baseurl http://repo.example.com/local/dists/el9/$basearch/
APT URIs http://repo.example.com/local
APT Suites / Components bookworm / main

The YUM and APT tutorials show the full source configuration. To verify signatures, distribute the public key as described in Sign your repository.

4. Check client access

Configure a client with the addresses above, refresh its indexes, and install a package. Success proves that both dists/ and pool/ are reachable over HTTP; if only the refresh works, the server treats the two directories differently. Give them the same access rules.

Publish an update

After you change membership or configuration, build and publish again:

sow build -r local
sow check -r local
sow publish public

If publication stops partway, rerun sow publish public to resume it. Once the cache grace period has passed, remove the files that no current build needs from the target:

sow gc public

See sow publish for abort, recovery, and target changes, and target GC for what gc keeps.

Deliver to an isolated host

When SOW cannot reach the destination, you take over the ordering that publish normally provides. Never copy over the live tree: build a complete new release directory and switch to it in one step. Stop all writes to the source repository while you create and check the copy.

  1. Run sow check on the source.
  2. Copy the complete repository to a new release directory on the destination. Preserve hard links, for example with rsync -aH or tar.
  3. Verify the transferred files against sow changes 0, which lists every file of the current build with its size and SHA-256, or against an archive checksum manifest.
  4. Switch the server’s path to the new release directory.
  5. Keep package and immutable metadata URLs that old indexes reference reachable until the longest client cache lifetime has passed, then remove the old release.

During that interval, the HTTP server can fall back to the previous release directory for paths missing from the new one.

Warning

Copying directly over a live tree can expose indexes before their package files arrive. Prepare the new directory first and switch it as a unit.

Serve a simple repository

For a simple repository, serve the directory you passed to sow create, with the same dotfile rule so temporary hidden files stay private. sow publish works only for standard repositories, so switch updates to a simple repository as a unit, as described above.

Publish to R2

For Cloudflare R2, use provider: r2 and configure its endpoint, bucket, credential reference, public URL, and cache lifetime; see the target configuration reference. Publish to a test prefix first and check it from your package clients.

On R2, sow gc TARGET only reports candidates after the cache grace period. If this workspace is the sole writer to the prefix, run sow gc TARGET --delete to reclaim them. See target GC.

Next steps

6 - Build the pigsty-infra Repository

Turn an existing dual-architecture RPM and DEB package pool into an infra repository, then validate installs, roll updates, promote to Stable, and take monthly snapshots.

pgsty/infra-pkg builds the Pigsty Infra packages as RPMs and DEBs for x86-64 and ARM64. Users of those packages want three kinds of channel: a rolling latest that gets every new version, a stable channel that moves only when you promote a release, and monthly snapshots that stay fixed. This tutorial builds that infra repository as a standard repository from already-built packages. Each channel is a pair of Dists, one per format; a Dist is a named package set with its own indexes, and all Dists share one package pool. Real dnf and apt clients in containers check each stage.

You need:

  • SOW 0.9.0, jq, and Docker. The client tests run rockylinux:9, ubuntu:24.04, and nginx:alpine containers.
  • Built RPMs and DEBs for both architectures in an infra-pkg checkout at ~/pgsty/infra-pkg/dist/. The install tests use pg-exporter, so include it and any dependencies the client images lack.
  • A new, empty ~/repo directory for the workspace.

1. Put the packages under ~/repo

Copy packages from your infra-pkg checkout into two input directories:

mkdir -p ~/repo/packages/rpm ~/repo/packages/deb
cp ~/pgsty/infra-pkg/dist/rpm/*.rpm ~/repo/packages/rpm/
cp ~/pgsty/infra-pkg/dist/deb/*.deb ~/repo/packages/deb/

Include both x86-64 and ARM64 packages. Step 3 checks their formats and architectures from package metadata.

2. Create the infra repository and two Dists

Initialize a workspace and create the repository named infra:

sow init ~/repo
cd ~/repo
sow repo new infra
sow dist new rpm --format rpm -r infra
sow dist new deb --format deb -r infra

Set limit: 1 for both Dists in ~/repo/sow.yml:

schema: sow/v3
architectures: [x86_64, aarch64]
repos:
  infra:
    dists:
      rpm:
        format: rpm
        limit: 1
      deb:
        format: deb
        limit: 1

limit: 1 keeps only the newest version for each package name and native architecture, so the rpm and deb Dists become rolling latest channels that still carry both x86-64 and ARM64. “Newest” follows native RPM (rpmvercmp, including ~ and ^) and Debian version ordering, so a post-release snapshot such as 2.0^20250611 sorts below 2.0.1.

sow config check

3. Ingest once and build once

Import both package formats, then build their indexes together:

cd ~/repo
sow add ~/repo/packages/rpm --recursive -r infra -d rpm --skip
sow add ~/repo/packages/deb --recursive -r infra -d deb --skip
sow build -r infra -d rpm -d deb
sow check -r infra

After sow check succeeds, list the formats and architectures read from package metadata:

sow ls -r infra -d rpm -d deb --json |
  jq -r '.result.packages | group_by(.format + "/" + .canonical_arch)[] |
    "\(.[0].format)\t\(.[0].canonical_arch)\t\(length) packages"'

The output must include at least:

deb     aarch64   ... packages
deb     x86_64    ... packages
rpm     aarch64   ... packages
rpm     x86_64    ... packages

SOW reports canonical architecture names, so DEB amd64/arm64 appear here as x86_64/aarch64.

4. Read the generated filesystem tree

The important structure is:

  • ~/repo/
    • sow.ymlconfiguration; never serve it
    • .sow/database, locks, recovery; never serve it
    • packages/original input pool; archive as desired
      • rpm/
      • deb/
    • infra/complete public repository root
      • pool/one shared payload pool for RPM and DEB
      • dists/
        • rpm/
          • x86_64/repodata/
          • aarch64/repodata/
        • deb/
          • Release
          • main/
            • binary-amd64/
            • binary-arm64/

SOW places all Dists under dists/ and packages under pool/. Publish or mount the complete ~/repo/infra tree so every Dist can reach its package files.

5. Serve the repository read-only with Nginx

Use the official nginx:alpine image and mount the repository root read-only at /infra:

docker network create --internal infra-lab
docker run --detach \
  --name infra-nginx \
  --network infra-lab \
  --publish 127.0.0.1:8080:80 \
  --volume "$HOME/repo/infra:/usr/share/nginx/html/infra:ro" \
  nginx:alpine

Nginx can see only ~/repo/infra; it cannot see sow.yml or .sow/, and it cannot modify the repository.

6. Install an RPM from only infra on EL9

The Rocky Linux 9 container below connects to the --internal network. The script removes every preconfigured repository and enables only infra, so a successful installation cannot fall back to a public mirror.

docker run --rm --interactive --network infra-lab rockylinux:9 bash -s <<'ROCKY'
set -euxo pipefail

rm -f /etc/yum.repos.d/*.repo
cat >/etc/yum.repos.d/infra.repo <<'REPO'
[infra]
name=Pigsty Infra RPM
baseurl=http://infra-nginx/infra/dists/rpm/$basearch/
enabled=1
gpgcheck=0
repo_gpgcheck=0
REPO

dnf clean all
dnf --disablerepo='*' --enablerepo=infra makecache
dnf --disablerepo='*' --enablerepo=infra install -y pg-exporter
rpm -q --qf '%{NAME}\t%{VERSION}-%{RELEASE}\t%{ARCH}\n' pg-exporter
command -v pg_exporter
ROCKY

An RPM baseurl must point to a concrete architecture view. dnf expands $basearch to x86_64 or aarch64.

7. Install a DEB from only infra on Ubuntu 24.04

APT points URIs at the repository root and uses the Dist name deb as Suites:

docker run --rm --interactive --network infra-lab ubuntu:24.04 bash -s <<'UBUNTU'
set -euxo pipefail

rm -f /etc/apt/sources.list
rm -f /etc/apt/sources.list.d/*.list /etc/apt/sources.list.d/*.sources
cat >/etc/apt/sources.list.d/infra.sources <<'SOURCE'
Types: deb
URIs: http://infra-nginx/infra
Suites: deb
Components: main
Trusted: yes
SOURCE

apt-get clean
apt-get update
apt-get install -y --no-install-recommends pg-exporter
dpkg-query -W -f='${Package}\t${Version}\t${Architecture}\n' pg-exporter
command -v pg_exporter
UBUNTU

The lab uses unsigned repositories. Follow Sign Your Repository to enable repo_gpgcheck=1 for RPM metadata and Signed-By for APT. Use gpgcheck=1 when RPM package signatures are also available. Remove Trusted: yes from the signed APT source.

Docker containers use the host architecture by default. To test the other architecture, add --platform linux/amd64 or --platform linux/arm64 to the corresponding docker run. Cross-architecture execution requires binfmt/QEMU support.

8. Routine maintenance: add a new version

To update the repository, run add with the new packages. Suppose the four new pg-exporter payloads are ready:

cp ~/pgsty/infra-pkg/dist/rpm/pg-exporter-*.rpm ~/repo/packages/rpm/
cp ~/pgsty/infra-pkg/dist/deb/pg-exporter_*.deb ~/repo/packages/deb/

cd ~/repo
sow add ~/repo/packages/rpm/pg-exporter-*.rpm -r infra -d rpm --skip
sow add ~/repo/packages/deb/pg-exporter_*.deb -r infra -d deb --skip
sow build -r infra -d rpm -d deb
sow check -r infra

Because the latest Dists have limit: 1, the new version wins and the old version leaves that Dist’s desired membership automatically. SOW does not delete the old bytes immediately. Relaxing policy later does not restore the old membership automatically.

Rerun the EL9 and Ubuntu clients from sections 6 and 7, refresh metadata, then install or upgrade to complete the update acceptance test.

To withdraw a bad package, use sow ls -r infra -d rpm --json to find its SHA-256. Preview with sow rm sha256:DIGEST -r infra -d rpm --check, then repeat without --check. Use -d deb for DEBs. A SHA-256 reference selects one package object; a bare name selects all its versions and architectures. sow gc handles unused pool files separately.

9. Two retention layers: latest and stable

limit: 1 makes rpm and deb good rolling channels, but it cannot express “keep every formally released version.” Create two more Dists for that purpose:

cd ~/repo
sow dist new rpm-stable --format rpm -r infra
sow dist new deb-stable --format deb -r infra
sow config show -r infra -d rpm-stable -d deb-stable

The new Dists default to limit: 0, which means retain every version. The resulting policy is:

Dist Format limit Role
rpm RPM 1 RPM latest
deb DEB 1 DEB latest
rpm-stable RPM 0 Accumulate promoted RPMs
deb-stable DEB 0 Accumulate promoted DEBs

Stable accumulates the versions you explicitly promote after creating the Dists.

10. Promote latest into stable

Promote packages by adding the source Dist’s pool files to the target Dist. SOW verifies and reuses the existing package objects, so promotion adds no second copy. Pause other repository writers before exporting the manifests. Resume them after promotion finishes.

First require clean source state and save the promotion manifests:

set -euo pipefail
cd ~/repo
sow check -r infra
mkdir -p ~/repo/manifests

sow ls -r infra -d rpm --json |
  jq -r '.result.packages[].pool_path' > ~/repo/manifests/rpm-latest-202608.list
sow ls -r infra -d deb --json |
  jq -r '.result.packages[].pool_path' > ~/repo/manifests/deb-latest-202608.list

Add the recorded pool objects to the stable Dists:

cd ~/repo
(
  set -euo pipefail
  while IFS= read -r pool_path; do
    sow add "$HOME/repo/infra/$pool_path" -r infra -d rpm-stable --skip
  done < ~/repo/manifests/rpm-latest-202608.list

  while IFS= read -r pool_path; do
    sow add "$HOME/repo/infra/$pool_path" -r infra -d deb-stable --skip
  done < ~/repo/manifests/deb-latest-202608.list

  sow build -r infra -d rpm-stable -d deb-stable
  sow check -r infra
)

Each add should report reused. If the loop stops midway, the source Dists stay unchanged. Fix the failure and rerun the same manifest. Over subsequent promotions, rpm/deb retain only the latest version while rpm-stable/deb-stable accumulate release history.

11. Take the 2026-08 snapshot from stable

A client-visible monthly snapshot is another pair of Dists:

cd ~/repo
sow dist new rpm-202608 --format rpm -r infra
sow dist new deb-202608 --format deb -r infra
sow config show -r infra -d rpm-202608 -d deb-202608

Pause other repository writers while creating the snapshot. First save the stable package lists:

set -euo pipefail
sow check -r infra
sow ls -r infra -d rpm-stable --json |
  jq -r '.result.packages[].pool_path' > ~/repo/manifests/rpm-stable-202608.list
sow ls -r infra -d deb-stable --json |
  jq -r '.result.packages[].pool_path' > ~/repo/manifests/deb-stable-202608.list

Add those manifests to the corresponding snapshot Dists:

cd ~/repo
(
  set -euo pipefail
  while IFS= read -r pool_path; do
    sow add "$HOME/repo/infra/$pool_path" -r infra -d rpm-202608 --skip
  done < ~/repo/manifests/rpm-stable-202608.list

  while IFS= read -r pool_path; do
    sow add "$HOME/repo/infra/$pool_path" -r infra -d deb-202608 --skip
  done < ~/repo/manifests/deb-stable-202608.list

  sow build -r infra -d rpm-202608 -d deb-202608
  sow check -r infra
)

To keep this build after you eventually remove the snapshot Dists, also retain the current Generation of the repository:

sow retain add "$(sow status -r infra --json | jq -r '.result.built_generation')" -r infra
sow retain ls -r infra

retain stores this build’s metadata and protects its package files from garbage collection. Clients still use the snapshot Dists. SOW does not make these Dists read-only; keep their membership and effective configuration unchanged to preserve their contents.

12. Client address map

One Nginx service and one shared infra/pool support every channel:

Channel dnf baseurl APT URIs / Suites
latest http://infra-nginx/infra/dists/rpm/$basearch/ http://infra-nginx/infra / deb
stable http://infra-nginx/infra/dists/rpm-stable/$basearch/ http://infra-nginx/infra / deb-stable
2026-08 http://infra-nginx/infra/dists/rpm-202608/$basearch/ http://infra-nginx/infra / deb-202608

Use sow dist ls -r infra to see all six Dists.

The rolling Dists keep the latest packages, stable Dists accumulate promoted releases, and monthly Dists keep the selected snapshot. All views share the same package pool.

Stop the temporary service when the lab is complete:

docker rm --force infra-nginx
docker network rm infra-lab

Next

The lab serves the repository through a read-only bind mount. For real clients, publish it to a filesystem or R2 target with Serve and publish, which keeps old files available while clients still cache older indexes, and add signatures with Sign your repository.