文章目录
一、命令介绍
- 一、命令介绍
- 二、命令选项
- (一)从
specfile
建立 - (二)从
tarball
包建立 - (三)从
source package
包建立 - (四)其它选项
- (五)所有 rpm 都可使用的选项
- (六)附加选项
- (七)帮助选项
- (一)从
- 三、命令示例
- (一)根据配置文件对源码包进一步解压,得到最终的源码文件
命令 rpmbuild
用于创建 RPM 软件包和 SRPM 软件包,这两类软件包分别是 rpm 格式的二进制软件包和源码软件包
Build options with [ | | ]
中文译为:通过配置文件或 tar.gz 格式的源码包或者 rpm 格式的源码包来构建
(一)从specfile
建立
选项说明-bpbuild through %prep (unpack sources and apply patches) from .
译文:从 specfile
文件的 %prep
开始建立(解开源码包并打补丁),只作准备,解压与打补丁-bcbuild through %build (%prep, then compile) from .
译文:从文件的 %build
开始建立(解开源码包、打补丁、编译)-bibuild through %install (%prep, %build, then install) from
译文:从文件的 %install
开始建立(解开源码包、打补丁、编译、安装)-blverify %files section from .
译文:检查文件的 %files
段,检验文件是否齐全-babuild source and binary packages from .
译文:创建源码包(SRPM)和二进制包(RPM)-bbbuild binary package only from .
译文:只构建二进制包-bsbuild source package only from .
译文:只建立源码包(SRPM)
(二)从 tarball
包建立
这个 tarball 应该是以 .tar
为后缀名的包。
build through %prep (unpack sources and apply patches) from .
译文:从 tar 包的 %prep
开始构建(解开源码包并打补丁)-tcbuild through %build (%prep, then compile) from .
译文:从 tar 包的 %build
开始建立(解开源码包、打补丁、编译)-tibuild through %install (%prep, %build, then install) from .
译文:从 tar 包的 %install
开始建立(解开源码包、打补丁、编译、安装)-tabuild source and binary packages from .
译文:从 tar 包建立源码包和二进制包-tbbuild binary package only from .
译文:只建立二进制包-tsbuild source package only from .
译文:只建立源码包
(三)从 source package
包建立
这个源码包,应该是以 .tar.gz
为后缀名的包。
--rebuild
build binary package from .
译文:基于源码包建立二进制包(*.rpm)--recompile
build through %install (%prep, %build, then install) from .
译文:基于源码包的 %install
开始建立(解开源码包、打补丁、编译、安装)
(四)其它选项
选项说明--buildroot
override build root. 重写生成根目录--clean
remove build tree when done. 完成打包后清除 BUILD下的文件目录--nobuild
do not execute any stages of the build. 不进行 BUILD 的阶段--nodeps
do not verify build dependencies. 不检查建立包时的关联文件--nodirtokens
generate package header(s) compatible with (legacy) rpm[23] packaging. 生成与(传统)rpm[23]打包兼容的包头--rmsource
remove sources when done. 完成打包后清除 sources--rmspec
remove specfile when done. 完成打包后清除 specfile--short-circuit
skip straight to specified stage (only for c,i). 直接跳到指定的阶段(仅适用于c、i)--target
override target platform. 覆盖目标平台,确定包的最终使用平台
(五)所有 rpm 都可使用的选项
Common options for all rpm modes.
选项说明-D 或 --define
define MACRO with value EXPR. 用值表达式定义宏-E 或 --eval
print macro expansion of EXPR. 打印表达式的宏扩展--macros
read instead of default file(s). 读取而不是默认文件--nodigest
don’t verify package digest(s). 不验证包摘要,不检查包的说明信息--nosignature
don’t verify package signature(s). 不检查包的签名信息--rcfile
read instead of default file(s). 读 文件代替默认文件-r 或 --root
use ROOT as top level directory (default: “/”). 使用根目录作为顶级目录(默认值:“/”)--querytags
display known query tags. 显示已知查询标记--showrc
display final rpmrc and macro configuration. 显示最终的rpmrc和宏配置--quiet
provide less detailed output. 提供不太详细的输出-v 或 --verbose
provide more detailed output. 提供大量的详细的信息--version
print the version of rpm being used. 显示rpm包的版本
(六)附加选项
Options implemented via popt alias/exec. 通过popt alias/exec实现的选项
选项说明--dbpath
use database in DIRECTORY. 使用目录中的数据库--with
enable configure for build. 建立时允许配置的选项--without
disable configure for build. 建立时不允许配置的选项
(七)帮助选项
Help options.
选项说明-? 或 --help
Show this help message. 显示帮助信息--usage
Display brief usage message. 显示使用方法的信息
三、命令示例
(一)根据配置文件对源码包进一步解压,得到最终的源码文件
这个最终的源码文件应该是存放在目录 BUILD 下。
先切换到目录 SPECS 下:
[root@localhost ~]# cd /root/rpmbuild/SPECS
选项 -bp
会根据配置文件对 SOURCES 目录下源码包进一步解压:
rpmbuild -bp httpd.specs
欲了解命令 rpmbuild
在安装 SRPM 软件包的实际使用,猛戳《Linux 如何安装 SRPM 包》