如果你对RPM没有什么好印像的话,我相信原因就是它的过复杂的包依赖关系。
但如果自己动手来编绎RPM包的话,这个问题你可以很愉快的进行控制
如果你有一个很好的软件版本控制系统的话,你完全可以把你所有要用的软件包都编绎成RPM, 这样可以提高一些常规软件部署效率,比如apache mysql这样的软件。
本次目标:在新装的一台centos6.4 x86_64位系统上生成根据apache的源码包生成个apache的rpm文件
yum-y install wget -y
yuminstall rpm-build -y
wget http://archive.apache.org/dist/httpd/httpd-2.4.4.tar.bz2
这些文件的下载可以放在一个文档,比如/usr/local/src,本博写的文件是直接下载在/root目录下的
RPM的建立可以直接从Apache httpd源码压缩包中使用以下命令:
rpmbuild-tb httpd-2.4.4.tar.bz2
但是如果下载好httpd的源码包就直接使用这个命令的话是会有如下错误提示的
相应的“开发”被安装在您的构建系统之前建立的RPM包将被要求,rpmbuild的命令会自动计算需要什么的RPM,并列出在您的系统中缺少的任何依赖。这些“开发”包不会被构建完成后,可以安全地删除。
根据上面的提示要安装的包,我们要下载apr 1.4以上的相关的包和distcache的包,在系统自带的包里面的apr的版本太低的。
wget http://mirror.bit.edu.cn/apache/apr/apr-1.5.0.tar.bz2
wget http://mirror.bit.edu.cn/apache/apr/apr-util-1.5.3.tar.bz2
wget http://dl.fedoraproject.org/pub/fedora/linux/releases/18/Fedora/source/SRPMS/d/distcache-1.4.5-23.src.rpm
如下所示下载好apr的包要是直接用rpmbuild打包也还是不行,还是要安装相关的组件
结和上面关于apr和httpd相关的组件整合在一起安装如下所示:除了freetds的组件,这个组件要从别的源下载的如epel
yum -y install autoconf libtool doxygen expat expat-devel libuuid-develdb4-devel mysql-devel unixODBC-devel postgresql-devel sqlite-devel pcrepcre-devel lua-devel libxml2-devel openldap-devel nss-devel zlib-devel libselinux-develmake
安装“freetds freetds-devel”这个相关的组件的,只是这个包在系统自带的那个包里是没有的,须要用外网的源,比如epel、remi等。这里我就用epel的源
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
yum -y install freetds freetds-devel
安装好上面相关的组件后就可以使用这个命令“rpmbuild-tb apr-1.5.0.tar.bz2”编译apr的rpm包了。
打包好之后会/root/rpmbuild/RPMS/x86_64/下生成rpm的包的,这里的这个rpmbuild这个目录是我在做第一步的时候使用这个命令时“rpmbuild -tb httpd-2.4.6.tar.bz2”它自动生成的,当然也可以自己建这个目录的及这个目录下面的这几个目录的(BUILD BUILDROOT RPMS SOURCES SPECS SRPMS)
下面就是安装apr的包
rpm–ivh /root/rpmbuild/RPMS/x86_64/apr-1.5.0-1.x86_64.rpm
rpm-ivh /root/rpmbuild/RPMS/x86_64/apr-devel-1.5.0-1.x86_64.rpm
rpmbuild -tb apr-util-1.5.3.tar.bz2
rpm -ivh /root/rpmbuild/RPMS/x86_64/apr-util-* //安装转为rpm包的apr-util的所有的包
最后要安装distcache这个组件:
rpmbuild --rebuild distcache-1.4.5-23.src.rpm //从源码包建立二进制包
rpm -ivh /root/rpmbuild/RPMS/x86_64/distcache-* //安装所有制作好的distcache的rpm的包
所有和httpd制作相关的组件都安装好了,接下来就可以编译httpd的rpm包了
rpmbuild -tb httpd-2.4.4.tar.bz2
httpd的rpm包打包好之后就可以安装了如下所示,不过在安装httpd的rpm包之前要先安装mailcap组件的,不然会提示“
[root@localhost~]# rpm -ivh rpmbuild/RPMS/x86_64/httpd-2.4.4-1.x86_64.rpm
error: Failed dependencies:
/etc/mime.types is needed by httpd-2.4.4-1.x86_64”
yum install mailcap -y
安装完mailcap组件后再安装下面的httpd的相关的rpm包:
rpm–ivh /root/rpmbuild/RPMS/x86_64/httpd-2.4.4-1.x86_64.rpm
rpm–ivh /root/rpmbuild/RPMS/x86_64/httpd-devel-2.4.4-1.x86_64.rpm
rpm–ivh /root/rpmbuild/RPMS/x86_64/httpd-tools-2.4.4-1.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/httpd-manual-2.4.4-1.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/mod_authnz_ldap-2.4.4-1.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/mod_lua-2.4.4-1.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/mod_proxy_html-2.4.4-1.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/mod_socache_dc-2.4.4-1.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/mod_ssl-2.4.4-1.x86_64.rpm
service httpd start
rpmbuild --help 命令的解释说明如下:
————————————————————————————————————————————
*使用命令:rpmbuild ·[OPTION]
Build options with [
*建立包的选项有:[ 从文件
*从文件
-bp build through %prep (unpack sources and apply patches) from
* -bp 从
-bc build through %build (%prep, then compile) from
*-bc 从
-bi build through %install (%prep,%build, then install) from
-bl verify %files section from
*检查
-ba build source and binary packages from
*建立源码和二进制包
-bb build binary package only from
*只建立二进制包
-bs build source package only from
*只建立源码包
*从
-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
*只建立源码包
*从
————————————————————————————————————————————
番外的,整合了一下上面所述的命令的,如下所示:
————————————————————————————————————————————
以上的apache的源码包就打包成了rpm的包,还是有很多rpm包的。将这些在/root/rpmbuild/RPMS/x86_64/下生成rpm的包或拷贝整个rpmbuild这个目录到别的服务器上,那些相关的组件也还是要安装的,才能安装这些打包好的rpm包的。这样就方便多了,不用编译要等那么长的时间了,步骤如下所示:
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
yum -y install autoconf libtool doxygen expat expat-devel libuuid-devel db4-develmysql-devel unixODBC-devel postgresql-devel sqlite-devel pcre pcre-devellua-devel libxml2-devel openldap-devel nss-devel zlib-devel libselinux-develmake freetds freetds-devel mailcap
rpm –ivh /root/rpmbuild/RPMS/x86_64/apr-1.5.0-1.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/apr-devel-1.5.0-1.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/apr-util-*
rpm -ivh /root/rpmbuild/RPMS/x86_64/distcache-*
rpm –ivh /root/rpmbuild/RPMS/x86_64/httpd-2.4.4-1.x86_64.rpm
rpm –ivh /root/rpmbuild/RPMS/x86_64/httpd-devel-2.4.4-1.x86_64.rpm
rpm –ivh /root/rpmbuild/RPMS/x86_64/httpd-tools-2.4.4-1.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/httpd-manual-2.4.4-1.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/mod_authnz_ldap-2.4.4-1.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/mod_lua-2.4.4-1.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/mod_proxy_html-2.4.4-1.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/mod_socache_dc-2.4.4-1.x86_64.rpm
rpm -ivh /root/rpmbuild/RPMS/x86_64/mod_ssl-2.4.4-1.x86_64.rpm
————————————————————————————————————————————