rpm打包,rpmbuild SPEC文件深度说明

2024-09-07 09:38

本文主要是介绍rpm打包,rpmbuild SPEC文件深度说明,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

关键字 
spec脚本包括很多关键字,主要有:
引用
Name: 软件包的名称,后面可使用%{name}的方式引用
Summary: 软件包的内容概要
Version: 软件的实际版本号,例如:1.0.1等,后面可使用%{version}引用
Release: 发布序列号,例如:1linuxing等,标明第几次打包,后面可使用%{release}引用
Group: 软件分组,建议使用标准分组
License: 软件授权方式,通常就是GPL
Source: 源代码包,可以带多个用Source1、Source2等源,后面也可以用%{source1}、%{source2}引用
BuildRoot: 这个是安装或编译时使用的“虚拟目录”,考虑到多用户的环境,一般定义为:
%{_tmppath}/%{name}-%{version}-%{release}-root

%{_tmppath}/%{name}-%{version}-%{release}-buildroot-%(%{__id_u} -n}
该参数非常重要,因为在生成rpm的过程中,执行make install时就会把软件安装到上述的路径中,在打包的时候,同样依赖“虚拟目录”为“根目录”进行操作。
后面可使用$RPM_BUILD_ROOT 方式引用。
URL: 软件的主页
Vendor: 发行商或打包组织的信息,例如RedFlag Co,Ltd
Disstribution: 发行版标识
Patch: 补丁源码,可使用Patch1、Patch2等标识多个补丁,使用%patch0或%{patch0}引用
Prefix: %{_prefix} 这个主要是为了解决今后安装rpm包时,并不一定把软件安装到rpm中打包的目录的情况。这样,必须在这里定义该标识,并在编写%install脚本的时候引用,才能实现rpm安装时重新指定位置的功能
Prefix: %{_sysconfdir} 这个原因和上面的一样,但由于%{_prefix}指/usr,而对于其他的文件,例如/etc下的配置文件,则需要用%{_sysconfdir}标识
Build Arch: 指编译的目标处理器架构,noarch标识不指定,但通常都是以/usr/lib/rpm/marcros中的内容为默认值
Requires: 该rpm包所依赖的软件包名称,可以用>=或<=表示大于或小于某一特定版本,例如:
libpng-devel >= 1.0.20 zlib 
※“>=”号两边需用空格隔开,而不同软件名称也用空格分开
还有例如PreReq、Requires(pre)、Requires(post)、Requires(preun)、Requires(postun)、BuildRequires等都是针对不同阶段的依赖指定 
Provides: 指明本软件一些特定的功能,以便其他rpm识别
Packager: 打包者的信息
%description 软件的详细说明


spec脚本主体 
spec脚本的主体中也包括了很多关键字和描述,下面会一一列举。我会把一些特别需要留意的地方标注出来。
%prep 预处理脚本
%setup -n %{name}-%{version} 把源码包解压并放好
通常是从/usr/src/asianux/SOURCES里的包解压到/usr/src/asianux/BUILD/%{name}-%{version}中。
一般用%setup -c就可以了,但有两种情况:一就是同时编译多个源码包,二就是源码的tar包的名称与解压出来的目录不一致,此时,就需要使用-n参数指定一下了。
%patch 打补丁
通常补丁都会一起在源码tar.gz包中,或放到SOURCES目录下。一般参数为:
%patch -p1 使用前面定义的Patch补丁进行,-p1是忽略patch的第一层目录
%Patch2 -p1 -b xxx.patch 打上指定的补丁,-b是指生成备份文件
◎补充一下 
引用
%setup 不加任何选项,仅将软件包打开。 
%setup -n newdir 将软件包解压在newdir目录。 
%setup -c 解压缩之前先产生目录。 
%setup -b num 将第num个source文件解压缩。 
%setup -T 不使用default的解压缩操作。 
%setup -T -b 0 将第0个源代码文件解压缩。 
%setup -c -n newdir 指定目录名称newdir,并在此目录产生rpm套件。 
%patch 最简单的补丁方式,自动指定patch level。 
%patch 0 使用第0个补丁文件,相当于%patch ?p 0。 
%patch -s 不显示打补丁时的信息。 
%patch -T 将所有打补丁时产生的输出文件删除。

