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.