RPM包制作方法
最近有同学问我制作RPM包相关的问题,我发现我以前做过,但是忘记记录了,现在记录一下:
以打包nginx并带有nginx-rtmp的工程为rpm为例:
首先,需要安装一个rpmbuild:
安装完成之后,系统中可以使用rpmbuild命令
然后下载nginx与nginx-rtmp,当然,做包的前提是我们手动能够编译,安装nginx+nginx-rtmp
接下来就可以开始写spec,因为打包rpm时,rpmbuild会根据spec来进行操作,将源码包解压,然后按照我们的手动操作的步骤进行操作,最后打包成rpm
所以,关键要把spec写好:
-
[root@sr01 SOURCES]# cat nginx-1.3.8.with.rtmp/nginx.spec
-
Name: nginx
-
Version: 1.3.8.with.rtmp
-
Release: 1%{?dist}
-
Summary: nginx support rtmp media center
-
-
Group: Steven & Gary
-
License: GPL
-
URL: http://bbs.chinaffmpeg.com
-
Source0: nginx-1.3.8-with-rtmp.tar.gz
-
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}.%{version}-%{release}-XXXXXX)
-
-
-
%description
-
-
-
%prep
-
%setup -q
-
-
-
%build
-
./configure --add-module=./nginx-rtmp/
-
make %{?_smp_mflags}
-
-
-
%install
-
rm -rf %{buildroot}
-
make install DESTDIR=%{buildroot}
-
-
-
%clean
-
rm -rf %{buildroot}
-
-
-
%files
-
%defattr(-,root,root,-)
-
%doc
-
-
-
-
%changelog
spec写完后,将源码包放在SOURCE目录下即可,一般是在/root/rpmbuild下面
-
[root@sr01 SOURCES]# pwd
-
/root/rpmbuild/SOURCES
-
[root@sr01 SOURCES]# ls
-
nginx-1.3.8.with.rtmp nginx-1.3.8-with-rtmp.tar.gz nginx-1.3.8.with.rtmp.tar.gz
-
[root@sr01 SOURCES]#
然后rpmbuild -ba 刚刚生成的nginx.spec即可
输出如下
-
[root@sr01 SOURCES]# rpmbuild -ba nginx-1.3.8.with.rtmp/nginx.spec > /dev/null
-
+ umask 022
-
+ cd /root/rpmbuild/BUILD
-
+ cd /root/rpmbuild/BUILD
-
+ rm -rf nginx-1.3.8.with.rtmp
-
+ /usr/bin/gzip -dc /root/rpmbuild/SOURCES/nginx-1.3.8-with-rtmp.tar.gz
-
+ /bin/tar -xf -
-
+ STATUS=0
-
+ '[' 0 -ne 0 ']'
-
+ cd nginx-1.3.8.with.rtmp
-
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
-
+ exit 0
-
+ umask 022
-
+ cd /root/rpmbuild/BUILD
-
+ cd nginx-1.3.8.with.rtmp
-
+ ./configure --add-module=./nginx-rtmp/
-
+ make -j8
-
+ exit 0
-
+ umask 022
-
+ cd /root/rpmbuild/BUILD
-
+ cd nginx-1.3.8.with.rtmp
-
+ rm -rf /root/rpmbuild/BUILDROOT/nginx-1.3.8.with.rtmp-1.el6.x86_64
-
+ make install DESTDIR=/root/rpmbuild/BUILDROOT/nginx-1.3.8.with.rtmp-1.el6.x86_64
-
+ /usr/lib/rpm/brp-compress
-
+ /usr/lib/rpm/brp-strip
-
+ /usr/lib/rpm/brp-strip-static-archive
-
+ /usr/lib/rpm/brp-strip-comment-note
-
warning: Installed (but unpackaged) file(s) found:
-
/usr/local/nginx/conf/fastcgi.conf
-
/usr/local/nginx/conf/fastcgi.conf.default
-
/usr/local/nginx/conf/fastcgi_params
-
/usr/local/nginx/conf/fastcgi_params.default
-
/usr/local/nginx/conf/koi-utf
-
/usr/local/nginx/conf/koi-win
-
/usr/local/nginx/conf/mime.types
-
/usr/local/nginx/conf/mime.types.default
-
/usr/local/nginx/conf/nginx.conf
-
/usr/local/nginx/conf/nginx.conf.default
-
/usr/local/nginx/conf/scgi_params
-
/usr/local/nginx/conf/scgi_params.default
-
/usr/local/nginx/conf/uwsgi_params
-
/usr/local/nginx/conf/uwsgi_params.default
-
/usr/local/nginx/conf/win-utf
-
/usr/local/nginx/html/50x.html
-
/usr/local/nginx/html/index.html
-
/usr/local/nginx/sbin/nginx
-
+ umask 022
-
+ cd /root/rpmbuild/BUILD
-
+ cd nginx-1.3.8.with.rtmp
-
+ rm -rf /root/rpmbuild/BUILDROOT/nginx-1.3.8.with.rtmp-1.el6.x86_64
-
+ exit 0
-
[root@sr01 SOURCES]#
然后即可看到生成的rpm包
-
[root@sr01 SOURCES]# ls /root/rpmbuild/RPMS/x86_64/nginx-1.3.8.with.rtmp-1.el6.x86_64.rpm
-
/root/rpmbuild/RPMS/x86_64/nginx-1.3.8.with.rtmp-1.el6.x86_64.rpm
-
[root@sr01 SOURCES]#
文件生成完毕
阅读(13865) | 评论(0) | 转发(4) |