%configure 这个不是关键字,而是rpm定义的标准宏命令。意思是执行源代码的configure配置
在/usr/src/asianux/BUILD/%{name}-%{version}目录中进行 ,使用标准写法,会引用/usr/lib/rpm/marcros中定义的参数。
另一种不标准的写法是,可参考源码中的参数自定义,例如:
引用
CFLAGS="$RPM_OPT_FLAGS" CXXFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{_prefix}
%build 开始构建包
在/usr/src/asianux/BUILD/%{name}-%{version}目录中进行make的工作 ,常见写法:
引用
make %{?_smp_mflags} OPTIMIZE="%{optflags}"
都是一些优化参数,定义在/usr/lib/rpm/marcros中
%install 开始把软件安装到虚拟的根目录中
在/usr/src/asianux/BUILD/%{name}-%{version}目录中进行make install的操作。这个很重要,因为如果这里的路径不对的话,则下面%file中寻找文件的时候就会失败。 常见内容有:
%makeinstall 这不是关键字,而是rpm定义的标准宏命令。也可以使用非标准写法:
引用
make DESTDIR=$RPM_BUILD_ROOT install
或 引用
make prefix=$RPM_BUILD_ROOT install
需要说明的是,这里的%install主要就是为了后面的%file服务的。所以,还可以使用常规的系统命令:
引用
install -d $RPM_BUILD_ROOT/
cp -a * $RPM_BUILD_ROOT/

%clean 清理临时文件
通常内容为:
引用
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "$RPM_BUILD_ROOT"
rm -rf $RPM_BUILD_DIR/%{name}-%{version}

※注意区分$RPM_BUILD_ROOT和$RPM_BUILD_DIR:
$RPM_BUILD_ROOT是指开头定义的BuildRoot,而$RPM_BUILD_DIR通常就是指/usr/src/asianux/BUILD,其中,前面的才是%file需要的。 

%pre rpm安装前执行的脚本
%post rpm安装后执行的脚本
%preun rpm卸载前执行的脚本
%postun rpm卸载后执行的脚本
 
%preun %postun 的区别是什么呢?
前者在升级的时候会执行,后者在升级rpm包的时候不会执行

%files 定义那些文件或目录会放入rpm中
这里会在虚拟根目录下进行,千万不要写绝对路径,而应用宏或变量表示相对路径。 如果描述为目录,表示目录中除%exclude外的所有文件。
%defattr (-,root,root) 指定包装文件的属性,分别是(mode,owner,group),-表示默认值,对文本文件是0644,可执行文件是0755

%exclude 列出不想打包到rpm中的文件
※小心,如果%exclude指定的文件不存在,也会出错的。 
%changelog 变更日志

※特别需要注意的是:%install部分使用的是绝对路径,而%file部分使用则是相对路径,虽然其描述的是同一个地方。千万不要写错。


就是%file中必须明白,用的是相对目录 引用
%files 
%defattr(-,root,root) 
%{_bindir} 
%{_libdir} 
%{_datadir} 
%exclude %{_libdir}/debug

制作补丁 
详细看参考: [原]使用diff同patch工具 

如何编写%file段 
由于必须在%file中包括所有套件中的文件,所以,我们需要清楚编译完的套件到底包括那些文件?
常见的做法是,人工模拟一次编译的过程:

 这样,整个套件的内容就会被放到/usr/local/xxx中,可根据情况编写%file和%exclude段。

※当然,这个只能对源码按GNU方式编写,并使用GNU autotool创建的包有效,若自定义Makefile则不能一概而论。 
关于rpm中的执行脚本 
如果正在制作的rpm包是准备作为放到系统安装光盘中的话,则需要考虑rpm中定义的脚本是否有问题。由于系统在安装的时候只是依赖于一个小环境进行,而该环境与实际安装完的环境有很大的区别,所以,大部分的脚本在该安装环境中都是无法生效,甚至会带来麻烦的。
所以,对于这样的,需要放到安装光盘中的套件,不加入执行脚本是较佳的方法。
另外,为提供操作中可参考的信息,rpm还提供了一种信号机制:不同的操作会返回不同的信息,并放到默认变量$1中。

 

引用
0代表卸载、1代表安装、2代表升级

 

一.RPM制作步骤

我们在企业中有的软件基本都是编译的,我们每次安装都得编译,那怎么办呢?那就根据我们的需求制作RPM安装包吧。先来说说基本布骤:

1.Planning what you want             计划做什么rpm包。软件的?库的?

2.Gathering the software to package  收集原材料,即收集源码包

3.Patch the software as need         如果需要打补丁,收集补丁文件。此布骤不是必须

4.Outling any dependenies      确定依赖关系包

------------------  上述动作可由我们手动编译一次软件来确定  -------------------

