您当前的位置: 首页 >  ui

liaowenxiong

暂无认证

  • 2浏览

    0关注

    1171博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

liaowenxiong 发布时间:2021-06-17 13:57:43 ,浏览量:2

文章目录
  • 一、命令介绍
  • 二、命令选项
    • (一)从 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 为后缀名的包。

选项说明-tpbuild 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 为后缀名的包。

选项说明--rebuildbuild binary package from . 译文:基于源码包建立二进制包(*.rpm)--recompilebuild through %install (%prep, %build, then install) from . 译文:基于源码包的 %install 开始建立(解开源码包、打补丁、编译、安装) (四)其它选项 选项说明--buildrootoverride 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)--targetoverride target platform. 覆盖目标平台,确定包的最终使用平台 (五)所有 rpm 都可使用的选项

Common options for all rpm modes.

选项说明-D 或 --definedefine MACRO with value EXPR. 用值表达式定义宏-E 或 --evalprint macro expansion of EXPR. 打印表达式的宏扩展--macrosread instead of default file(s). 读取而不是默认文件--nodigestdon’t verify package digest(s). 不验证包摘要,不检查包的说明信息--nosignaturedon’t verify package signature(s). 不检查包的签名信息--rcfileread instead of default file(s). 读 文件代替默认文件-r 或 --rootuse 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实现的选项

选项说明--dbpathuse database in DIRECTORY. 使用目录中的数据库--withenable configure for build. 建立时允许配置的选项--withoutdisable 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 包》

关注
打赏
1661566967
查看更多评论
立即登录/注册

微信扫码登录

0.0545s