排错 rpmbuild -ba ***.spec时出现 警告:发现已安装(但未打包的)文件/错误:警告:发现已安装(但未打包的)文件

排错 rpmbuild -ba ***.spec时出现 警告:发现已安装(但未打包的)文件/错误:警告:发现已安装(但未打包的)文件

  • 问题出现:

学习Nginx rpm打包时候,他原本的配置是 :

	# 编译阶段执行的命令
	%build
	./configure
	make

那就是默认配置安装,按照他的做可以配置,rpmbuild -ba nginx.spec ,可以生成rpm包。但是作为新时代新青年,这默认安装就能拿下我吗?显然不可能,那好,咱们就要yum/rpm包有编译安装的味道,我想加模块就加模块,我想定义路径,就定义路径。于是新时代新青年版改动就来了,如下:

	
	%build
	./configure --user=nginx --group=nginx --prefix=/opt/nginx --conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/sbin/nginx --error-log-path=/var/log/nginx/nginx_error.log --http-log-path=/var/log/nginx/nginx_access.log --pid-path=/usr/local/nginx/run/nginx.pid
	make 

如此,我就想加什么配置参数都可以,想配置什么模块也行,那么程序能轻易让我得逞吗?显然是不能
rpmbuild -ba nginx.spec结果如下

[root@bcchost SPECS]# rpmbuild -ba nginx.spec
执行(%prep): /bin/sh -e /var/tmp/rpm-tmp.bfNLUG
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd /root/rpmbuild/BUILD
+ rm -rf nginx-1.22.1
+ /usr/bin/tar -xf -
+ /usr/bin/gzip -dc /root/rpmbuild/SOURCES/nginx-1.22.1.tar.gz
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd nginx-1.22.1
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ exit 0
执行(%build): /bin/sh -e /var/tmp/rpm-tmp.pj2whF
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd nginx-1.22.1
+ ./configure --user=nginx --group=nginx --prefix=/opt/nginx --conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/sbin/nginx --error-log-path=/var/log/nginx/nginx_error.log --http-log-path=/var/log/nginx/nginx_access.log --pid-path=/usr/local/nginx/run/nginx.pid
checking for OS
 + Linux 3.10.0-1160.76.1.el7.x86_64 x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) 
checking for gcc -pipe switch ... found
... ... (中间太多无用信息省略)
creating objs/Makefile

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library

  nginx path prefix: "/opt/nginx"
  nginx binary file: "/usr/sbin/nginx"
  nginx modules path: "/opt/nginx/modules"
  nginx configuration prefix: "/etc/nginx"
  nginx configuration file: "/etc/nginx/nginx.conf"
  nginx pid file: "/usr/local/nginx/run/nginx.pid"
  nginx error log file: "/var/log/nginx/nginx_error.log"
  nginx http access log file: "/var/log/nginx/nginx_access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