5.Building RPMs                      开始动手制作RPM包

5.1 Set up the directory stucture 设定好目录结构,我们在这些目录中制作我们的RPM包,我们需要下列目录

BUILD 源代码解压后的存放目录

RPMS    制作完成后的RPM包存放目录,里面有与平台相关的子目录

SOURCES 收集的源材料,补丁的存放位置

SPECS   SPEC文件存放目录

SRMPS   存放SRMPS生成的目录

5.2 Place the Sources in the right directory   把源材料放到正确的位置

5.3 Create a spec file that tell rpmbuild command what to do 创建spec文件,这是纲领文件,rpmbuild命令根据spec文件来制作合适的rpm包

5.4 Build the source and binary RPMS 制作src或二进制rpm包

6.Test RPMS 测试制作的PRM包

7.Add signature for RPM  为RPM包签名

二.RPM包制作实例

我还是用连贯的 话为大家叙述一遍吧,我们首先确实我们要为什么做rpm包,通常我们是为一些软件,比如httpd,nginx等,然后去收集这些软件包的源代码,如果有 需要的话也收集这些补丁文件,手动编译安装一下这个软件(当然如果是不需要编译的就不用演练了),确定依赖的软件包,并记录下来,下面开始准备制作 tengine的PRM包吧:

1.建立一个普通用户,有普通用户来制作rpm,用root的可能会因为代码问题导致毁灭的后果

  1. useradd ibuler 
  2. su - ibuler 

2.确定我们在 哪个目录下制作RPM,通常这个目录我们topdir,这个需要在宏配置文件中指定,这个配置文件称为macrofiles,它们通常为 /usr/lib/rpm/macros:/usr/lib/rpm/macros.*:~/.rpmmacros,这个在rhel 5.8中可以通过rpmbuild --showrc | grep macrofiles  查看,6.3的我使用这个找不到,但使用是一样的。你可以通过rpmbuild --showrc | grep topdir 查看你系统默认的工作车间 

  1. rpmbuild --showrc | grep topdir 
  2.  
  3. -14: _builddir  %{_topdir}/BUILD 
  4. -14: _buildrootdir  %{_topdir}/BUILDROOT 
  5. -14: _rpmdir    %{_topdir}/RPMS 
  6. -14: _sourcedir %{_topdir}/SOURCES 
  7. -14: _specdir   %{_topdir}/SPECS 
  8. -14: _srcrpmdir %{_topdir}/SRPMS 
  9. -14: _topdir    %{getenv:HOME}/rpmbuild 

我们还是自定义工作目录(或车间)吧

  1. vi ~/.rpmmacros 
  2. %_topdir        /home/ibuler/rpmbuild    ##目录可以自定义 
  3.  
  4. mkdir ~/rpmbuild  

3.在topdir下建立需要的目录

  1. cd ~/rpmbuild  
  2. mkdir -pv {BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} 

4.把收集的源码放到SOURCES下

  1. cp /tmp/tengine-1.4.2.tar.gz SOURCES  ##事先放好的

5.在SPECS下建立重要的spec文件

  1. cd SPECS 
  2. vi tengine.spec          ##内容见后讲解,rhel6.3会自动生成模板 

6.用rpmbuild命令制作rpm包,rpmbuild命令会根据spec文件来生成rpm包 

  1. rpmbuild  
  2. -ba 既生成src.rpm又生成二进制rpm 
  3. -bs 只生成src的rpm 
  4. -bb 只生二进制的rpm 
  5. -bp 执行到pre 
  6. -bc 执行到 build段 
  7. -bi 执行install段 
  8. -bl 检测有文件没包含 

我们可以一步步试,先rpmbuild -bp ,再-bc 再-bi 如果没问题,rpmbuild -ba 生成src包与二进制包吧

7.安装测试有没有问题,能否正常安装运行,能否正常升级,卸载有没有问题

root用户测试安装:

  1. cd /tmp
  2. cp /home/ibuler/rpmbuild/RPMS/x86_64/tengine-1.4.2-1.el6.x86_64.rpm /tmp  
  3. rpm -ivh tengine-1.4.2-1.el6.x86_64.rpm  ##测试安装 
  4. rpm -e tengine                           ##测试卸载,如果版本号比原来的高,升级测试 

8.如果没问题为rpm包签名吧,防止有人恶意更改    ##这个先不写了,有点晚了,以后补上

到此整个流程完毕。下面来说说其中最最重要的spec的格式,先说最简单的,最容易实现的

