Linux 命令之 rpmbuild -- 用于创建 rpm 格式的二进制软件包和源码软件包

一、命令介绍

命令 rpmbuild 用于创建 RPM 软件包和 SRPM 软件包,这两类软件包分别是 rpm 格式的二进制软件包和源码软件包

二、命令选项

Build options with [ <specfile> | <tarball> | <source package> ]

中文译为:通过配置文件或 tar.gz 格式的源码包或者 rpm 格式的源码包来构建

(一)从 specfile 建立

选项说明
-bpbuild through %prep (unpack sources and apply patches) from <specfile>.
译文:从 specfile 文件的 %prep 开始建立(解开源码包并打补丁),只作准备,解压与打补丁
-bcbuild through %build (%prep, then compile) from <specfile>.
译文:从文件的 %build 开始建立(解开源码包、打补丁、编译)
-bibuild through %install (%prep, %build, then install) from <specfile>
译文:从文件的 %install 开始建立(解开源码包、打补丁、编译、安装)
-blverify %files section from <specfile>.
译文:检查文件的 %files 段,检验文件是否齐全
-babuild source and binary packages from <specfile>.
译文:创建源码包(SRPM)和二进制包(RPM)
-bbbuild binary package only from <specfile>.
译文:只构建二进制包
-bsbuild source package only from <specfile>.
译文:只建立源码包(SRPM)

(二)从 tarball 包建立

这个 tarball 应该是以 .tar 为后缀名的包。

选项说明
-tpbuild through %prep (unpack sources and apply patches) from <tarball>.
译文:从 tar 包的 %prep 开始构建(解开源码包并打补丁)
-tcbuild through %build (%prep, then compile) from <tarball>.
译文:从 tar 包的 %build 开始建立(解开源码包、打补丁、编译)
-tibuild through %install (%prep, %build, then install) from <tarball>.
译文:从 tar 包的 %install 开始建立(解开源码包、打补丁、编译、安装)
-tabuild source and binary packages from <tarball>.
译文:从 tar 包建立源码包和二进制包
-tbbuild binary package only from <tarball>.
译文:只建立二进制包
-tsbuild source package only from <tarball>.
译文:只建立源码包

(三)从 source package 包建立

这个源码包,应该是以 .tar.gz 为后缀名的包。

选项说明
--rebuildbuild binary package from <source package>.
译文:基于源码包建立二进制包(*.rpm)
--recompilebuild through %install (%prep, %build, then install) from <source package>.
译文:基于源码包的 %install 开始建立(解开源码包、打补丁、编译、安装)

(四)其它选项

选项说明
--buildroot<DIRECTORY>override build root. 重写生成根目录
--cleanremove build tree when done. 完成打包后清除 BUILD下的文件目录
--nobuilddo not execute any stages of the build. 不进行 BUILD 的阶段
--nodepsdo not verify build dependencies. 不检查建立包时的关联文件
--nodirtokensgenerate package header(s) compatible with (legacy) rpm[23] packaging. 生成与(传统)rpm[23]打包兼容的包头
--rmsourceremove sources when done. 完成打包后清除 sources
--rmspecremove specfile when done. 完成打包后清除 specfile
--short-circuitskip straight to specified stage (only for c,i). 直接跳到指定的阶段(仅适用于c、i)
--target<CPU-VENDOR-OS>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<filename>read instead of default file(s). 读取而不是默认文件
--nodigestdon’t verify package digest(s). 不验证包摘要,不检查包的说明信息
--nosignaturedon’t verify package signature(s). 不检查包的签名信息
--rcfile<filename>read instead of default file(s). 读 文件代替默认文件
-r 或 --root<ROOT>use ROOT as top level directory (default: “/”). 使用根目录作为顶级目录(默认值:“/”)
--querytagsdisplay known query tags. 显示已知查询标记
--showrcdisplay final rpmrc and macro configuration. 显示最终的rpmrc和宏配置
--quietprovide less detailed output. 提供不太详细的输出
-v 或 --verboseprovide more detailed output. 提供大量的详细的信息
--versionprint 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.

选项说明
-? 或 --helpShow this help message. 显示帮助信息
--usageDisplay brief usage message. 显示使用方法的信息

三、命令示例

(一)根据配置文件对源码包进一步解压,得到最终的源码文件

这个最终的源码文件应该是存放在目录 BUILD 下。

先切换到目录 SPECS 下:

[root@localhost ~]# cd /root/rpmbuild/SPECS

选项 -bp 会根据配置文件对 SOURCES 目录下源码包进一步解压:

rpmbuild -bp httpd.specs             

欲了解命令 rpmbuild 在安装 SRPM 软件包的实际使用,猛戳《Linux 如何安装 SRPM 包

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值