Linux rpmbuild简单介绍

本博客先前介绍过如何解压rpm包,演示了将.rpm包还原成源代码的形式。rpmbuild则是用来将源代码打包成.rpm格式的工具。

xxx.rpm 指普通的软件包,执行rpm -ivh xxx.rpm以后即是完成了安装;xxx.src.rpm 指的是包含源代码的软件包,执行rpm -ivh xxx.src.rpm以后,并不是安装了该软件,而是在当前目录下生成一个名为rpmbuild的文件夹,里面包含了此软件的所有源代码,还需要使用rpmbuild工具将源代码打包成.rpm或者.tar.gz格式的软件包,才能正常安装使用。

CentOS6 中安装rpmbuild:

yum install rpm-build

rpmbuild命令参数介绍-bp 只作准备 (解压与打补丁)-bc 准备并编译-bi 编译并安装-bl 检验文件是否齐全-ba 编译后做成*.rpm和src.rpm-bb 编译后做成*.rpm-bs 只做成*.src.rpm-tc -ti -ta -tb -ts 的功能类似,只是所需参数由spec文件变成tar包。

例如:

cd /usr/src/redhat/SPECSrpmbuild -bp kernel-2.6.spec

更具体的用法说明:

Build options with [  |  |  ]:建立包的选项有:[ 从建立 | 从包建立 | 从包建立 ]

从specfile文件建立

  -bp  build through %prep (unpack sources and apply patches) from        -bp 从文件的%prep段开始建立(解开源码包并打补丁)  -bc  build through %build (%prep, then compile) from        -bc 从文件的%build  -bi  build through %install (%prep, %build, then install) from   -bl  verify %files section from        检查文件的%files段  -ba  build source and binary packages from        建立源码和二进制包  -bb  build binary package only from        只建立二进制包  -bs  build source package only from        只建立源码包

从tarball包建立

  -tp  build through %prep (unpack sources and apply patches) from   -tc  build through %build (%prep, then compile) from   -ti  build through %install (%prep, %build, then install) from   -ta  build source and binary packages from        建立源码和二进制包  -tb  build binary package only from        只建立二进制包  -ts  build source package only from        只建立源码包

从source package包建立

  --rebuild   build binary package from               建立二进制包  --recompile               build through %install (%prep, %build, then install) from 

关于rpmbuild的使用,请参考CentOS 6.4安装mock。

一些.src.rpm包的下载地址:ftp://ftp.redhat.com/pub/redhat/linux/enterprise/6Server/en/os/SRPMS

Linux rpmbuild简单介绍

相关文章:

你感兴趣的文章:

标签云: