标签:
[root@NGM ~]# yum install pcre-devel zlib-devel openssl-devel make cmake gcc gcc-c++ bison ncurses-devel rpm-build rpmdevtools -y [root@NGM ~]# rpmdev-setuptree #直接执行rpmdev-setuptree就会新建工作目录和.rpmmacros文件 [root@NGM ~]# cat .rpmmacros %_topdir %(echo $HOME)/rpmbuild %_smp_mflags -j3 %__arch_install_post /usr/lib/rpm/check-rpaths /usr/lib/rpm/check-buildroot
下载源码包到:SOURCE中
[root@NGM x86_64]# ls /root/rpmbuild/ BUILD BUILDROOT RPMS SOURCES SPECS SRPMS
[root@NGM x86_64]# ls /root/rpmbuild/SOURCES/ nginx-1.4.4.tar.gz nginx.conf
制作xxx.spec文件在 SPECS中
[root@NGM x86_64]# ls /root/rpmbuild/SPECS/ nginx.spec [root@NGM x86_64]# cat /root/rpmbuild/SPECS/nginx.spec Name: nginx Version: 1.4.4 Release: 1%{?dist} Summary: nginx rmp package production Group: Applications/Archiving License: GPLv2 URL: http://www.nginx.org Source: http://nginx.org/download/nginx-1.4.4.tar.gz BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) BuildRequires: gcc Requires: openssl,openssl-devel,pcre-devel,pcre %description Custom nginx rpm package %prep rm -rf $RPM_BUILD_DIR/nginx-1.4.4 tar fx $RPM_SOURCE_DIR/nginx-1.4.4.tar.gz %build cd nginx-1.4.4 ./configure --user=www --group=www --prefix=/home/application/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module make %{?_smp_mflags} %install rm -rf %{buildroot} cd nginx-1.4.4 make install DESTDIR=%{buildroot} %clean rm -rf %{buildroot} %files %defattr(-,root,root,-) /home/application/nginx
xxx.spec文件解释:
#:以#开头是注释,rpm会忽略它。 Summary: 简单描述软件。 Name : 定义rpm的名称。 Version: 定义软件版本 Release: 发行版本 License: 定义许可证 Group: 软件分类 Source: 源码下载地址 URL: 源码相关网站 Distribution: 发行版系列 Packager: 打包人的信息 %description:软件详细描述,可多行 %prep :软件编译之前的处理,如解压。 %build :开始编译软件,如make %install :开始安装软件,如make install %files :指定哪些文件需要被打包,如/usr/local/nginx %preun :定义卸载之前的动作,如杀掉进程。
开始制作:
[root@NGM x86_64]# rpmbuild -bb /root/rpmbuild/SPECS/nginx.spec
生成RPM包:
[root@NGM x86_64]# tree /root/rpmbuild/RPMS/ /root/rpmbuild/RPMS/ └── x86_64 ├── nginx-1.4.4-1.el6.x86_64.rpm └── nginx-debuginfo-1.4.4-1.el6.x86_64.rpm 1 directory, 2 files
标签:
原文地址:http://www.cnblogs.com/bass6/p/5611889.html