Linux使用src rpm包做二次rpm封包

安装编译需要的gcc gcc-c++ 和rpmbuild
[root@LookBack-Node ~]# yum install gcc gcc-c++ rpm-build
添加个普通用户
[root@LookBack-Node ~]# name=rpmbuild
[root@LookBack-Node ~]# useradd $name
设定普通用户的rpmbuild根目录
[root@LookBack-Node ~]# echo "%_topdir  /home/$name/rpmbuild" >> /home/$name/.rpmmacros
[root@LookBack-Node ~]# chown $name.$name /home/$name/.rpmmacros
添加sudo权限
[root@LookBack-Node ~]# echo "$name ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
[root@LookBack-Node ~]# su - $name
创建必要的目录
[rpmbuild@LookBack-Node ~]$ mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
[rpmbuild@LookBack-Node ~]$ rpmbuild --showrc | grep _topdir
-14: _builddir  %{_topdir}/BUILD
-14: _buildrootdir      %{_topdir}/BUILDROOT
-14: _rpmdir    %{_topdir}/RPMS
-14: _sourcedir %{_topdir}/SOURCES
-14: _specdir   %{_topdir}/SPECS
-14: _srcrpmdir %{_topdir}/SRPMS
-14: _topdir    /home/rpmbuild/rpmbuild
[rpmbuild@LookBack-Node ~]$ cd rpmbuild/SOURCES/
下载Nginx的src rpm包
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ wget http://nginx.org/packages/mainline/centos/7/SRPMS/nginx-1.9.9-1.el7.ngx.src.rpm
解包
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ rpm2cpio nginx-1.9.9-1.el7.ngx.src.rpm |cpio -dvi
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ ls
COPYRIGHT  nginx-1.9.9-1.el7.ngx.src.rpm  nginx.conf           nginx-debug.sysconf  nginx.service  nginx.suse.logrotate  nginx.upgrade.sh
logrotate  nginx-1.9.9.tar.gz             nginx-debug.service  nginx.init.in        nginx.spec     nginx.sysconf         nginx.vh.default.conf
给Nginx源码包添加自己需要的东西,这里我加了三个模块
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ tar xf nginx-1.9.9.tar.gz
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ cd nginx-1.9.9/
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES/nginx-1.9.9]$ git clone https://github.com/aperezdc/ngx-fancyindex.git
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES/nginx-1.9.9]$ git clone https://github.com/cuber/ngx_http_google_filter_module.git
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES/nginx-1.9.9]$ git clone https://github.com/yaoweibin/ngx_http_substitutions_filter_module.git
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES/nginx-1.9.9]$ cd ..
将新的源码目录打包
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ tar zcf nginx-1.9.9.tar.gz nginx-1.9.9/
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ tar zcf nginx-1.9.9.tar.gz nginx-1.9.9
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ rm -rf nginx-1.9.9
备份原有的spec,下载新的spec,当然这里自己重新写也是可以的
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ mv nginx.spec{,_bak}
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ wget http://www.dwhd.org/wp-content/uploads/2015/12/nginx.spec
对必备文件做适量修改让其适配我们自己的spec文件
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ sed -i 's@/usr/sbin/nginx@/usr/local/nginx/sbin/nginx@' nginx-debug.service nginx-debug.sysconf nginx.service nginx.sysconf nginx.upgrade.sh
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ sed -i 's@/etc/nginx@/usr/local/nginx/conf@' nginx-debug.service nginx-debug.sysconf nginx.init.in nginx.service nginx.sysconf nginx.upgrade.sh nginx.conf
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ sed -i 's@/usr/share/nginx/html@/data/wwwroot/default@' nginx.vh.default.conf
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ sed -ri 's/^(user).*/\1 www;/;s/^(worker_processes).*/\1 auto;/' nginx.conf
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ sed -ri 's@^(\s+include).*@\1 vhost/*.conf;@' nginx.conf
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ sed -i 's@/usr/sbin/%PROVIDES%@/usr/local/nginx/sbin/%PROVIDES%@' nginx.init.in
开始构建rpm包,当系统环境缺少这些依赖的时候会做提示
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ rpmbuild -ba nginx.spec
错误:构建依赖失败:
        openssl-devel >= 1.0.1 被 nginx-1:1.9.9-2.el7.centos.ngx.x86_64 需要
        zlib-devel 被 nginx-1:1.9.9-2.el7.centos.ngx.x86_64 需要
        pcre-devel 被 nginx-1:1.9.9-2.el7.centos.ngx.x86_64 需要
        gd-devel 被 nginx-1:1.9.9-2.el7.centos.ngx.x86_64 需要
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ sudo yum install -y openssl-devel zlib-devel pcre-devel gd-devel
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ rpmbuild -ba nginx.spec
安装自己制作的rpm包
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ sudo yum install -y /home/rpmbuild/rpmbuild/RPMS/x86_64/nginx-1.9.9-2.el7.centos.ngx.x86_64.rpm
安装好之后来看看具体情况
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ . /etc/profile.d/nginx.sh
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ which nginx
/usr/local/nginx/sbin/nginx
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ yum list all |grep nginx.*@
nginx.x86_64                             1:1.9.9-2.el7.centos.ngx        @/nginx-1.9.9-2.el7.centos.ngx.x86_64
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ nginx -V
nginx version: nginx/1.9.9
built by gcc 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf
--error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid
--lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
--http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=www --group=www --with-http_ssl_module --with-http_realip_module
--with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module
--with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module
--with-http_stub_status_module --with-http_auth_request_module --with-http_image_filter_module --with-threads --with-stream
--with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6
--with-http_v2_module --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong
--param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --add-module=ngx_http_substitutions_filter_module
--add-module=ngx_http_google_filter_module --add-module=ngx-fancyindex
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ rpm -qi nginx
Name        : nginx
Epoch       : 1
Version     : 1.9.9
Release     : 2.el7.centos.ngx
Architecture: x86_64
Install Date: 2015年12月11日 星期五 01时03分20秒
Group       : System Environment/Daemons
Size        : 2215625
License     : 2-clause BSD-like license
Signature   : (none)
Source RPM  : nginx-1.9.9-2.el7.centos.ngx.src.rpm
Build Date  : 2015年12月11日 星期五 00时59分25秒
Build Host  : LookBack-Node.dwhd.org
Relocations : (not relocatable)
Vendor      : nginx inc.
URL         : http://nginx.org
Summary     : High performance web server
Description :
nginx [engine x] is an HTTP and reverse proxy server, as well as a mail proxy server.

