This is the multi-page printable view of this section.
Tutorials
- 1: Build a YUM Repository
- 2: Migrate an Existing YUM Repository
- 3: Build an APT Repository
- 4: Sign Your Repository
- 5: Serve and Publish Repositories
- 6: Build the pigsty-infra 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:
- Quick start: turn a directory of packages into a simple repository.
- Your first standard repository: a workspace, a shared package pool, and Dists.
- YUM or APT: membership policy, updates, and a real client.
- Signing, then serving: what you need before other hosts depend on the repository.
- 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
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/sowdirectory your user can create and write to, or another path. - For step 5, an EL host with
dnf. The preview listens on127.0.0.1only, so run the client on the same host or publish the repository first.
Create the workspace
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:
Check the configuration:
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
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:
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:
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:
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:
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
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
- Sign your repository so
dnfcan verify metadata and packages. - Serve and publish the repository to other hosts.
- Platforms & Integrations lists the tested clients.
2 - Migrate an Existing YUM Repository
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
.repofile.
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=1setting. - If the current
repomd.xmllists independent metadata such ascomps,updateinfo, ormodules,sow createreplaces the index without it and reports the dropped types as a warning on stderr, or indropped_metadatawith--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:
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:
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:
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:
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:
- With the same inputs, options, and timestamp, a repeat build reports
noop=true, and the existing detached signature still verifies. - 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
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/sowdirectory your user can create and write to, or another path. - For step 5, a Debian or Ubuntu host with
apt. The preview listens on127.0.0.1only, so run the client on the same host or publish the repository first.
Create the workspace
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:
Then validate it:
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
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/
- binary-amd64/
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:
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:
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:
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
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
- Sign your repository so
aptverifies it throughSigned-By. - Serve and publish the repository to other hosts.
- Platforms & Integrations lists the tested clients.
4 - Sign Your Repository
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.
dnfchecksrepomd.xml.ascwhenrepo_gpgcheck=1;aptchecksInReleaseorRelease.gpgagainst the key named inSigned-By. - RPM package signatures live inside each RPM.
dnfchecks them whengpgcheck=1, and they still hold after the file leaves your repository. DEBs have no counterpart: APT trusts package hashes through the signedRelease, 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
pigstystandard repository in the/srv/sowworkspace, from the YUM or APT tutorial. Run only the commands for the formats and Dists you created. - GPG, plus
rpmif 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.
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:
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:
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:
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:
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:
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:
Enable the checks that match what you signed:
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:
Reference it from the deb822 source and remove Trusted: yes:
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:
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
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.xmlandRelease, 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 gcremove 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
localrepository and itsel9andbookwormDists from Your first standard repository, in the/srv/sowworkspace. - Nginx on the serving host, and
sudoto create/srv/repo-public. - A
dnforaptclient 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
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:
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:
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:
For the sample repository, the first run and a repeat print:
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:
The last location keeps hidden files, including temporary files, private. Check and
reload the configuration:
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:
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:
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.
- Run
sow checkon the source. - Copy the complete repository to a new release directory on the destination. Preserve hard links, for example with
rsync -aHortar. - 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. - Switch the server’s path to the new release directory.
- 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.
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
- Sign your repository before other hosts depend on it.
- Build the pigsty-infra repository for several channels served from one pool.
sow publishand the Publication & Recovery for recovery details.
6 - Build the pigsty-infra Repository
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 runrockylinux:9,ubuntu:24.04, andnginx:alpinecontainers. - Built RPMs and DEBs for both architectures in an
infra-pkgcheckout at~/pgsty/infra-pkg/dist/. The install tests usepg-exporter, so include it and any dependencies the client images lack. - A new, empty
~/repodirectory for the workspace.
1. Put the packages under ~/repo
Copy packages from your infra-pkg checkout into two input directories:
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:
Set limit: 1 for both Dists in ~/repo/sow.yml:
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.
3. Ingest once and build once
Import both package formats, then build their indexes together:
After sow check succeeds, list the formats and architectures read from package metadata:
The output must include at least:
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/
- rpm/
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:
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.
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:
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:
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:
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:
Add the recorded pool objects to the stable Dists:
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:
Pause other repository writers while creating the snapshot. First save the stable package lists:
Add those manifests to the corresponding snapshot Dists:
To keep this build after you eventually remove the snapshot Dists, also retain the current Generation of the repository:
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:
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.