rpmbuild 简单实例

1427阅读 0评论2009-05-26 ygl23
分类:系统运维

1.二进制文件准备
之前已经执行源码编译工作 :configure --prefix=/opt/httpd;make;make install
 
2.建立build目录,并且创建nginx.spec文件:
$cd /usr/src/redhat/BUILD
$mkdir -p /usr/src/redhat/BUILD/nginx-root/opt/httpd
$cp -rpf /opt/httpd/* /usr/src/redhat/BUILD/nginx-root/opt/httpd/
$mkdir -p /usr/src/redhat/BUILD/nginx-root/etc/init.d
$cp /etc/init.d/httpd /usr/src/redhat/BUILD/nginx-root/etc/init.d/
$touch nginx.spec
 
Summary: Nginx Server
Name: nginx
Version: 0.6.3
Release: 1
License: GPL
Group: Development/Tools
BuildRoot: %{_builddir}/%{name}-root
#BuildRoot: /usr/src/redhat/BUILD/nginx-root
%description
Nginx Server install rpm page
Requires: zlib >= 1.2.3 zlib-devel >= 1.2.3 openssl
%files
/opt/httpd
/etc/init.d/httpd
%pre
if [ -f /etc/init.d/httpd ];then
chkconfig --del httpd
fi
%post
chkconfig --add httpd
chkconfig --level 35 httpd on
chkconfig --level 01246 httpd off
%preun
chkconfig --del httpd
rm -f /etc/init.d/httpd
 
4.生成nginx-0.6.3-1.i386.rpm \nginx-0.6.3-1.x86_64.rpm
$rpmbuild -bb nginx.spec --nodeps
 
/usr/src/redhat/RPMS/i386/nginx-0.6.3-1.i386.rpm # 32位系统生成文件存储位置
 
/usr/src/redhat/RPMS/x86_64/nginx-0.6.3-1.x86_64.rpm # 64位系统生成文件存储位置
 
5.安装测试
 
将安装包拷贝到测试机器上执行
$rpm -ivh nginx-0.6.3-1.i386.rpm
程序已经发布到/opt/httpd/目录下
 
查询安装
$rpm -qa|grep nginx
nginx-0.6.3-1
 
卸载
$rpm -e nginx
/opt/httpd/目录,/etc/init.d/httpd文件被清除.
 
RPMBUILD相关文章:
 http://www-900.ibm.com/developerWorks/cn/linux/management/package/rpm/part1/index.shtml 
http://www-900.ibm.com/developerWorks/cn/linux/management/package/rpm/part2/index.shtml
http://www-900.ibm.com/developerWorks/cn/linux/management/package/rpm/part3/index.shtml
http://blog.chinaunix.net/u/7356/showart_235311.html
http://www.ibm.com/developerworks/cn/linux/management/package/rpm/part1/
 
http://blog.csdn.net/anxiongshan/archive/2007/10/06/1812578.aspx
 
http://hlee.javaeye.com/blog/343499
 
 
 
上一篇:Linux双网卡bonding举例
下一篇:Tomcat 6.18 Virtual Host