rpmbuild(8)
Build RPM packages from source code and spec files.
Synopsis
rpmbuild [OPTION]... STAGE [FILE]...Description
rpmbuild is used to build RPM binary and source packages from source code. It reads a spec file describing the package and executes the necessary build steps: unpacking sources, applying patches, compiling, installing, and creating the final RPM archives.
The tool supports multiple build stages, from preparing sources (-bp) through creating binary (-bb) and source (-bs) packages. It requires a properly formatted .spec file that defines build dependencies, compilation steps, and package metadata.
Common options
| Flag | What it does |
|---|---|
-ba | Build both binary and source RPM packages |
-bb | Build only the binary RPM package |
-bs | Build only the source RPM package (SRPM) |
-bp | Execute only the prep stage (unpack and patch sources) |
-bc | Execute up through the compile stage |
-bi | Execute up through the install stage |
--define MACRO VALUE | Define a macro variable for use in the spec file |
-D 'MACRO VALUE' | Define a macro with whitespace in the value |
--with FEATURE | Enable a conditional feature (bcond_with) |
--without FEATURE | Disable a conditional feature (bcond_without) |
-v | Verbose output showing build progress |
--clean | Remove build directory after successful build |
Examples
Build both binary and source RPMs from mypackage.spec in the current directory
rpmbuild -ba mypackage.specBuild only a binary RPM package from the httpd spec file
rpmbuild -bb ~/rpmbuild/SPECS/httpd.specBuild a source RPM with a custom dist tag for EL8
rpmbuild -bs package.spec --define 'dist .el8'Build with debug support enabled and test suite disabled
rpmbuild -bb package.spec --with debug --without testsPrepare sources by unpacking and applying patches without compiling
rpmbuild -bp package.specBuild with verbose output and capture entire log to a file
rpmbuild -v -ba package.spec 2>&1 | tee build.logBuild using a custom RPM workspace directory instead of ~/rpmbuild
rpmbuild -bb --define '_topdir /custom/rpm' package.specRebuild a binary package from a source RPM (SRPM)
rpmbuild --rebuild package-1.0-1.src.rpm