Linux 命令之 rpmbuild -- 用于创建 rpm 格式的二进制软件包和源码软件包
生活随笔
收集整理的這篇文章主要介紹了
Linux 命令之 rpmbuild -- 用于创建 rpm 格式的二进制软件包和源码软件包
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
文章目錄
- 一、命令介紹
- 二、命令選項
- (一)從 specfile 建立
- (二)從 tarball 包建立
- (三)從 source package 包建立
- (四)其它選項
- (五)所有 rpm 都可使用的選項
- (六)附加選項
- (七)幫助選項
- 三、命令示例
- (一)根據配置文件對源碼包進一步解壓,得到最終的源碼文件
一、命令介紹
命令 rpmbuild 用于創建 RPM 軟件包和 SRPM 軟件包,這兩類軟件包分別是 rpm 格式的二進制軟件包和源碼軟件包
二、命令選項
Build options with [ <specfile> | <tarball> | <source package> ]
中文譯為:通過配置文件或 tar.gz 格式的源碼包或者 rpm 格式的源碼包來構建
(一)從 specfile 建立
| -bp | build through %prep (unpack sources and apply patches) from <specfile>. 譯文:從 specfile 文件的 %prep 開始建立(解開源碼包并打補丁),只作準備,解壓與打補丁 |
| -bc | build through %build (%prep, then compile) from <specfile>. 譯文:從文件的 %build 開始建立(解開源碼包、打補丁、編譯) |
| -bi | build through %install (%prep, %build, then install) from <specfile> 譯文:從文件的 %install 開始建立(解開源碼包、打補丁、編譯、安裝) |
| -bl | verify %files section from <specfile>. 譯文:檢查文件的 %files 段,檢驗文件是否齊全 |
| -ba | build source and binary packages from <specfile>. 譯文:創建源碼包(SRPM)和二進制包(RPM) |
| -bb | build binary package only from <specfile>. 譯文:只構建二進制包 |
| -bs | build source package only from <specfile>. 譯文:只建立源碼包(SRPM) |
(二)從 tarball 包建立
這個 tarball 應該是以 .tar 為后綴名的包。
| -tp | build through %prep (unpack sources and apply patches) from <tarball>. 譯文:從 tar 包的 %prep 開始構建(解開源碼包并打補丁) |
| -tc | build through %build (%prep, then compile) from <tarball>. 譯文:從 tar 包的 %build 開始建立(解開源碼包、打補丁、編譯) |
| -ti | build through %install (%prep, %build, then install) from <tarball>. 譯文:從 tar 包的 %install 開始建立(解開源碼包、打補丁、編譯、安裝) |
| -ta | build source and binary packages from <tarball>. 譯文:從 tar 包建立源碼包和二進制包 |
| -tb | build binary package only from <tarball>. 譯文:只建立二進制包 |
| -ts | build source package only from <tarball>. 譯文:只建立源碼包 |
(三)從 source package 包建立
這個源碼包,應該是以 .tar.gz 為后綴名的包。
| --rebuild | build binary package from <source package>. 譯文:基于源碼包建立二進制包(*.rpm) |
| --recompile | build through %install (%prep, %build, then install) from <source package>. 譯文:基于源碼包的 %install 開始建立(解開源碼包、打補丁、編譯、安裝) |
(四)其它選項
| --buildroot<DIRECTORY> | 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<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). 讀取而不是默認文件 |
| --nodigest | don’t verify package digest(s). 不驗證包摘要,不檢查包的說明信息 |
| --nosignature | don’t verify package signature(s). 不檢查包的簽名信息 |
| --rcfile<filename> | read instead of default file(s). 讀 文件代替默認文件 |
| -r 或 --root<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 包》
總結
以上是生活随笔為你收集整理的Linux 命令之 rpmbuild -- 用于创建 rpm 格式的二进制软件包和源码软件包的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linux环境变量生效命令(linux
- 下一篇: Linux 系统的硬链接和软链接详解