到此一个简单的tengine RPM包制作好了。

三.RPM包制作拓展

下面我们来拓展一下,比如:我们想为tengine增加控制脚本,可以通过 start|stop控制,我们还想更换一下默认的首页index.html,默认的fastcgi_params是不能直接连接php的,所以我们替换 为新的配置文件,我们也可以用设置好的nginx.conf替换原来的nginx.conf。基于上述步骤下面继续

1.把修改后的首页文件index.html,控制脚本init.nginx,fastCGI配置文件fastcgi_params,Nginx配置文件nginx.conf 放到SOURCES中 。 

  1. [ibuler@ng1 rpmbuild]$ ls SOURCES/ 
  2. fastcgi_params  index.html  init.nginx  nginx.conf  tengine-1.4.2.tar.gz 

2 编辑tengine.spec,修改

2.1 介绍区域的SOURCE0下增加如下

  1. Source0:        %{name}-%{version}.tar.gz 
  2. Source1:        index.html 
  3. Source2:        init.nginx 
  4. Source3:        fastcgi_params 
  5. Source4:        nginx.conf 

2.2 安装区域增加如下

  1. make install DESTDIR=%{buildroot} 
  2. %{__install} -p -D %{SOURCE1} %{buildroot}/usr/html/index.html  #%{__install}这个宏代表install命令
  3. %{__install} -p -D -m 0755 %{SOURCE2} %{buildroot}/etc/rc.d/init.d/nginx 
  4. %{__install} -p -D %{SOURCE3} %{buildroot}/etc/nginx/fastcgi_params 
  5. %{__install} -p -D %{SOURCE4} %{buildroot}/etc/nginx/nginx.conf 

2.3 脚本区域增加如下

  1. %post 
  2. if [ $1 == 1 ];then 
  3.         /sbin/chkconfig --add nginx 
  4. fi 

2.4 %file区域增加如下

  1. %files 
  2. %defattr (-,root,root,0755) 
  3. /etc/ 
  4. /usr/ 
  5. /var/ 
  6. %config(noreplace) /etc/nginx/nginx.conf  #%config表明这是个配置文件noplace表明不能替换
  7. %config(noreplace) /etc/nginx/fastcgi_params 
  8. %doc /usr/html/index.html  #%doc表明这个是文档
  9. %attr(0755,root,root) /etc/rc.d/init.d/nginx #%attr后面的是权限,属主,属组

3. 生成rpm文件测试

  1. rpmbuild -ba tengine.spec 

4. 安装测试 

到此RPM包制作完毕,你可以根据你的需求制作RPM包吧。

四.RPM包签名

1.生成GPG签名密钥,我用的是root用户

  1. gpg --gen-key 
  2.  
  3. Your selection?1<Enter>  ##默认即可
  4. What keysize do you want? (2048) 1024<Enter>  ##密钥长度
  5. Key is valid for? (0) 1y<Enter>  ##有效期
  6. Is this correct? (y/N) y<Enter>  ##确认
  7. Real name: LaoGuang<Enter>  ##密钥名称
  8. Email address: ibuler@qq.com<Enter>  ##邮件
  9. Comment: GPG-RPM-KEY<Enter>  ##备注
  10. Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O<ENTER
  11. Enter passphrase  OK <Enter>  ##使用空密码,也可以输入                              
  12. <Take this one anyway<Enter
  13. <Take this one anyway<Enter

有时可能因为随机数不够导致卡在那里,这时候你就yum 安装几个包组,马上就够了。

2.查看成生的密钥

  1. [root@ng1 dev]# gpg --list-keys 
  2. /root/.gnupg/pubring.gpg 
  3. ------------------------ 
  4. pub   1024R/49C99488 2012-11-28 [expires: 2013-11-28] 
  5. uid                  LaoGuang (GPG-RPM-KEY) <ibuler@qq.com
  6. sub   1024R/69BA199D 2012-11-28 [expires: 2013-11-28] 

3.导出公钥以供大家使用验证

  1. gpg --export -a "LaoGuang" > RPM-GPG-KEY-LaoGuang 

4.编缉 .rpmmacros说明我们用哪一个密钥加密,我们用root加密的那就在/root下编辑

  1. vi ~/.rpmmacros 
  2. %_gpg_name LaoGuang 

5.为rpm包加签名

  1.  rpm --addsign tengine-1.4.2-1.el6.x86_64.rpm  
  2. Enter pass phrase:   ##输入密钥
  3. Pass phrase is good. 
  4. tengine-1.4.2-1.el6.x86_64.rpm: 