add : --with-http_v2_module \
      --with-http_image_filter_module \
      --add-module=ngx_http_google_filter_module \
      --add-module=ngx_http_substitutions_filter_module \
      --add-module=ngx-fancyindex
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ rpm -ql nginx
/data/wwwroot/default
/data/wwwroot/default/50x.html
/data/wwwroot/default/index.html
/etc/logrotate.d/nginx
/usr/lib/systemd/system/nginx-debug.service
/usr/lib/systemd/system/nginx.service
/usr/libexec/initscripts/legacy-actions/nginx
/usr/libexec/initscripts/legacy-actions/nginx/upgrade
/usr/local/nginx
/usr/local/nginx/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/vhost
/usr/local/nginx/conf/vhost/default.conf
/usr/local/nginx/conf/win-utf
/usr/local/nginx/doc/nginx-1.9.9
/usr/local/nginx/doc/nginx-1.9.9/COPYRIGHT
/usr/local/nginx/sbin/nginx
/usr/local/nginx/sbin/nginx-debug
/usr/local/sysconfig/nginx
/usr/local/sysconfig/nginx-debug
/var/cache/nginx
/var/log/nginx
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$
启动试试
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ sudo systemctl enable nginx.service
ln -s '/usr/lib/systemd/system/nginx.service' '/etc/systemd/system/multi-user.target.wants/nginx.service'
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ sudo systemctl start nginx.service
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ sudo systemctl status nginx.service
nginx.service - nginx - high performance web server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled)
   Active: active (running) since 五 2015-12-11 01:41:27 CST; 5s ago
     Docs: http://nginx.org/en/docs/
  Process: 43638 ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)
  Process: 43636 ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf (code=exited, status=0/SUCCESS)
 Main PID: 43640 (nginx)
   CGroup: /system.slice/nginx.service
           ├─43640 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
           ├─43641 nginx: worker process
           └─43642 nginx: worker process

12月 11 01:41:27 LookBack-Node.dwhd.org systemd[1]: Starting nginx - high performance web server...
12月 11 01:41:27 LookBack-Node.dwhd.org nginx[43636]: nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
12月 11 01:41:27 LookBack-Node.dwhd.org nginx[43636]: nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
12月 11 01:41:27 LookBack-Node.dwhd.org nginx[43636]: nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
12月 11 01:41:27 LookBack-Node.dwhd.org nginx[43638]: nginx: [warn] conflicting server name "localhost" on 0.0.0.0:80, ignored
12月 11 01:41:27 LookBack-Node.dwhd.org systemd[1]: Started nginx - high performance web server.
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$ curl localhost
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
[rpmbuild@LookBack-Node ~/rpmbuild/SOURCES]$
CentOS 6 上测试
[root@02748dd85f09 /]# rpm -qi nginx
Name        : nginx                        Relocations: (not relocatable)
Version     : 1.9.9                             Vendor: nginx inc.
Release     : 2.el6.ngx                     Build Date: Thu Dec 10 23:27:58 2015
Install Date: Thu Dec 10 23:28:33 2015         Build Host: 02748dd85f09
Group       : System Environment/Daemons    Source RPM: nginx-1.9.9-2.el6.ngx.src.rpm
Size        : 2145548                          License: 2-clause BSD-like license
Signature   : (none)
URL         : http://nginx.org
Summary     : High performance web server
Description :
nginx [engine x] is an HTTP and reverse proxy server, as well as a mail proxy server.

add : --with-http_v2_module \
      --with-http_image_filter_module \
      --add-module=ngx_http_google_filter_module \
      --add-module=ngx_http_substitutions_filter_module \
      --add-module=ngx-fancyindex
[root@02748dd85f09 /]#

时间: 2024-09-21 07:55:17

