RPMBUILD(8)
๐ RPMBUILD โ bestie edition ๐
okay so you wanna build RPM packages? say less. this is the rpmbuild(8) manual page and i'm gonna walk you through it like we're texting at 2am, except every single flag stays exactly where it belongs. no cap. ๐ซถ
โจ NAME โจ
rpmbuild โ Build RPM Package(s). that's it, that's the whole vibe. building packages. iconic behaviour honestly. ๐
๐ธ SYNOPSIS ๐ธ
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
rpmbuild-options ๐
[--buildroot DIRECTORY] [--clean] [--nobuild] [--rmsource] [--rmspec]
[--short-circuit] [--build-in-place] [--noprep] [--noclean] [--nocheck]
[--rpmfcdebug] [--target PLATFORM] [--with OPTION] [--without OPTION]
๐ฆ DESCRIPTION ๐ฆ
so rpmbuild is the tool you use to build both binary and source software packages. a package is basically an archive of files plus meta-data โ and that meta-data is what lets you install and erase the archive files. the meta-data includes helper scripts, file attributes, and descriptive info about the package. it's giving โจorganisedโจ.
packages come in two flavours:
- binary packages โ the ones used to encapsulate software to be installed
- source packages โ the ones containing the source code and the recipe necessary to produce binary packages
you must pick one of the following basic modes: Build Package, Build Package from Tarball, Recompile Package, Show Configuration. pick one bestie, you can't do all of them at once ๐
๐ GENERAL OPTIONS ๐
these ones work in all the different modes, so they're like the universal besties of the option world.
-?,--helpโ prints a longer usage message than normal. go off.--versionโ prints a single line with the version number of rpm being used. one line. very minimal. we love her.--quietโ print as little as possible โ normally only error messages get displayed. ๐คซ-vโ print verbose information โ normally routine progress messages will be displayed.-vvโ print lots of ugly debugging information. it's a lot. it's ugly. it's information. ๐--rpmfcdebugโ enables you to debug dependencies generation.--rcfile FILELISTโ replace the default list of configuration files to be read withFILELIST. see rpmrc Configuration inrpm(8)for details.--load FILEโ load an individual macro file.--macros FILELISTโ replace the list of macro files to be loaded withFILELIST. see Macro Configuration inrpm(8)for details.--pipe CMDโ pipes the output of rpm to the commandCMD.--dbpath DIRECTORYโ use the database inDIRECTORYrather than the default path/var/lib/rpm.--root DIRECTORYโ use the file system tree rooted atDIRECTORYfor all operations. note that this means the database withinDIRECTORYwill be used for dependency checks, and any scriptlet(s) (e.g.%postif installing, or%prepif building, a package) will be run after achroot(2)toDIRECTORY. lowkey a big deal.-D,--define='MACRO EXPR'โ definesMACROwith valueEXPR.--scm=SCMโ select the SCM to use with%autosetup, if one is not set in the spec file. note that not all values forSCM, e.g.,patch(the default) andgendiff,git, orquiltwork interchangeably with all other patches and options stated in the%autosetupline, especially option-pN. so likeโฆ don't just assume they're swappable bestie ๐
๐ฅ 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. three flavours, one queen ๐
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. the main character of options fr fr ๐-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%confstage. 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"make install"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.rpmpackage if any are missing. don't build anything else. just vibes and dependency checking โจ
the following options may also be used:
--buildroot DIRECTORY(DEPRECATED) โ when building a package, override the buildroot ofrpmbuild(8)toDIRECTORY. this option is deprecated and will be removed in the future, do not introduce new usages. bestie. i'm begging you. don't start using it now ๐--cleanโ remove the build tree after the packages are made.--nobuildโ do not execute any build stages. useful for testing out spec files. very "i'm just looking, not buying" energy.--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. so like, they're marked. don't ship them. periodt.--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/%buildsubdirpoints back to the current working directory.%prepis skipped entirely. she skips prep. she's built different ๐ฆ--target PLATFORMโ when building the package, interpretPLATFORMasarch-vendor-osand set the macros%_target,%_target_cpu, and%_target_osaccordingly.--with OPTIONโ enable configureOPTIONfor build.--without OPTIONโ disable configureOPTIONfor 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. (yes, the original says "the the". we're keeping it. it's a whole vibe. ๐)
these options are now superseded by the-r*options which allow much more fine control over what stages of the build to run. so like, they still work, but the-r*girls are the moment now.
๐ง 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. it's giving โจloop until it stops yelling at youโจ
if the -br command is coupled with --nodeps, exit code 11 is always returned and a buildreqs.nosrc.rpm package is always created. always. no exceptions bestie.
โญ 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). that's it. go read that one, she has the file deets ๐
๐ SEE ALSO ๐
gendiff(1), popt(3), rpm(8), rpm2cpio(8), rpmkeys(8), rpmspec(8), rpmsign(8)
rpmbuild --help โ as rpm supports customizing the options via popt aliases it's impossible to guarantee that what's described in the manual matches what's available. so like, the manual is a vibe guide, not a legal contract ๐
http://www.rpm.org/ <URL:http://www.rpm.org/>
๐ AUTHORS ๐
the literal legends who made this happen:
- Marc Ewing
<marc@redhat.com> - Jeff Johnson
<jbj@redhat.com> - Erik Troan
<ewt@redhat.com>
and that's the whole page bestie ๐ซถ this one's from 09 June 2002, and it's the RPMBUILD(8) manual โ go build something iconic. slay. โจ๐
๐
๐ฆ where this page comes from
- debian trixie: rpm 4.20.1+dfsg-3 ยท GPL-2.0-or-later
- nixpkgs unstable: rpm 4.20.1
- opensuse-leap 16.0: rpm 4.20.1-160000.4.1 ยท GPL-2.0-or-later
- opensuse-leap 16.0: rpm 4.20.1-160000.4.1 ยท GPL-2.0-or-later
- opensuse-leap 16.0: rpm 4.20.1-160000.4.1 ยท GPL-2.0-or-later
- opensuse-leap 16.0: rpm 4.20.1-160000.4.1 ยท GPL-2.0-or-later
- ubuntu questing: rpm 4.20.1+dfsg-3
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms