Skip to content
Latchkey

rpmbuild: Usage, Options & Common CI Errors

rpmbuild compiles a .spec recipe into binary and/or source RPM packages.

rpmbuild turns a .spec file into RPMs. Its two signature CI failures are the strict "Installed but unpackaged files" check (every installed file must be listed in %files) and missing BuildRequires.

What it does

rpmbuild executes the stages of an RPM .spec file - %prep, %build, %install, %check - inside a build root, then packages the staged files per the %files section into .rpm artifacts. It enforces that every installed file is accounted for.

Common usage

Terminal
rpmbuild -bb package.spec          # build binary RPM
rpmbuild -ba package.spec          # build binary + source RPM
rpmbuild -bs package.spec          # source RPM only
rpmbuild --define '_topdir %(pwd)/rpmbuild' -bb package.spec
rpmbuild -bb --nocheck package.spec   # skip %check

Options

FlagWhat it does
-bbBuild a binary package
-baBuild binary and source packages
-bsBuild a source package only
--define "k v"Set a macro (e.g. _topdir)
--nocheckSkip the %check stage
--buildroot <dir>Override the install staging root

Common errors in CI

"error: Installed (but unpackaged) file(s) found:" - something landed in the buildroot that %files does not list; add it (or use %exclude). "error: Failed build dependencies: foo is needed" - install BuildRequires first (dnf builddep package.spec). "File not found: ... %{buildroot}/..." means %install did not place an expected file. Set _topdir (the default ~/rpmbuild may not exist in CI). Use mock for clean, isolated, reproducible builds.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →