RPM包制作之rpmbuild命令说明

2018-11-30 21:30:00
赵勤松
原创
3893
摘要:RPM包是Linux中常见的安装包,使用方便,在此简单介绍使用rpmbuild软件来构建rpm包的方法

使用环境:CentOS 7.2


1.rpmbuild的安装

在CentOS中,可以使用yum直接安装,命令为


#yum install rpm-build


2.rpmbuild的参数


Usage: rpmbuild [OPTION...]
Build options with [ <specfile> | <tarball> | <source package> ]:
  -bp                           build through %prep (unpack sources and apply patches) from <specfile>
  -bc                           build through %build (%prep, then compile) from <specfile>
  -bi                           build through %install (%prep, %build, then install) from <specfile>
  -bl                           verify %files section from <specfile>
  -ba                           build source and binary packages from <specfile>
  -bb                           build binary package only from <specfile>
  -bs                           build source package only from <specfile>
  -tp                           build through %prep (unpack sources and apply patches) from <tarball>
  -tc                           build through %build (%prep, then compile) from <tarball>
  -ti                           build through %install (%prep, %build, then install) from <tarball>
  -ta                           build source and binary packages from <tarball>
  -tb                           build binary package only from <tarball>
  -ts                           build source package only from <tarball>
  --rebuild                     build binary package from <source package>
  --recompile                   build through %install (%prep, %build, then install) from <source package>
  --buildroot=DIRECTORY         override build root
  --clean                       remove build tree when done
  --nobuild                     do not execute any stages of the build
  --nodeps                      do not verify build dependencies
  --nodirtokens                 generate package header(s) compatible with (legacy) rpm v3 packaging
  --noclean                     do not execute %clean stage of the build
  --nocheck                     do not execute %check stage of the build
  --rmsource                    remove sources when done
  --rmspec                      remove specfile when done
  --short-circuit               skip straight to specified stage (only for c,i)
  --target=CPU-VENDOR-OS        override target platform
Common options for all rpm modes and executables:
  -D, --define='MACRO EXPR'     define MACRO with value EXPR
  --undefine=MACRO              undefine MACRO
  -E, --eval='EXPR'             print macro expansion of EXPR
  --macros=<FILE:...>           read <FILE:...> instead of default file(s)
  --noplugins                   don't enable any plugins
  --nodigest                    don't verify package digest(s)
  --nosignature                 don't verify package signature(s)
  --rcfile=<FILE:...>           read <FILE:...> instead of default file(s)
  -r, --root=ROOT               use ROOT as top level directory (default: "/")
  --dbpath=DIRECTORY            use database in DIRECTORY
  --querytags                   display known query tags
  --showrc                      display final rpmrc and macro configuration
  --quiet                       provide less detailed output
  -v, --verbose                 provide more detailed output
  --version                     print the version of rpm being used
Options implemented via popt alias/exec:
  --with=<option>               enable configure <option> for build
  --without=<option>            disable configure <option> for build
  --buildpolicy=<policy>        set buildroot <policy> (e.g. compress man pages)
  --sign                        generate GPG signature (deprecated, use command rpmsign instead)
Help options:
  -?, --help                    Show this help message
  --usage                       Display brief usage message


3.rpmbuild参数详解


编号 参数 说明
1
-bp 从spec文件中读取配置,并执行至%prep阶段
2 -bc
从spec文件中读取配置,并执行至%build阶段
3 -bi 从spec文件中读取配置,并执行至%install阶段
4 -bl 从spec文件中读取配置,并执行一次列表检查,查看%files中的文件是否存在
5 -ba 从spec文件中读取配置,并生成二进制包*.rpm和源代码包*.src.rpm
6 -bb 从spec文件中读取配置,并生成二进制包*.rpm
7 -bs 从spec文件中读取配置,并生成源代码包*.src.rpm
8 -tp 从tar包中读取配置,并执行至%prep阶段
9 -tc 从tar包中读取配置,并执行至%build阶段
10 -ti 从tar包中读取配置,并执行至%install阶段
11 -ta 从tar包中读取配置,并生成二进制包*.rpm和源代码包*.src.rpm
12 -tb 从tar包中读取配置,并生成二进制包*.rpm
13 -ts 从tar包中读取配置,并生成源码包*.src.rpm
14 --rebuild 针对目标源码包,进行源代码包的安装,然后执行准备,编绎,安装,并重新构建新的二进制包
15 --recompile 针对目标源码包,进行源代码包的安装,然后执行准备,编绎,安装
16 --buildroot=DIRECTORY 设定DIRECTORY来替换%buildroot值
17 --clean 打包完成后清除构建树
18 --nobuild 不进行包的实际创建
19 --nodeps 不检查编绎条件是否满足
20 --nodirtokens rpm v3版本的头文件兼容转换
21 --noclean 不执行SPEC文件中的%clean阶段(即使其存在)
22 --nocheck 不执行SPEC文件中的%check阶段(即使其存在)
23 --rmsource 构建rpm包后删除源代码,也可单独使用,如rpmbuild --rmsource xxx.spec
24 --rmspec 构建rpm包后删除SPEC文件,也可单独使用,如rpmbuild --rmspec xxx.spec
25 --short-circuit 直接跳到指定阶段,只有与c或i或b连用时才有效,仅用于本地调试,生成的包将被标记为依赖关系不足
26 --target=CPU-VENDOR-OS 强制指定运行平台
27 -D, --define='MACRO EXPR' 指定宏定义MACRO的值为EXPR
28 --undefine=MACRO 删除指定的宏定义
29 -E, --eval='EXPR' 从EXPR中导入宏定义信息
30 --macros=<FILE:...> 设定宏定义文件列表,以冒号:分隔
31 --noplugins 不使用任何插件
32 --nodigest 不校验包的完整性信息(MD5求和)
33 --nosignature 不校验包的签名信息
34 --rcfile=<FILE:...> 设定包含配置信息的文件列表,以冒号:分隔,默认读取/usr/lib/rpm/rpmrc:/usr/lib/rpm/redhat/rpmrc:/etc/rpmrc:~/.rpmrc这些文件
35 -r, --root=ROOT 在编绎时设定ROOT为最高级目录,即/
36 --dbpath=DIRECTORY RPM归档数据库的路径
37 --querytags 显示已知的请求标签信息
38 --showrc 显示rpmbuild的编绎环境和宏变量定义等
39 --quiet 不输出编绎信息
40 -v, --verbose 输出详细的编绎过程信息
41 --version 显示rpmbuild的版本信息
42 --with=<option> 强制使用指定的参数
43 --without=<option> 禁止使用指定的参数
44 --buildpolicy=<policy> 设定策略文档路径,比如用户手册等
45 --sign GPG签名,已废弃,用rpmsign代替
46 -?, --help 显示rpmbuild命令的帮助信息,如参数详细说明等
47 --usage 显示rpmbuild命令的格式及所有参数

4.rpmbuild打包配置文件SPEC说明






文章分类
联系我们
联系人: powereye
Email: zqs@someapp.cn
QQ: 1134846
微信: powereye