Skip to content

RPM Packages

kurokyuu edited this page Nov 30, 2026 · 1 revision

RPM packages

rpm.py turns any project into an RPM, whatever it is written in, and rpm.py publish puts it into an RPM repository on your own server: one directory of signed packages behind a plain web server, which every Fedora machine in the house then installs and updates with dnf. No Copr, no account with anyone, and the signing key never leaves the server.

The page goes in three steps; stop at the one that is enough:

  1. Build one of our apps as an RPM - one machine, no repository.
  2. Package your own project - the [rpm] block.
  3. Host your own repository - a server, a key, and dnf upgrade on every PC.

Build one of our apps as an RPM

These Istarlabs projects carry an [rpm] block:

Project Package(s)
istar-gamescripts istar-gamescripts
istar-countdown istar-countdown
istar-wheelstar istar-wheelstar, istar-wheelstar-ets2-plugin
kurodlg kurodlg
istar-media-converter istar-media-converter
istar-devtools istar-devtools

You need rpm-build, Python 3.11 or newer, and what the project itself needs to build (its README says: cargo for Rust, cmake and the KDE Frameworks development packages for the Qt ones).

sudo dnf install rpm-build
git clone --recursive https://github.com/Istarlabs/istar-gamescripts.git
cd istar-gamescripts
python3 Scripts/rpm.py build
sudo dnf install ~/.cache/devscripts/rpm/istar-gamescripts-*.rpm
  • --recursive brings devscripts along as the .devscripts submodule, which is where Scripts/rpm.py finds the real script. A clone made without it: git submodule update --init.
  • No --depth 1. The version is x.y from the project's version file and the number of commits as .z (a Cargo.toml x.y.0, a CMake VERSION x.y), so a shallow clone gets a wrong version.
  • The release is a timestamp (0.1.5-202611301931), so each build is newer than the one before and dnf upgrade / dnf install of the next one replaces it.
  • python3 Scripts/rpm.py spec prints the spec without building; rpm -qpl <file>.rpm lists what the package installs, rpm -qpR <file>.rpm what it asks of the machine.

A copy installed earlier from the sources has to go, all of it: ~/.local comes before /usr both in PATH and for desktop entries and Dolphin menus, so the old copy keeps winning, or shows up twice. For a Rust project that is ~/.local/bin/<binary> and, with a Dolphin menu, ~/.local/share/kio/servicemenus/<name>.desktop; a CMake project lists what it wrote in build/install_manifest.txt (python3 Scripts/cpp.py uninstall).

