nginx1.7.7 rpm包制作过程
制作环境:centos 6.5 x64 2.6.32-431.el6.x86_64
1、检查是否安装了rpmbuild
2、检查是否生成了rpmbuild工作目录,如果没有使用rpmdev-setuptree重新生成
各目录功能如下:
SOURCES:放置打包资源,包括源码打包文件和补丁文件等。
SPECS:放置SPEC文档。
BUILD:打包过程中的工作目录。
RPMS:存放生成的二进制包。
SRPMS:目录存放生成的源码包。
3、编写spec文件
Summary:High Performance Web Server Name:nginx Version:1.7.7 Release:el6 Source0:%{name}-%{version}.tar.gz License:GPL BuildRoot:%{_tmppath}/%{name}-%{version}-%{release}-root Group:Applications/Server Distribution:Linux Packager:apeter<[email protected]> %description nginx [engine x] is a HTTP and reverse proxy server, as well as a mail proxy server %prep rm -rf $RPM_BUILD_DIR/nginx1.7.7 zcat $RPM_SOURCE_DIR/nginx-1.7.7.tar.gz | tar -xvf - %build cd nginx-1.7.7 ./configure --prefix=/usr/local/nginx make %install cd nginx-1.7.7 make install DESTDIR=%{buildroot} %preun if [ -z "`ps aux | grep nginx | grep -v grep`" ];then killall nginx >/dev/null exit 0 fi %files /usr/local/nginx
4、接下来一步是构建rpm包
首先安装编译需要的rpm包,如gcc、pcre、pcre-devel,然后复制nginx源码到~/rpmbuild/SOURCES目录,nginx源码复制完成后,进入~/rpmbuild/SPECS目录,使用rpmbuild -bb nginx.spec命令制作RPM包。制作完成后会在~/rpmbuild/RPMS/x86_64生成一个rpm包。
在制作过程中遇到了下图中的错误,具体解决方法是这样的:
编辑/usr/lib/rpm/macros文件:
%_topdir %{getenv:HOME}/rpmbuild
修改为:
%_topdir %{_usrsrc}/redhat
另外还需要定义buildroot
在spec文件中的make install后面加上DESTDIR=%{buildroot},即:
make install DESTDIR=%{buildroot}