Skip to content

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