+ make
make -f objs/Makefile
make[1]: Entering directory `/root/rpmbuild/BUILD/nginx-1.22.1'

... ... (中间太多无用信息省略)

make[1]: Leaving directory `/root/rpmbuild/BUILD/nginx-1.22.1'
+ exit 0
执行(%install): /bin/sh -e /var/tmp/rpm-tmp.rhFPbw
+ umask 022
+ cd /root/rpmbuild/BUILD
+ '[' /root/rpmbuild/BUILDROOT/nginx-1.22.1-1.el7.centos.x86_64 '!=' / ']'
+ rm -rf /root/rpmbuild/BUILDROOT/nginx-1.22.1-1.el7.centos.x86_64
++ dirname /root/rpmbuild/BUILDROOT/nginx-1.22.1-1.el7.centos.x86_64
+ mkdir -p /root/rpmbuild/BUILDROOT
+ mkdir /root/rpmbuild/BUILDROOT/nginx-1.22.1-1.el7.centos.x86_64
+ cd nginx-1.22.1
+ make install DESTDIR=/root/rpmbuild/BUILDROOT/nginx-1.22.1-1.el7.centos.x86_64
make -f objs/Makefile install
make[1]: Entering directory `/root/rpmbuild/BUILD/nginx-1.22.1'

... ... (中间太多无用信息省略)

+ '[' '%{buildarch}' = noarch ']'
+ QA_CHECK_RPATHS=1
+ case "${QA_CHECK_RPATHS:-}" in
+ /usr/lib/rpm/check-rpaths
+ /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/brp-python-bytecompile /usr/bin/python 1
+ /usr/lib/rpm/redhat/brp-python-hardlink
+ /usr/lib/rpm/redhat/brp-java-repack-jars
处理文件:nginx-1.22.1-1.el7.centos.x86_64
Provides: nginx = 1.22.1-1.el7.centos nginx(x86-64) = 1.22.1-1.el7.centos
Requires(interp): /bin/sh /bin/sh
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires(post): /bin/sh
Requires(preun): /bin/sh
处理文件:nginx-debuginfo-1.22.1-1.el7.centos.x86_64
Provides: nginx-debuginfo = 1.22.1-1.el7.centos nginx-debuginfo(x86-64) = 1.22.1-1.el7.centos
Requires(rpmlib): rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
检查未打包文件:/usr/lib/rpm/check-files /root/rpmbuild/BUILDROOT/nginx-1.22.1-1.el7.centos.x86_64
警告:发现已安装(但未打包的)文件:
   /usr/sbin/nginx
   /opt/nginx/html/50x.html
   /opt/nginx/html/index.html

  • 分析问题

好的,重点来了,遇到这个问题应该怎么办呢,最开始我是这样解决的
解决方式一:注释,不检测
问题解决了吗?解决了,但是没完全解决,出现什么情况,我打包成功了,传入新机器,发现我做出的改变,编译方式出现的文件都没有,而且

	/usr/sbin/nginx
   /opt/nginx/html/50x.html
   /opt/nginx/html/index.html

在新机器没生成,那么就很难受,我为了什么,为了生成新的包,指定路径上有我的文件啊。
那么怎么解决呢?

  • 解决

在打包时候,进行打包不就好了嘛

	%files
	%{_prefix}/local/*   #原来的

改版

	%files
	%{_prefix}/local/*
	/etc/nginx/*
	%{_prefix}/sbin/nginx
	/opt/nginx/*  #改版后

改版后全部源代码

Name:           nginx   
Version:        1.22.1
Release:        1%{?dist}
Summary:        "nginx"project
Summary(zh_CN): "nginx"项目

License:        GPLv3+
URL:            http://nginx.org/download/      
Source0:        nginx-1.22.1.tar.gz

BuildRequires:  gcc
Requires:       pcre-devel zlib-devel

%description  -l zh_CN
这是nginx的项目


%prep
%setup -q


%build
./configure --user=nginx --group=nginx --prefix=/opt/nginx --conf-path=/etc/nginx/nginx.conf --sbin-path=/usr/sbin/nginx --error-log-path=/var/log/nginx/nginx_error.log --http-log-path=/var/log/nginx/nginx_access.log --pid-path=/usr/local/nginx/run/nginx.pid
#./configure 
make 


%install
#%define _unpackaged_files_terminate_build 0
rm -rf %{buildroot}/*
make install DESTDIR=%{buildroot}

# 安装后执行的命令
%post
useradd nginx -M -s /sbin/nologin
/usr/sbin/nginx
 
# 卸载前执行的命令
%preun
userdel -r nginx
 
# 将所需要打包的文件都存放到这边中;-f %{name}.lang 加上后的意思为声明找到的文件

%files
%{_prefix}/local/*
/etc/nginx/*
%{_prefix}/sbin/nginx
/opt/nginx/*

特别鸣谢
老王笔记
mtOS1573
提供的学习和解答文章,可以帮忙点点浏览量

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

(~ ̄▽ ̄)~凤凰涅槃

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值