Skip to content

Membership Policy

Keep debug and JIT subpackages out of your indexes and cap how many versions of each package a Dist keeps.

Upstream build output usually contains packages you do not want to ship: -debuginfo and -debugsource RPMs, PostgreSQL -llvmjit subpackages, Debian -dbgsym packages. And a repository you keep adding to keeps every version it ever received, so the index every client downloads grows with each release. In a standard repository, each Dist, a named package set such as el9, has two settings for this: exclude drops packages that match a rule, and limit keeps only the newest versions of each package.

repos:
  demo:
    dists:
      el9:
        format: rpm
        limit: 2
        exclude:
          - kind: [debuginfo, debugsource, llvmjit]

With this policy, sow add leaves debug and JIT subpackages out of el9, and adding a third version of a package drops the oldest one from the index in the same operation.

How SOW applies policy

SOW evaluates policy whenever membership can change. add, rm, and build each take the complete candidate set of every selected Dist, meaning its current members plus any new inputs, run exclude over it, and then apply limit to what remains. The result depends only on that set, not on the order in which packages arrived. So adding an older version to a group that is already full changes nothing: the older version is limited on arrival.

Editing the policy in sow.yml marks the Dist dirty but changes nothing until the next build:

sow config check
sow status -r demo    # status=dirty dirty_dists=el9
sow build -r demo     # applies the new policy to existing members

A build applies policy to the current members only, so a policy edit can remove packages from an index but can never add any. See Relaxing a policy.

Exclude packages

An exclude list holds rules. SOW excludes a package when any rule matches. A rule matches when all of its fields match, and a field matches when any of its patterns matches.

exclude:
  - kind: [debuginfo, debugsource, dbgsym, dbg, llvmjit]
  - name: ["test-*", "*-experimental"]
    arch: [aarch64]

The first rule drops debug and JIT packages on every architecture. The second drops aarch64 packages whose names start with test- or end with -experimental.

Field Package value
name Binary package name
source Normalized source package name
arch x86_64, aarch64, or neutral
kind Classification in the table below
format rpm or deb

Patterns are case-sensitive exact strings or shell globs (*, ?, [...]). There are no regular expressions, version comparisons, or negation. sow config check rejects empty rules, empty or untrimmed patterns, duplicate patterns within a field, and invalid globs.

SOW derives kind from the suffix of the binary package name:

Format Name suffix kind
RPM -debuginfo debuginfo
RPM -debugsource debugsource
RPM -llvmjit llvmjit
DEB -dbgsym dbgsym
DEB -dbg dbg
Either No matching suffix main

SOW does not check kind patterns against this table, so a typo such as kind: [debug] is valid configuration that matches nothing. sow show PACKAGE --json shows the computed kind of a stored package.

Limit versions

limit: N keeps the newest N versions of each binary package name per architecture. x86_64 and aarch64 count separately, and neutral packages (noarch or all) form their own group even when they share a name with an architecture-specific package. The default 0 keeps every version; a negative value is a configuration error.

“Newest” follows each format’s native version ordering, never string comparison. RPM compares epoch, version, and release with rpmvercmp, including ~ pre-releases and ^ snapshots (2.0~rc1 < 2.0 < 2.0^20250611 < 2.0.1). DEB uses Debian version ordering. Epoch is compared first, which can surprise: CentOS 4’s centos-release package has epoch 6, so it ranks above CentOS 7’s package, which has epoch 0.

Read policy results

sow add reports one line per input, with a result for each selected Dist. In this example, el9 has limit: 2 and an exclusion rule for epel-*, and already holds centos-release 0:6 and 0:7:

sow add rpms/centos-release-4-0.1.x86_64.rpm rpms/epel-release-7-5.noarch.rpm -r demo
add repository=demo operation=6919779572306201678 accepted=1 failed=0 memberships=+1/-1 revision=2 generation=4 dirty=false
item input="rpms/centos-release-4-0.1.x86_64.rpm" status=accepted format=rpm coordinate="centos-release-6:4-0.1.x86_64" sha256:7886102c... dists=el9:accepted
item input="rpms/epel-release-7-5.noarch.rpm" status=excluded format=rpm coordinate="epel-release-0:7-5.noarch" sha256:d6f332ed... dists=el9:excluded

sow add rpms/centos-release-6-0.el6.centos.5.x86_64.rpm -r demo
add repository=demo operation=2344830323726248547 accepted=0 failed=0 memberships=+0/-0 revision=2 generation=4 dirty=false
item input="rpms/centos-release-6-0.el6.centos.5.x86_64.rpm" status=excluded format=rpm coordinate="centos-release-0:6-0.el6.centos.5.x86_64" sha256:ffd9e7bd... dists=el9:limited

The epoch-6 package outranks both members, so it is accepted and 0:6 leaves the Dist (memberships=+1/-1). Adding 0:6 back afterwards does nothing, because it is now older than both members.

An input that no selected Dist accepts has item status excluded. Its per-Dist result says why: excluded means an exclusion rule matched, and limited means the package fell outside the version limit. With --json, read .result.items[].status and .result.items[].dists. Policy results are not failures: they do not count as failed inputs and do not change the exit code. When you select several Dists, one can accept a package that another excludes. A new package that no Dist accepts is not stored in the pool.

Relaxing a policy does not restore packages

Raising limit, deleting an exclusion rule, or removing the newest version of a package does not bring back versions that policy already removed. Policy only filters the candidate set, and a removed version is no longer in it: SOW tracks current membership, not the packages that would be members if the rules allowed them. The benefit is that a configuration edit never puts packages into an index by itself; only add does that.

To restore a version, add its package file again:

sow add ./archive/example-1.0-1.x86_64.rpm -r demo -d el9

Policy removes membership, not package bytes. If a built or retained Generation still needs the file, it is still in the pool, and add reports it as reused. sow gc reclaims package files that nothing references; use sow gc TARGET for a publication target.

Preview removal

sow rm example -r demo -d el9 --check

The preview lists the memberships your references match and the local file changes the removal would make, including index changes that policy causes, without changing repository state. In JSON, check prediction_complete before treating the file list as complete. See sow rm for the options a preview accepts.

See Configuration for the schema and sow add for all input results.

Table reader