RPMBUILD(8)

๐Ÿ“ฆ
version 4.20.1 ยท 5 versions
, in debian trixie, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing

๐Ÿ’… 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 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 rpm to 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. %post if installing, or %prep if building, a package) will be run after a chroot(2) to DIRECTORY. lowkey a big deal.
  • -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) and gendiff, git, or quilt work interchangeably with all other patches and options stated in the %autosetup line, 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 %prep stage 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 %build stage. this generally involves the equivalent of "make".
  • -bi โ€” install the binaries into the build root โ€” executes up to and including the %check stage. this generally involves the equivalent of a "make install" and "make check".
  • -bl โ€” do a "list check" โ€” the %files section 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_buildrequires stage 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. just vibes and dependency checking โœจ

the following options may also be used:

  • --buildroot DIRECTORY (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. 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 %prep build stage even if present in spec.
  • --noclean โ€” do not execute %clean build stage even if present in spec.
  • --nocheck โ€” do not execute %check build 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 %setup was used, but %builddir/%buildsubdir points back to the current working directory. %prep is skipped entirely. she skips prep. she's built different ๐Ÿฆ‹
  • --target PLATFORM โ€” when building the package, interpret PLATFORM as arch-vendor-os and set the macros %_target, %_target_cpu, and %_target_os accordingly.
  • --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. (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. โœจ๐Ÿ’…๐ŸŽ€