Linux使用src rpm包做二次rpm封包的相关文章

Linux源码包制作RPM包之Apache

公司服务器比较多,需要把apache源码包制作成rpm包,然后放到公司内网yum源上进行下载安装.apache的rpm包安装方式比源码安装方式比较快,这能节约不少的时间. 有关内网yum源的搭建,可以参考<烂泥:yum的使用及配置>这篇文章. 一.安装rpm-build 查阅相关资料得知,要把源码包制作成rpm包需要使用rpm打包工具rpm-build. rpm-build通过rpmbuild命令根据本地源码包,通过spec文件中的规则就可以把源码包制作成rpm包. 现在我们来安装rpm-bu

解压rpm包的linux命令及rpm命令使用简介_linux shell

rpm 是红帽(RedHat)软件包管理工具,实现类似于 Windows 中的添加/删除程序功能 rpm -ivh install_rpm tar xvf informix-linux.tar inux下解压命令大全 .tar 解包:tar xvf FileName.tar 打包:tar cvf FileName.tar DirName (注:tar是打包,不是压缩!) --------------- .gz 解压1:gunzip FileName.gz 解压2:gzip -d FileName

CentOS 6.6 x86_64 RPM包制作教程

一.RPM包介绍 对RPM包有五种基本的操作功能:安装.卸载.升级.查询和验证.linux软件包分为两大类:    1. 二进制类包:包括rpm安装包(一般分为i386和x86_64这几种)     2. 源码类包:源码包和开发包(.src.rpm)都是属于此类 有时候为了方便源码包的安装,和我们自己订制软件包的需求,我们会把一些源码包按照我们的需求来做成rpm包,当有源码包就可以直接编译得到二进制安装和其他任意包,另外,我们也可以使用rpm包来打包一些文件或者自己开发的一套软件,使用rpm有数

RHCE学习&lt;3&gt;NFS、Samba、ACL权限、SELinux和RPM包管理

一.NFS网络文件共享服务 1.简单介绍 NFS包含3个版本:NFSv2.NFSv3.NFSv4 RHEL6是以NFSv4作为默认版本,NFSv4使用TCP协议,默认NFS占用5个端口,1个NFS端口(2049),四个动态端口,而老版本的NFS可以在TCP协议或者是UDP协议上运行. /etc/exports:NFS服务的主配置文件,该文件的最主要目的是发布共享目录并为共享目录限制权限. /var/lib/nfs/xtab:这个文件主要用来记录客户端与NFS服务器的连接记录. 格式:共享目录 客

Centos下rpm包如何制作?

  Centos下rpm包如何制作?          谈论RPM对好多编译安装的朋友来多,RPM安装是傻瓜安装. 呵呵,其实RPM是一种非常有效果的集中部署的解决方案. yum+RPM是非常快速便捷的大规模部署方案. 下面简单介绍下rpm的制作: 以cronolog为例: 首先下载cronolog的源码包. 解开源码包,tar xzvf cronolog-1.6.2.tar.gz 找到 cronolog.spec 该文件是定制如何生成RPM包的配置文件 ? 1 2 3 4 5 6 7 8 9

CentOS6.5系统下RPM包安装MySQL5.6

1.查看操作系统相关信息. [root@linuxidc ~]# cat /etc/issue CentOS release 6.5 (Final) Kernel \r on an \m [root@linuxidc ~]# uname -a Linux linuxidc 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux 2.创建需要下载rpm软件包的目录. 1 [ro

YUM解决RPM包安装依赖关系及yum工具介绍本地源配置方法详解_Linux

1.背景概述 在实际生产环境下,对于在linux系统上安装rpm包,主要面临两个实际的问题 1)安装rpm包过程中,不断涌现的依赖关系问题,导致需要按照提示或者查询资料,手工安装更多的包 2)由于内外网的隔离,无法连接外网的yum源 鉴于上述因此,本文将详细介绍,yum工具以及配置本地yum源的方法 2.yum工具简介 •yum工具作为rpm包的软件管理器,可以进行rpm包的安装.升级以及删除等日常管理工作,而且对于rpm包之间的依赖关系可以自动分析,大大简化了rpm包的维护成本. •yum工具

linux下制作安装rpm包的方法

  一.制作rpm包  以rp-pppoe-3.10为列进行制作过程. 1.下载rp-pppoe-3.10.tar.gz [root@localhost home]# pwd /home [root@localhost home]# 2.解压 # tar zxvf rp-pppoe-3.10.tar.gz 3. # cp /home/rp-pppoe-3.10/rp-pppoe.spec /usr/src/redhat/SOURCES/ # cp /home/rp-pppoe-3.10.tar.

初学者-linux下安装rpm包,挂载文件问题

问题描述 linux下安装rpm包,挂载文件问题 1C 求解这是为什么啊...初学者请谅解~ 解决方案 有dependency依赖问题,缺少libcryptolibssl,这个是openssl的库文件,所以你需要现在机器上安装上openssl 解决方案二: 他们两个有什么关系呀? 解决方案三: yum -y install gcc gcc-c++ autoconf automake makeyum -y install zlib zlib-devel openssl openssl--devel