| RPMBUILD(1) | General Commands Manual | RPMBUILD(1) |
NAME¶
rpmbuild - Build RPM Package(s)
SYNOPSIS¶
rpmbuild -bSTAGE [options] SPEC_FILE ...
rpmbuild -rSTAGE [options] SOURCE_PACKAGE ...
rpmbuild -tSTAGE [options] TAR_ARCHIVE ...
rpmbuild {--rebuild|--recompile} [options] SOURCE_PACKAGE ...
DESCRIPTION¶
rpmbuild is used to build software packages in the RPM format, in an automated and repeatable manner.
A package consists of an archive of files and meta-data used to install and erase the archive files. The meta-data includes helper scripts, file attributes, and descriptive information about the package.
Packages come in two varieties: binary packages, used to encapsulate software to be installed, and source packages, containing the source code and recipe necessary to produce binary packages.
OPERATIONS¶
-bSTAGE
-rSTAGE
-tSTAGE
--rebuild, --recompile
Packages are built in four phases: parse, build, assembly and cleanup. The middle two are further divided into stages, listed below, which can be built separately. Building a STAGE means executing all the preceding stages up to (and including) the one specified, unless stated otherwise.
Assembly stages¶
The assembly stages produce packages and are the primary way of interacting with rpmbuild. If in doubt, choose one of these.
a
b
r
s
Build stages¶
The build stages produce the artifacts to be packaged, typically by patching and compiling the sources, and installing the binaries into the buildroot. These stages generally correspond to spec sections such as %prep, %build or %install, but there are some which are implicit.
Building these stages separately is generally only useful when packaging new software in RPM format and/or troubleshooting. They are listed below in the order of execution, with the corresponding spec section in parenthesis where applicable.
p (%prep)
d (%generate_buildrequires)
f (%conf)
c (%build)
i (%install and %check)
l
ARGUMENTS¶
SPEC_FILE
SOURCE_PACKAGE
TAR_ARCHIVE
OPTIONS¶
--build-in-place
--clean
--nobuild
--nocheck
--noclean
--nodebuginfo
--nodeps
--noprep
--rmsource
--rmspec
--rpmfcdebug
--scm=SCM
--short-circuit
--with OPTION
--without OPTION
See rpm-common(8) for the options common to all operations.
DYNAMIC BUILD DEPENDENCIES¶
When the %generate_buildrequires stage runs and some of the newly generated BuildRequires are not satisfied, rpmbuild creates an intermediate source package ending in buildreqs.nosrc.rpm, which has the new BuildRequires, and exits with code 11. This package can then be used in place of the original source package to resolve and install the missing build dependencies in the usual way, such as with dnf-builddep(8).
Multiple layers of dynamic build dependencies may exist in a spec file; the presence of specific BuildRequires on the system may yield new BuildRequires next time a build is performed with the same source package. The easiest way to ensure that all dynamic build dependencies are satisfied is to run the -br option, install the new dependencies of the buildreqs.nosrc.rpm package and repeat the whole procedure until rpmbuild no longer exits with code 11.
If the -br option is coupled with --nodeps, exit code 11 is always returned and a buildreqs.nosrc.rpm package is always created.
ENVIRONMENT¶
RPM_BUILD_NCPUS
EXIT STATUS¶
On success, 0 is returned, a non-zero failure code otherwise.
Packages with a %generate_buildrequires section will return with code 11 when there are unmet DYNAMIC BUILD DEPENDENCIES.
EXAMPLES¶
rpmbuild --rebuild hello-1.0-1.src.rpm
rpmbuild -bb --nocheck --with openssl hello.spec
rpmbuild -ta hello-2.0.tar.gz
rpmbuild -bc hello.spec
rpmbuild -bi --short-circuit hello.spec
FILES¶
See rpm-common(8)
SEE ALSO¶
gendiff(1), popt(3), rpm(8), rpm-common(8), rpmbuild-config(5), rpm2cpio(1), rpmkeys(8), rpmspec(1), rpmsign(1), rpm-setup-autosign(1) rpm-macros(7)
| 2025-11-07 | RPM 6.0.0 |