到此签名添加成功,下面来验证

6.讲刚才导出的公钥导入rpm中

  1. rpm --import RPM-GPG-KEY-LaoGuang 

7.验证

  1. rpm --checksig tengine-1.4.2-1.el6.x86_64.rpm  
  2.  
  3. tengine-1.4.2-1.el6.x86_64.rpm: rsa sha1 (md5) pgp md5 OK 

到此整个过程完毕,你也试试吧




Group:

软件包所属类别,具体类别有:

Amusements/Games (娱乐/游戏)

Amusements/Graphics(娱乐/图形)

Applications/Archiving (应用/文档)

Applications/Communications(应用/通讯)

Applications/Databases (应用/数据库

Applications/Editors (应用/编辑器)

Applications/Emulators (应用/仿真器)

Applications/Engineering (应用/工程)

Applications/File (应用/文件)

Applications/Internet (应用/因特网)

Applications/Multimedia(应用/多媒体)

Applications/Productivity (应用/产品)

Applications/Publishing(应用/印刷)

Applications/System(应用/系统)

Applications/Text (应用/文本)

Development/Debuggers (开发/调试器)

Development/Languages (开发/语言)

Development/Libraries (开发/函数库)

Development/System (开发/系统)

Development/Tools (开发/工具)

Documentation (文档)

System Environment/Base(系统环境/基础)

System Environment/Daemons (系统环境/守护)

System Environment/Kernel (系统环境/内核)

System Environment/Libraries (系统环境/函数库)

System Environment/Shells (系统环境/接口)

User Interface/Desktops(用户界面/桌面)

User Interface/X (用户界面/X窗口)

User Interface/X Hardware Support (用户界面/X硬件支持)


测试通过实例:

cat rpmbuild/SPECS/tengine.spec
# This is a sample spec file for test rpm package
%define _prefix    /usr/local/nginx
%define _user      nobody
%define _user_uid  99
%define _group     nobody
%define _group_uid 99
%define _sbin_path      /usr/sbin%define name      Tengine
%define summary   Tengine for Webserver
%define version   2.1.2
%define release   1
%define license   GPL
%define group     Application/WebServer
%define source    tengine-%{version}.tar.gz
%define url       http://tengine.taobao.org/
%define vendor    Taobao
%define packager  webuserName:           tengine
Version:        2.1.2  
Vendor:         Taobao
Release:    1
Summary:    GUN Tengine2.1.2Group:      Application/WebServer
License:    GPL
URL:            http://tengine.taobao.org/ 
Source0:    tengine-%{version}.tar.gz
Source1:        index.html
Source2:        nginx
Source3:        fastcgi_params
Source4:        nginx.conf
Packager:       webuser
#BuildRoot: /www/rpmbuild/%{name}-%{version}-%{release}-rpmbuild
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root #BuildRequires: gcc>=4.4.7, gcc-c++>=4.4.7, zlib-devel>=1.2.3, pcre-devel>=8.12, openssl-devel>=1.0.1e, autoconf>=2.63, automake>=1.11.1
#BuildRequires:  mhash-devel
#BuildRequires:  libxml2-devel
#BuildRequires:  libxslt-devel
#BuildRequires:  libgd-devel
#
#Requires:  gcc>=4.4.7, gcc-c++>=4.4.7, zlib-devel>=1.2.3, pcre-devel>=8.12, openssl-devel>=1.0.1e, autoconf>=2.63, automake>=1.11.1
#Requires:      mhash-devel
#Requires:      libxml2-devel
#Requires:      libxslt-devel
#Requires:      libgd-devel%description
The GNU Tengine WEB Server program. %prep
%setup -q -n tengine-%{version}%build
./configure \--user=nobody \--group=nobody \--prefix=/usr/local/nginx \--with-ipv6 \--with-debug \--with-http_sub_module \--with-http_stub_status_module \--with-http_ssl_module \--with-http_spdy_module \--with-http_v2_module \--with-http_realip_module \--with-http_gzip_static_module \--with-http_auth_request_module \--with-http_perl_module \--with-pcre \--add-module=../ngx_cache_purge-2.3  
make%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
%{__install} -p -D %{SOURCE1} %{buildroot}/usr/local/nginx/html/index.html
%{__install} -p -D -m 0755 %{SOURCE2} %{buildroot}/etc/rc.d/init.d/nginx
%{__install} -p -D %{SOURCE3} %{buildroot}/usr/local/nginx/conf/fastcgi_params
%{__install} -p -D %{SOURCE4} %{buildroot}/usr/local/nginx/conf/nginx.confmkdir -p %{buildroot}/%{_initrddir}
(
cat <<'EOF'
#!/bin/bash
# tengine Startup script for the tengine HTTP Server
# this script create it by Luo Hui at 2008.11.11.
# if you find any errors on this scripts,please contact Luo Hui.
# and send mail to farmer.luo at gmail dot com.
#
# chkconfig: - 85 15
# description: tengine is a high-performance web and proxy server.
# processname: tengine
# tengine pidfile: /var/run/tengine.pid
# tengine config: /usr/local/tengine/conf/nginx.confnginxd=%{_prefix}/sbin/nginx
nginx_config=%{_prefix}/conf/nginx.conf
nginx_pid=/var/run/tengine.pidRETVAL=0
prog="nginx"# Source function library.
. /etc/rc.d/init.d/functions# Source networking configuration.
. /etc/sysconfig/network# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0[ -x $nginxd ] || exit 0ulimit -HSn 65535# Start tengine daemons functions.
nginx_start() {if [ -e $nginx_pid ];thenecho "tengine already running...."exit 1fiif [ ! -d %{_prefix}/logs ];thenmkdir -p %{_prefix}/logsfiif [ ! -d %{_prefix}/tmp ]; thenmkdir -p %{_prefix}/tmpfiif [ -e $nginx_pid ];thenecho "tengine already running...."exit 1fiecho -n $"Starting $prog: "daemon $nginxd -c ${nginx_config}RETVAL=$?echo[ $RETVAL = 0 ] && touch /var/lock/subsys/tenginereturn $RETVAL}# Stop tengine daemons functions.
nginx_stop() {echo -n $"Stopping $prog: "killproc $nginxdRETVAL=$?echo[ $RETVAL = 0 ] && rm -f /var/lock/subsys/tengine $nginx_pid
}# reload tengine service functions.
nginx_reload() {echo -n $"Reloading $prog: "#kill -HUP `cat ${nginx_pid}`killproc $nginxd -HUPRETVAL=$?echo}# See how we were called.
case "$1" in
start)nginx_start;;stop)nginx_stop;;reload)nginx_reload;;restart)nginx_stopnginx_start;;status)status $progRETVAL=$?;;
*)echo $"Usage: tengine {start|stop|restart|reload|status|help}"exit 1
esacexit $RETVAL
EOF
) >%{buildroot}/%{_initrddir}/tenginechmod 755 %{buildroot}/%{_initrddir}/tengine%clean
rm -rf %{buildroot}%pre
grep -q ^%{_group}: /etc/group || %{_sbin_path}/groupadd -g %{_group_gid} %{_group}
grep -q ^%{_user}: /etc/passwd || %{_sbin_path}/useradd -g %{_group} -u %{_user_uid} -d %{_prefix} -s /sbin/nologin -M %{_user}%post
chkconfig --add tengine
chkconfig --level 345 tengine on%preun
chkconfig --del tengine#%postun
#if [ $1 = 0 ]; then
#        userdel %{_user} > /dev/null 2>&1 || true
#fi%files
%defattr(-,root,root,-)
%dir %{_prefix}/
%attr(0755,%{_user},%{_group}) %dir %{_prefix}/logs
%dir %{_prefix}/modules
%dir %{_prefix}/sbin
%dir %{_prefix}/conf
%dir %{_prefix}/html
%{_prefix}/sbin/nginx
%{_prefix}/sbin/dso_tool
%{_prefix}/conf/module_stubs
%{_prefix}/conf/fastcgi.conf
%{_prefix}/conf/fastcgi_params.default
%{_prefix}/conf/win-utf
%{_prefix}/conf/koi-utf
%{_prefix}/conf/nginx.conf.default
%{_prefix}/conf/fastcgi.conf.default
%config(noreplace) %{_prefix}/conf/fastcgi_params
%{_prefix}/conf/koi-win
%{_prefix}/conf/mime.types
%config(noreplace) %{_prefix}/conf/nginx.conf
%{_prefix}/conf/mime.types.default
%{_prefix}/conf/scgi_params
%{_prefix}/conf/scgi_params.default
%{_prefix}/conf/uwsgi_params
%{_prefix}/conf/uwsgi_params.default
%{_prefix}/html/50x.html
%{_prefix}/html/index.html
/usr/lib64/perl5/perllocal.pod
/usr/local/lib64/perl5/auto/nginx/.packlist
/usr/local/lib64/perl5/auto/nginx/nginx.bs
/usr/local/lib64/perl5/auto/nginx/nginx.so
/usr/local/lib64/perl5/nginx.pm
%{_prefix}/conf/browsers
%{_prefix}/include/nginx.h
%{_prefix}/include/ngx_alloc.h
%{_prefix}/include/ngx_array.h
%{_prefix}/include/ngx_atomic.h
%{_prefix}/include/ngx_auto_config.h
%{_prefix}/include/ngx_auto_headers.h
%{_prefix}/include/ngx_buf.h
%{_prefix}/include/ngx_channel.h
%{_prefix}/include/ngx_conf_file.h
%{_prefix}/include/ngx_config.h
%{_prefix}/include/ngx_connection.h
%{_prefix}/include/ngx_core.h
%{_prefix}/include/ngx_crc.h
%{_prefix}/include/ngx_crc32.h
%{_prefix}/include/ngx_crypt.h
%{_prefix}/include/ngx_cycle.h
%{_prefix}/include/ngx_errno.h
%{_prefix}/include/ngx_event.h
%{_prefix}/include/ngx_event_busy_lock.h
%{_prefix}/include/ngx_event_connect.h
%{_prefix}/include/ngx_event_openssl.h
%{_prefix}/include/ngx_event_pipe.h
%{_prefix}/include/ngx_event_posted.h
%{_prefix}/include/ngx_event_timer.h
%{_prefix}/include/ngx_file.h
%{_prefix}/include/ngx_files.h
%{_prefix}/include/ngx_gcc_atomic_x86.h
%{_prefix}/include/ngx_hash.h
%{_prefix}/include/ngx_http.h
%{_prefix}/include/ngx_http_busy_lock.h
%{_prefix}/include/ngx_http_cache.h
%{_prefix}/include/ngx_http_config.h
%{_prefix}/include/ngx_http_core_module.h
%{_prefix}/include/ngx_http_perl_module.h
%{_prefix}/include/ngx_http_reqstat.h
%{_prefix}/include/ngx_http_request.h
%{_prefix}/include/ngx_http_script.h
%{_prefix}/include/ngx_http_spdy.h
%{_prefix}/include/ngx_http_spdy_module.h
%{_prefix}/include/ngx_http_ssi_filter_module.h
%{_prefix}/include/ngx_http_ssl_module.h
%{_prefix}/include/ngx_http_upstream.h
%{_prefix}/include/ngx_http_upstream_round_robin.h
%{_prefix}/include/ngx_http_v2.h
%{_prefix}/include/ngx_http_v2_module.h
%{_prefix}/include/ngx_http_variables.h
%{_prefix}/include/ngx_inet.h
%{_prefix}/include/ngx_linux.h
%{_prefix}/include/ngx_linux_config.h
%{_prefix}/include/ngx_list.h
%{_prefix}/include/ngx_log.h
%{_prefix}/include/ngx_md5.h
%{_prefix}/include/ngx_murmurhash.h
%{_prefix}/include/ngx_open_file_cache.h
%{_prefix}/include/ngx_os.h
%{_prefix}/include/ngx_palloc.h
%{_prefix}/include/ngx_parse.h
%{_prefix}/include/ngx_pipe.h
%{_prefix}/include/ngx_proc.h
%{_prefix}/include/ngx_process.h
%{_prefix}/include/ngx_process_cycle.h
%{_prefix}/include/ngx_proxy_protocol.h
%{_prefix}/include/ngx_queue.h
%{_prefix}/include/ngx_radix_tree.h
%{_prefix}/include/ngx_rbtree.h
%{_prefix}/include/ngx_regex.h
%{_prefix}/include/ngx_resolver.h
%{_prefix}/include/ngx_segment_tree.h
%{_prefix}/include/ngx_setaffinity.h
%{_prefix}/include/ngx_setproctitle.h
%{_prefix}/include/ngx_sha1.h
%{_prefix}/include/ngx_shmem.h
%{_prefix}/include/ngx_shmtx.h
%{_prefix}/include/ngx_slab.h
%{_prefix}/include/ngx_socket.h
%{_prefix}/include/ngx_string.h
%{_prefix}/include/ngx_sysinfo.h
%{_prefix}/include/ngx_syslog.h
%{_prefix}/include/ngx_thread.h
%{_prefix}/include/ngx_time.h
%{_prefix}/include/ngx_times.h
%{_prefix}/include/ngx_trie.h
%{_prefix}/include/ngx_user.h
/usr/local/share/man/man3/nginx.3pm
%{_initrddir}/tengine
%doc /usr/local/nginx/html/index.html
%attr(0775,root,root) /etc/rc.d/init.d/nginx%changelog
* Mon Jul 4 2016 Beijing <schangech@gmail.com>
- ver 2.1.2

