nginx源码包之rpm打包

4 篇文章 0 订阅
1 篇文章 0 订阅

1、安装rpm-build软件

[root@web46 ~]# yum -y install rpm-build

2、生成rpmbuild目录结构

[root@web46 ~]# rpmbuild -ba nginx.spec		//报错,但会自动创建rpmbuild目录结构
错误:stat /root/nginx.spec 失败:没有那个文件或目录
[root@web46 ~]# ls
nginx-1.12.2.tar.gz  rpmbuild
[root@web46 ~]# ls rpmbuild/
BUILD  BUILDROOT  RPMS  SOURCES  SPECS  SRPMS

3、将源码包复制到SOURCES目录

[root@web46 ~]# ls
nginx-1.12.2.tar.gz  rpmbuild
[root@web46 ~]# cp nginx-1.12.2.tar.gz rpmbuild/SOURCES/

4、创建并修改SPEC配置文件

[root@web46 ~]# vim rpmbuild/SPECS/nginx.spec
Name:nginx		//软件包名称,不能写错
Version:1.12.2		//软件版本,不能写错
Release:        1%{?dist}		//第几次打rpm包,默认第一次
Summary:this is a web server		//简单描述
#Group:         
License:GPL		//GPL协议:任意复制,任意粘贴,任意修改
URL:www.abc.com		//任意网址
Source0:nginx-1.12.2.tar.gz		//源码包名称,不能写错
#BuildRequires:		//源码安装提示的依赖包
#Requires:      //rpm打包完成后,交付使用安装提示的依赖包

%description
this is a web server to.		//详细描述

%post
useradd nginx		//非必需操作:安装后脚本(创建账户)

%prep
%setup -q		//自动解压源码包,并cd进入目录
%build
./configure --with-http_ssl_module		//安装配置项
make %{?_smp_mflags}
%install
make install DESTDIR=%{buildroot}
%files
%doc
/usr/local/nginx/*		//对哪些文件与目录打包
%changelog

5、安装依赖包

[root@web46 ~]# yum -y install gcc pcre-devel zlib-devel openssl-devel

6、rpmbuild创建rpm软件包

[root@web46 ~]# cd rpmbuild/SPECS/
[root@web46 SPECS]# ls
nginx.spec
[root@web46 SPECS]# rpmbuild -ba nginx.spec
[root@web46 SPECS]# ls /root/rpmbuild/RPMS/x86_64/
nginx-1.12.2-1.el7.centos.x86_64.rpm		//打包完后生成的rpm包
nginx-debuginfo-1.12.2-1.el7.centos.x86_64.rpm

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
在/rpmbuild/SRPMS/目录下生成的nginx-*.src.rpm包含有源码包和spec文件

[root@web46 ~]# cd rpmbuild/SRPMS/
[root@web46 SRPMS]# ls
nginx-1.12.2-1.el7.centos.src.rpm
[root@web46 SRPMS]# rpm -qpl nginx-1.12.2-1.el7.centos.src.rpm 
nginx-1.12.2.tar.gz
nginx.spec
[root@web46 SRPMS]# rpm2cpio  nginx-1.12.2-1.el7.centos.src.rpm  |cpio -div
nginx-1.12.2.tar.gz
nginx.spec
1919 块
[root@web46 SRPMS]# ls
nginx-1.12.2-1.el7.centos.src.rpm  nginx-1.12.2.tar.gz  nginx.spec
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值