← 返回命令列表

Linux command

rpmbuild 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Example

rpmbuild -ba path/to/spec_file

Example

rpmbuild -bb path/to/spec_file

Example

rpmbuild -bs path/to/spec_file

Example

rpmbuild -bb --define "version 1.0" path/to/spec_file

Prepare

rpmbuild -bp path/to/spec_file

Example

rpmbuild -bb --target x86_64 path/to/spec_file

Rebuild

rpmbuild --rebuild path/to/package.src.rpm

说明

rpmbuild builds both binary and source software packages from spec files. A package consists of an archive of files and metadata used to install and erase the archive files. The tool processes spec files through multiple build stages.

参数

-ba
Build binary and source packages
-bb
Build binary packages only
-bp
Unpack sources and apply patches only (%prep stage)
-bf
Configure the sources (%conf stage, equivalent to ./configure)
-bc
Compile sources (%build stage)
-bi
Install binaries into the build root and run %check
-bl
Verify that all files listed in %files exist
-bs
Build source package only
-br
Build source package with dynamic build dependency resolution
-bd
Check dynamic build dependencies and generate build requirements
-D, --define _'MACRO EXPR'_
Define a macro with value
--target _PLATFORM_
Set build target architecture (e.g. `x86_64`, `aarch64`)
--buildroot _DIRECTORY_
Override the build root directory
--clean
Remove build tree after completion
--nobuild
Skip all build stages (spec file syntax check only)
--noprep
Skip the %prep stage
--noclean
Skip the %clean stage
--nocheck
Skip the %check stage
--nodeps
Do not verify build dependencies
--short-circuit
Skip directly to the specified stage (usable with -bc, -bi, -bb only)
--rebuild _SOURCEPKG_
Install the source package, build binary packages, then clean up
--recompile _SOURCEPKG_
Like --rebuild but stops after the install stage without creating binary packages
--rmsource
Remove source files after build
--rmspec
Remove spec file after build

FAQ

What is the rpmbuild command used for?

rpmbuild builds both binary and source software packages from spec files. A package consists of an archive of files and metadata used to install and erase the archive files. The tool processes spec files through multiple build stages.

How do I run a basic rpmbuild example?

Run `rpmbuild -ba path/to/spec_file` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -ba do in rpmbuild?

Build binary and source packages