排错 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/*
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/156040.html