Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2353312
  • 博文数量: 141
  • 博客积分: 3552
  • 博客等级: 中校
  • 技术积分: 4148
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-15 14:39
个人简介

熟悉Linux下程序设计及各种应用程序 熟悉C Language 熟悉Glusterfs、FFmpeg、CDN 系统设计,计算机图形系统设计、分布式程序设计 目前主要研究方向:流媒体

文章分类

全部博文(141)

分类: LINUX

2013-12-05 10:52:10

RPM包制作方法


最近有同学问我制作RPM包相关的问题,我发现我以前做过,但是忘记记录了,现在记录一下:


以打包nginx并带有nginx-rtmp的工程为rpm为例:

首先,需要安装一个rpmbuild:


点击(此处)折叠或打开

  1. yum install rpm-build

安装完成之后,系统中可以使用rpmbuild命令

然后下载nginx与nginx-rtmp,当然,做包的前提是我们手动能够编译,安装nginx+nginx-rtmp

接下来就可以开始写spec,因为打包rpm时,rpmbuild会根据spec来进行操作,将源码包解压,然后按照我们的手动操作的步骤进行操作,最后打包成rpm

所以,关键要把spec写好:


点击(此处)折叠或打开

  1. [root@sr01 SOURCES]# cat nginx-1.3.8.with.rtmp/nginx.spec
  2. Name: nginx
  3. Version: 1.3.8.with.rtmp
  4. Release: 1%{?dist}
  5. Summary: nginx support rtmp media center

  6. Group: Steven & Gary
  7. License: GPL
  8. URL: http://bbs.chinaffmpeg.com
  9. Source0: nginx-1.3.8-with-rtmp.tar.gz
  10. BuildRoot: %(mktemp -ud %{_tmppath}/%{name}.%{version}-%{release}-XXXXXX)


  11. %description


  12. %prep
  13. %setup -q


  14. %build
  15. ./configure --add-module=./nginx-rtmp/
  16. make %{?_smp_mflags}


  17. %install
  18. rm -rf %{buildroot}
  19. make install DESTDIR=%{buildroot}


  20. %clean
  21. rm -rf %{buildroot}


  22. %files
  23. %defattr(-,root,root,-)
  24. %doc



  25. %changelog

spec写完后,将源码包放在SOURCE目录下即可,一般是在/root/rpmbuild下面


点击(此处)折叠或打开

  1. [root@sr01 SOURCES]# pwd
  2. /root/rpmbuild/SOURCES
  3. [root@sr01 SOURCES]# ls
  4. nginx-1.3.8.with.rtmp nginx-1.3.8-with-rtmp.tar.gz nginx-1.3.8.with.rtmp.tar.gz
  5. [root@sr01 SOURCES]#

然后rpmbuild -ba 刚刚生成的nginx.spec即可

输出如下


点击(此处)折叠或打开

  1. [root@sr01 SOURCES]# rpmbuild -ba nginx-1.3.8.with.rtmp/nginx.spec > /dev/null
  2. + umask 022
  3. + cd /root/rpmbuild/BUILD
  4. + cd /root/rpmbuild/BUILD
  5. + rm -rf nginx-1.3.8.with.rtmp
  6. + /usr/bin/gzip -dc /root/rpmbuild/SOURCES/nginx-1.3.8-with-rtmp.tar.gz
  7. + /bin/tar -xf -
  8. + STATUS=0
  9. + '[' 0 -ne 0 ']'
  10. + cd nginx-1.3.8.with.rtmp
  11. + /bin/chmod -Rf a+rX,u+w,g-w,o-w .
  12. + exit 0
  13. + umask 022
  14. + cd /root/rpmbuild/BUILD
  15. + cd nginx-1.3.8.with.rtmp
  16. + ./configure --add-module=./nginx-rtmp/
  17. + make -j8
  18. + exit 0
  19. + umask 022
  20. + cd /root/rpmbuild/BUILD
  21. + cd nginx-1.3.8.with.rtmp
  22. + rm -rf /root/rpmbuild/BUILDROOT/nginx-1.3.8.with.rtmp-1.el6.x86_64
  23. + make install DESTDIR=/root/rpmbuild/BUILDROOT/nginx-1.3.8.with.rtmp-1.el6.x86_64
  24. + /usr/lib/rpm/brp-compress
  25. + /usr/lib/rpm/brp-strip
  26. + /usr/lib/rpm/brp-strip-static-archive
  27. + /usr/lib/rpm/brp-strip-comment-note
  28. warning: Installed (but unpackaged) file(s) found:
  29.    /usr/local/nginx/conf/fastcgi.conf
  30.    /usr/local/nginx/conf/fastcgi.conf.default
  31.    /usr/local/nginx/conf/fastcgi_params
  32.    /usr/local/nginx/conf/fastcgi_params.default
  33.    /usr/local/nginx/conf/koi-utf
  34.    /usr/local/nginx/conf/koi-win
  35.    /usr/local/nginx/conf/mime.types
  36.    /usr/local/nginx/conf/mime.types.default
  37.    /usr/local/nginx/conf/nginx.conf
  38.    /usr/local/nginx/conf/nginx.conf.default
  39.    /usr/local/nginx/conf/scgi_params
  40.    /usr/local/nginx/conf/scgi_params.default
  41.    /usr/local/nginx/conf/uwsgi_params
  42.    /usr/local/nginx/conf/uwsgi_params.default
  43.    /usr/local/nginx/conf/win-utf
  44.    /usr/local/nginx/html/50x.html
  45.    /usr/local/nginx/html/index.html
  46.    /usr/local/nginx/sbin/nginx
  47. + umask 022
  48. + cd /root/rpmbuild/BUILD
  49. + cd nginx-1.3.8.with.rtmp
  50. + rm -rf /root/rpmbuild/BUILDROOT/nginx-1.3.8.with.rtmp-1.el6.x86_64
  51. + exit 0
  52. [root@sr01 SOURCES]#

然后即可看到生成的rpm包


点击(此处)折叠或打开

  1. [root@sr01 SOURCES]# ls /root/rpmbuild/RPMS/x86_64/nginx-1.3.8.with.rtmp-1.el6.x86_64.rpm
  2. /root/rpmbuild/RPMS/x86_64/nginx-1.3.8.with.rtmp-1.el6.x86_64.rpm
  3. [root@sr01 SOURCES]#

文件生成完毕

阅读(13895) | 评论(0) | 转发(4) |
给主人留下些什么吧!~~