这篇关于rpm打包,rpmbuild SPEC文件深度说明的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1144710

相关文章

Linux join命令的使用及说明

《Linuxjoin命令的使用及说明》`join`命令用于在Linux中按字段将两个文件进行连接,类似于SQL的JOIN,它需要两个文件按用于匹配的字段排序,并且第一个文件的换行符必须是LF,`jo... 目录一. 基本语法二. 数据准备三. 指定文件的连接key四.-a输出指定文件的所有行五.-o指定输出

Java中Redisson 的原理深度解析

《Java中Redisson的原理深度解析》Redisson是一个高性能的Redis客户端,它通过将Redis数据结构映射为Java对象和分布式对象,实现了在Java应用中方便地使用Redis,本文... 目录前言一、核心设计理念二、核心架构与通信层1. 基于 Netty 的异步非阻塞通信2. 编解码器三、

Java HashMap的底层实现原理深度解析

《JavaHashMap的底层实现原理深度解析》HashMap基于数组+链表+红黑树结构,通过哈希算法和扩容机制优化性能,负载因子与树化阈值平衡效率,是Java开发必备的高效数据结构,本文给大家介绍... 目录一、概述:HashMap的宏观结构二、核心数据结构解析1. 数组(桶数组)2. 链表节点(Node

Java 虚拟线程的创建与使用深度解析

《Java虚拟线程的创建与使用深度解析》虚拟线程是Java19中以预览特性形式引入,Java21起正式发布的轻量级线程,本文给大家介绍Java虚拟线程的创建与使用,感兴趣的朋友一起看看吧... 目录一、虚拟线程简介1.1 什么是虚拟线程?1.2 为什么需要虚拟线程?二、虚拟线程与平台线程对比代码对比示例:三

Python函数作用域与闭包举例深度解析

《Python函数作用域与闭包举例深度解析》Python函数的作用域规则和闭包是编程中的关键概念,它们决定了变量的访问和生命周期,:本文主要介绍Python函数作用域与闭包的相关资料,文中通过代码... 目录1. 基础作用域访问示例1:访问全局变量示例2:访问外层函数变量2. 闭包基础示例3:简单闭包示例4

Redis中Hash从使用过程到原理说明

《Redis中Hash从使用过程到原理说明》RedisHash结构用于存储字段-值对,适合对象数据,支持HSET、HGET等命令,采用ziplist或hashtable编码,通过渐进式rehash优化... 目录一、开篇:Hash就像超市的货架二、Hash的基本使用1. 常用命令示例2. Java操作示例三

Redis中Set结构使用过程与原理说明

《Redis中Set结构使用过程与原理说明》本文解析了RedisSet数据结构,涵盖其基本操作(如添加、查找)、集合运算(交并差)、底层实现(intset与hashtable自动切换机制)、典型应用场... 目录开篇:从购物车到Redis Set一、Redis Set的基本操作1.1 编程常用命令1.2 集

Python打包成exe常用的四种方法小结

《Python打包成exe常用的四种方法小结》本文主要介绍了Python打包成exe常用的四种方法,包括PyInstaller、cx_Freeze、Py2exe、Nuitka,文中通过示例代码介绍的非... 目录一.PyInstaller11.安装:2. PyInstaller常用参数下面是pyinstal

Python sys模块的使用及说明

《Pythonsys模块的使用及说明》Pythonsys模块是核心工具,用于解释器交互与运行时控制,涵盖命令行参数处理、路径修改、强制退出、I/O重定向、系统信息获取等功能,适用于脚本开发与调试,需... 目录python sys 模块详解常用功能与代码示例获取命令行参数修改模块搜索路径强制退出程序标准输入

nodejs打包作为公共包使用的完整流程

《nodejs打包作为公共包使用的完整流程》在Node.js项目中,打包和部署是发布应用的关键步骤,:本文主要介绍nodejs打包作为公共包使用的相关资料,文中通过代码介绍的非常详细,需要的朋友可... 目录前言一、前置准备二、创建与编码三、一键构建四、本地“白嫖”测试(可选)五、发布公共包六、常见踩坑提醒