rpmbuild8
Build rpm package(s)
Usage
Building packages
rpmbuild {-ba | -bb | -bp | -bf | -bc | -bi | -bl | -bs | -br | -bd}
[rpmbuild-options]
SPECFILE ...
rpmbuild {-ra | -rb | -rp | -rf | -rc | -ri | -rl | -rs | -rr | -rd}
[rpmbuild-options]
SOURCEPACKAGE ...
rpmbuild {-ta | -tb | -tp | -tf | -tc | -ti | -tl | -ts | -tr | -td}
[rpmbuild-options]
TARBALL ...
rpmbuild {--rebuild | --recompile}
SOURCEPKG ...
Miscellaneous
rpmbuild --showrc
Overview
rpmbuild is used to build both binary and source software packages. 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.
One of the following basic modes must be selected: Build Package, Build Package from Tarball, Recompile Package, Show Configuration.
General options
These options can be used in all the different modes.
-
-?, --help -
Print a longer usage message then normal.
-
--version -
Print a single line containing the version number of
rpmbeing used.
-
--quiet -
Print as little as possible - normally only error messages will be displayed.
-
-v -
Print verbose information - normally routine progress messages will be displayed.
-
-vv -
Print lots of ugly debugging information.
-
--rpmfcdebug -
Enables to debug dependencies generation.
-
--rcfile FILELIST -
Replace default list of configuration files to be read with FILELIST. See rpmrc Configuration in rpm(8) for details.
-
--load FILE -
Load an individual macro file.
-
--macros FILELIST -
Replace the list of macro files to be loaded with FILELIST. See Macro Configuration in rpm(8) for details.
-
--pipe CMD -
Pipes the output of
rpmto the command CMD.
-
--dbpath DIRECTORY -
Use the database in DIRECTORY rather than the default path /var/lib/rpm.
-
--root DIRECTORY -
Use the file system tree rooted at DIRECTORY for all operations. Note that this means the database within DIRECTORY will be used for dependency checks and any scriptlet(s) (e.g.
%postif installing, or%prepif building, a package) will be run after a chroot(2) to DIRECTORY.
- -D, --define='MACRO EXPR'
-
Defines MACRO with value EXPR.
-
--scm=SCM -
Select the SCM to use with
%autosetup, if one is not set in the spec file. Note that not all values for SCM, e.g.,patch(the default) andgendiff,git, orquiltwork interchangeably with all other patches and options stated in the %autosetup line, especially option-pN.
Build options
The general form of an rpm(8) build command is
rpmbuild {-bSTAGE|-rSTAGE|-tSTAGE} [rpmbuild-options] FILE ...
The argument used is -b if a spec file is being used to build the package, -r if a source package is to be rebuilt and -t if rpmbuild should look inside of a (possibly compressed) tar file for the spec file to use.
Packages are built in a number of stages. The first six correspond to the following sections in a spec file: %prep, %generate_buildrequires, %build, %install, %check and %clean. Finally, binary and source packages are created in an assembly stage.
The STAGE character specifies the stage to finish with (after doing all the stages preceding it), and is one of:
-
-ba -
Perform a full build - executes up to and including the assembly stage. In most cases, this is the option to choose.
-
-bb -
Build just the binary packages - executes up to and including the assembly stage, but without creating the source package. On success, the build directory is removed (as in
--clean).
-
-bp -
Unpack the sources and apply any patches - executes the
%prepstage only.
-
-bf -
Configure the sources - executes up to and including the %conf stage. This generally involves the equivalent of a "
./configure".
-
-bc -
Compile the sources - executes up to and including the
%buildstage. This generally involves the equivalent of "make".
-
-bi -
Install the binaries into the build root - executes up to and including the
%checkstage. This generally involves the equivalent of a "makeinstall" and "make check".
-
-bl -
Do a "list check" - the
%filessection from the spec file is macro expanded, and checks are made to verify that each file exists.
-
-bs -
Build just the source package - skips straight to the assembly stage, without executing any of the preceding stages or creating binary packages.
-
-br -
Build just the source package, but also parse and include dynamic build dependencies - executes up to and including the
%generate_buildrequiresstage and then skips straight to the assembly stage, without creating binary packages. This command can be used to fully resolve dynamic build dependencies. See the DYNAMIC BUILD DEPENDENCIES section for details.
-
-bd -
Check dynamic build dependencies and build the .buildreqs.nosrc.rpm package if any are missing. Don’t build anything else.
The following options may also be used:
--buildrootDIRECTORY (DEPRECATED)-
When building a package, override the buildroot of rpmbuild(8) to DIRECTORY. This option is deprecated and will be removed in the future, do not introduce new usages.
-
--clean -
Remove the build tree after the packages are made.
-
--nobuild -
Do not execute any build stages. Useful for testing out spec files.
-
--noprep -
Do not execute
%prepbuild stage even if present in spec.
-
--noclean -
Do not execute
%cleanbuild stage even if present in spec.
-
--nocheck -
Do not execute
%checkbuild stage even if present in spec.
-
--nodebuginfo -
Do not generate debuginfo packages.
-
--nodeps -
Do not verify build dependencies.
-
--rmsource -
Remove the sources after the build (may also be used standalone, e.g. "
rpmbuild--rmsource foo.spec").
-
--rmspec -
Remove the spec file after the build (may also be used standalone, e.g. "
rpmbuild--rmspec foo.spec").
-
--short-circuit -
Skip straight to specified stage (i.e., skip all stages leading up to the specified stage). Only valid with
-bc,-bi, and-bb. Useful for local testing only. Packages built this way will be marked with an unsatisfiable dependency to prevent their accidental use.
-
--build-in-place -
Build from locally checked out sources in the current working directory. The build tree is set up as if
%setupwas used, but %builddir/%buildsubdir points back to the current working directory.%prepis skipped entirely.
-
--target PLATFORM -
When building the package, interpret PLATFORM as
arch-vendor-osand set the macros%_target,%_target_cpu, and%_target_osaccordingly.
-
--with OPTION -
Enable configure OPTION for build.
-
--without OPTION -
Disable configure OPTION for build.
Rebuild and recompile options
There are two other ways to invoke building with rpm(8):
rpmbuild --rebuild|--recompile SOURCEPKG ...
When invoked this way, rpmbuild installs the named source package, and does a prep, compile and install. In addition, --rebuild builds a new binary package. When the build has completed, the build directory is removed (as in --clean) and the the sources and spec file for the package are removed.
These options are now superseded by the -r* options which allow much more fine control over what stages of the build to run.
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 command is coupled with --nodeps, exit code 11 is always returned and a buildreqs.nosrc.rpm package is always created.
Showrc
The command
rpmbuild --showrc
shows the values rpmbuild will use for all of the options are currently set in rpmrc and macros configuration file(s).
Files
See rpm(8)
Releases
12 releases since Debian 3.0 (Woody); the text changed 10 times.
--build-in-place since Debian 10 (Buster);
--load since Debian 13 (Trixie);
--macros since Debian 13 (Trixie);
--nocheck since Debian 8 (Jessie);
--noclean since Debian 8 (Jessie);
--nodebuginfo since Debian 10 (Buster);
--nodeps since Debian 6.0 (Squeeze);
--noprep since Debian 10 (Buster);
--rpmfcdebug since Debian 10 (Buster);
--scm since Debian 11 (Bullseye);
--with since Debian 10 (Buster);
--without since Debian 10 (Buster);
-bd since Debian 12 (Bookworm);
-bf since Debian 12 (Bookworm);
-br since Debian 11 (Bullseye).
--all until Debian 3.0 (Woody);
--allfiles until Debian 3.0 (Woody);
--allmatches until Debian 3.0 (Woody);
--badreloc until Debian 3.0 (Woody);
--buildroot until Debian 12 (Bookworm);
--changelog until Debian 3.0 (Woody);
--configfiles until Debian 3.0 (Woody);
--docfiles until Debian 3.0 (Woody);
--dump until Debian 3.0 (Woody);
--excludedocs until Debian 3.0 (Woody);
--excludepath until Debian 3.0 (Woody);
--file until Debian 3.0 (Woody);
--filesbypkg until Debian 3.0 (Woody);
--force until Debian 3.0 (Woody);
--ftpport until Debian 3.0 (Woody);
--ftpproxy until Debian 3.0 (Woody);
--group until Debian 3.0 (Woody);
--hash until Debian 3.0 (Woody);
--httpport until Debian 3.0 (Woody);
--httpproxy until Debian 3.0 (Woody);
--ignorearch until Debian 3.0 (Woody);
--ignoreos until Debian 3.0 (Woody);
--ignoresize until Debian 3.0 (Woody);
--includedocs until Debian 3.0 (Woody);
--info until Debian 3.0 (Woody);
--justdb until Debian 3.0 (Woody);
--last until Debian 3.0 (Woody);
--list until Debian 3.0 (Woody);
--nofiles until Debian 3.0 (Woody);
--nomd5 until Debian 3.0 (Woody);
--noorder until Debian 3.0 (Woody);
--nopost until Debian 3.0 (Woody);
--nopostun until Debian 3.0 (Woody);
--nopre until Debian 3.0 (Woody);
--nopreun until Debian 3.0 (Woody);
--noscripts until Debian 3.0 (Woody);
--notriggerin until Debian 3.0 (Woody);
--notriggerpostun until Debian 3.0 (Woody);
--notriggers until Debian 3.0 (Woody);
--notriggerun until Debian 3.0 (Woody);
--oldpackage until Debian 3.0 (Woody);
--package until Debian 3.0 (Woody);
--percent until Debian 3.0 (Woody);
--prefix until Debian 3.0 (Woody);
--provides until Debian 3.0 (Woody);
--querybynumber until Debian 3.0 (Woody);
--relocate until Debian 3.0 (Woody);
--repackage until Debian 3.0 (Woody);
--replacefiles until Debian 3.0 (Woody);
--replacepkgs until Debian 3.0 (Woody);
--requires until Debian 3.0 (Woody);
--scripts until Debian 3.0 (Woody);
--sign until Debian 6.0 (Squeeze);
--specfile until Debian 3.0 (Woody);
--state until Debian 3.0 (Woody);
--test until Debian 3.0 (Woody);
--triggeredby until Debian 3.0 (Woody);
--triggers until Debian 3.0 (Woody);
--triggerscripts until Debian 3.0 (Woody);
--whatprovides until Debian 3.0 (Woody);
--whatrequires until Debian 3.0 (Woody);
-R until Debian 3.0 (Woody);
-a until Debian 3.0 (Woody);
-c until Debian 3.0 (Woody);
-d until Debian 3.0 (Woody);
-f until Debian 3.0 (Woody);
-g until Debian 3.0 (Woody);
-h until Debian 3.0 (Woody);
-i until Debian 3.0 (Woody);
-l until Debian 3.0 (Woody);
-p until Debian 3.0 (Woody);
-s until Debian 3.0 (Woody).