Package your own project

  1. Put the project on devscripts (Installation and setup) and add an [rpm] block to Scripts/project.toml. Every key is in the docstring of shared/build/rpm.py.
  2. python3 <devscripts>/install.py . again: it writes the Scripts/rpm.py shim now that the block is there.
  3. python3 Scripts/rpm.py spec, then python3 Scripts/rpm.py build, then look at what came out (rpm -qpl, rpm -qpR).
  4. Anything the program loads that is not a linked library goes into requires; rpmbuild finds linked libraries by itself, but not
    • QML modules a Qt program imports (rpm -qf /usr/lib64/qt6/qml/<module>/qmldir names the package),
    • a .NET runtime (dotnet-runtime-10.0) or a helper program it calls,
    • the libraries a Rust GUI opens at run time (winit's Wayland and EGL): strings target/release/<bin> | grep -oE 'lib[a-z0-9_-]+\.so\.[0-9]+' lists them; write them as libwayland-client.so.0()(64bit) so dnf picks the package.
  5. A window on Wayland gets its icon through its app id: name the desktop file and the icon after it.

The build commands lay the files out in a staging tree as they will sit under /; rpm.py writes a minimal spec around that tree and runs rpmbuild.

# Rust: the binary, version from Cargo.toml
[rpm]
name = "mytool"
summary = "One line on what it does"
license = "MIT"
url = "https://github.com/you/mytool"
version_file = "Cargo.toml"
build = ["cargo build --release --locked"]
files = { "target/release/mytool" = "/usr/bin/mytool" }

# CMake / KDE: a build directory of its own with prefix /usr, installed into the stage
[rpm]
name = "myapp"
summary = "..."
license = "GPL-3.0-or-later"
version_file = "CMakeLists.txt"
build = [
    "cmake -S . -B build/rpm -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_TESTING=OFF",
    "cmake --build build/rpm",
    "DESTDIR={stage} cmake --install build/rpm",
]
requires = ["kf6-kirigami", "kf6-qqc2-desktop-style"]

# .NET: framework-dependent publish into its own folder, a link in /usr/bin, the runtime from Fedora
[rpm]
name = "mytool"
summary = "..."
license = "MIT"
version_file = "src/MyTool/MyTool.csproj"
build = ["dotnet publish src/MyTool -c Release --self-contained false -o {stage}/usr/lib/mytool"]
links = { "/usr/bin/mytool" = "/usr/lib/mytool/MyTool" }
requires = ["dotnet-runtime-10.0"]

Several packages from one project: one [rpm.packages.NAME] table each, the keys of [rpm] are their defaults (istar-wheelstar builds the app and a Proton game plugin that way). Scriptlets are post, preun and postun. A scriptlet runs as root: one that acts on what users own (their Steam libraries, say) does it as them with runuser, never as root on paths read from their files.

Host your own repository

An RPM repository is nothing but a directory: the packages and a repodata/ folder that createrepo_c writes. Any web server can serve it. What rpm.py publish adds is the way in: it copies the new packages to the server over ssh and runs a script there that signs them and rebuilds repodata/.

your PC                                          the server
python3 Scripts/rpm.py publish                   ~/rpm-repo/
  build, stage, package                            incoming/          <- scp
  scp to server:rpm-repo/incoming/   ------->      publish.sh         <- ssh runs it: sign, move, createrepo_c
  ssh server rpm-repo/publish.sh                   repo/              <- the web server serves this, read-only
                                                     packages/*.rpm
every PC: sudo dnf upgrade  <--- https ------        repodata/
                                                     RPM-GPG-KEY-mine
                                                     mine.repo

On the server

Any Linux machine you reach with ssh; the commands are Fedora's, run as an ordinary user.

sudo dnf install rpm-sign createrepo_c
mkdir -p ~/rpm-repo/incoming ~/rpm-repo/repo/packages
curl -o ~/rpm-repo/publish.sh https://raw.githubusercontent.com/Istarlabs/devscripts/master/ops/rpm-repo/publish.sh
chmod +x ~/rpm-repo/publish.sh

publish.sh signs every package in incoming/, refuses one that carries no signature afterwards, copies it into repo/packages/ and runs createrepo_c --update. Old releases stay.

The signing key. RPM signatures are OpenPGP. Make a key that can only sign, on the server and only there:

gpg --batch --passphrase '' --quick-gen-key "RPM Signing" rsa4096 sign 3y
gpg --armor --export "RPM Signing" > ~/rpm-repo/repo/RPM-GPG-KEY-mine
gpg --list-secret-keys "RPM Signing"      # note the fingerprint: clients compare it on first install

No passphrase, because publish.sh runs unattended over ssh; what protects the key is that nobody else can read the server user's ~/.gnupg. A key under another name or in another GnuPG home: RPM_SIGNING_KEY and RPM_GNUPGHOME in ~/rpm-repo/publish.env.

The web server. Anything that serves static files will do. Rootless with podman and a Quadlet, as ~/.config/containers/systemd/rpm-repo.container:

[Unit]
Description=RPM repository
After=network-online.target
Wants=network-online.target

[Container]
Image=docker.io/library/nginx:alpine
ContainerName=rpm-repo
AutoUpdate=registry
PublishPort=8094:80
Volume=%h/rpm-repo/repo:/usr/share/nginx/html:ro,Z

[Service]
Restart=always

[Install]
WantedBy=default.target
systemctl --user daemon-reload && systemctl --user start rpm-repo
loginctl enable-linger "$USER"            # keeps it running without a login session

nginx's default configuration is fine; dnf needs no directory listing. Put it behind your reverse proxy for a name and HTTPS (https://packages.home.example), or use http://server:8094/ on the LAN - see HTTP or HTTPS.

The .repo file for the clients, as ~/rpm-repo/repo/mine.repo:

[mine]
name=My packages
baseurl=https://packages.home.example/
enabled=1
gpgcheck=1
gpgkey=https://packages.home.example/RPM-GPG-KEY-mine
metadata_expire=5m

metadata_expire=5m, so a new release shows up within minutes instead of a day.

On your PC

An ssh alias for the server in ~/.ssh/config (key login, no password prompt), then tell rpm.py where the repository is, per project or once for all:

[rpm]
repository = "server:rpm-repo"            # ssh alias : directory, relative to the home directory there
export DEVSCRIPTS_RPM_REPOSITORY=server:rpm-repo   # or this, for every project
python3 Scripts/rpm.py publish --dry-run           # build, say what would be sent, send nothing
python3 Scripts/rpm.py publish

publish sends only what changed: a package whose files, links and spec are the same as the last one sent from this machine (~/.cache/devscripts/rpm/published.json) is neither packaged nor sent; --force sends it anyway.

On every PC that installs

sudo curl -o /etc/yum.repos.d/mine.repo https://packages.home.example/mine.repo
sudo dnf install istar-gamescripts
dnf list --repo=mine --available           # everything the repository has

The first install asks to import the key: compare the fingerprint with gpg --list-secret-keys "RPM Signing" on the server. Updates come with the normal sudo dnf upgrade.

HTTP or HTTPS

gpgcheck=1 checks every package against your key, so nobody between server and client can slip in a package of their own, even over plain HTTP. The metadata is not signed, though: someone on the path could hold back updates or offer an older release. On a LAN you trust, HTTP is fine; anything beyond it gets HTTPS. With a certificate from your own CA, every client has to trust that CA system-wide (/etc/pki/ca-trust/source/anchors/, then sudo update-ca-trust), or dnf refuses the address.

When the key runs out

gpg --quick-set-expire <fingerprint> 3y on the server extends it and keeps the fingerprint, but every client holds the old copy, which says it has expired. Export it into the repository again and import it on each client:

gpg --armor --export "RPM Signing" > ~/rpm-repo/repo/RPM-GPG-KEY-mine                # on the server
sudo rpmkeys --import https://packages.home.example/RPM-GPG-KEY-mine                  # on every client

Put the expiry date in your calendar, or let a monthly timer warn you ninety days ahead.

Traps

  • 403 from nginx although the file is there (SELinux). The repository directory carries the label podman's :Z gave it. A file moved in with mv keeps the label of where it came from, one written with install gets the policy default, and nginx may read neither. publish.sh copies and then takes the directory's label with chcon --reference; a file put there by hand needs the same.
  • The volume options are comma-separated: :ro,Z, not :ro:Z, which podman rejects as incorrect volume format.
  • Could not set GPG_TTY to stdin from rpmsign over ssh is harmless; publish.sh filters it.
  • The old copy in ~/.local wins over the package, see above.
  • refused: no repository to publish to: neither repository in [rpm] nor DEVSCRIPTS_RPM_REPOSITORY is set.

Clone this wiki locally