前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >RPM包制作方法

RPM包制作方法

作者头像
用户3765803
发布2019-03-05 09:43:44
1.3K0
发布2019-03-05 09:43:44
举报
文章被收录于专栏:悟空被FFmpeg玩

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]#

文件生成完毕

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2013/12/05 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档