Linux RPM 构建错误:空 debugsourcefiles.list文件

最近在学习鸟哥的Linux私房菜基础篇,遇到了一些问题。
环境:CentOS8
在第22章SPRM打包,一个打包自己的软件的范例中,按照鸟哥的配置部署了main.spec,rpmbuild -ba main.spec后,却显示:

[root@zl SPECS]# rpmbuild -ba main.spec
正在执行(%prep):/bin/sh -e /var/tmp/rpm-tmp.weuNRc
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd /root/rpmbuild/BUILD
+ rm -rf main-0.1
+ /usr/bin/gzip -dc /root/rpmbuild/SOURCES/main-0.1.tgz
+ /usr/bin/tar -xof -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd main-0.1
+ /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ echo 'Patch #0 (main_0.1_to_0.2.patch):'
Patch #0 (main_0.1_to_0.2.patch):
+ /usr/bin/patch --no-backup-if-mismatch -p1 --fuzz=0
patching file cos_value.c
patching file main.c
patching file Makefile
patching file sin_value.c
+ exit 0
正在执行(%build):/bin/sh -e /var/tmp/rpm-tmp.PdUJfR
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd main-0.1
+ make clean main
rm -f main main.o haha.o sin_value.o cos_value.o
cc    -c -o main.o main.c
main.c: In function 'main':
main.c:13:2: warning: implicit declaration of function 'haha' [-Wimplicit-function-declaration]
  haha( name );
  ^~~~
main.c:14:2: warning: implicit declaration of function 'sin_value' [-Wimplicit-function-declaration]
  sin_value( angle );
  ^~~~~~~~~
main.c:15:2: warning: implicit declaration of function 'cos_value' [-Wimplicit-function-declaration]
  cos_value( angle );
  ^~~~~~~~~
cc    -c -o haha.o haha.c
cc    -c -o sin_value.o sin_value.c
cc    -c -o cos_value.o cos_value.c
gcc -o main main.o haha.o sin_value.o cos_value.o -lm
+ exit 0
正在执行(%install):/bin/sh -e /var/tmp/rpm-tmp.2FErCw
+ umask 022
+ cd /root/rpmbuild/BUILD
+ '[' /root/rpmbuild/BUILDROOT/main-0.1-1.el8.x86_64 '!=' / ']'
+ rm -rf /root/rpmbuild/BUILDROOT/main-0.1-1.el8.x86_64
++ dirname /root/rpmbuild/BUILDROOT/main-0.1-1.el8.x86_64
+ mkdir -p /root/rpmbuild/BUILDROOT
+ mkdir /root/rpmbuild/BUILDROOT/main-0.1-1.el8.x86_64
+ cd main-0.1
+ rm -rf /root/rpmbuild/BUILDROOT/main-0.1-1.el8.x86_64
+ mkdir -p /root/rpmbuild/BUILDROOT/main-0.1-1.el8.x86_64/usr/local/bin
+ install -m 755 main /root/rpmbuild/BUILDROOT/main-0.1-1.el8.x86_64/usr/local/bin
+ /usr/lib/rpm/find-debuginfo.sh -j2 --strict-build-id -m -i --build-id-seed 0.1-1.el8 --unique-debug-suffix -0.1-1.el8.x86_64 --unique-debug-src-base main-0.1-1.el8.x86_64 --run-dwz --dwz-low-mem-die-limit 10000000 --dwz-max-die-limit 110000000 -S debugsourcefiles.list /root/rpmbuild/BUILD/main-0.1
extracting debug info from /root/rpmbuild/BUILDROOT/main-0.1-1.el8.x86_64/usr/local/bin/main
gdb-add-index: No index was created for /root/rpmbuild/BUILDROOT/main-0.1-1.el8.x86_64/usr/local/bin/main
gdb-add-index: [Was there no debuginfo? Was there already an index?]
/usr/lib/rpm/sepdebugcrcfix: Updated 0 CRC32s, 1 CRC32s did match.
+ /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-ldconfig
/sbin/ldconfig: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf: No such file or directory
+ /usr/lib/rpm/brp-compress
+ /usr/lib/rpm/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/brp-python-bytecompile 1
+ /usr/lib/rpm/brp-python-hardlink
+ PYTHON3=/usr/libexec/platform-python
+ /usr/lib/rpm/redhat/brp-mangle-shebangs
处理文件:main-0.1-1.el8.x86_64
Provides: main = 0.1-1.el8 main(x86-64) = 0.1-1.el8
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires: libc.so.6()(64bit) libc.so.6(GLIBC_2.2.5)(64bit) libc.so.6(GLIBC_2.7)(64bit) libm.so.6()(64bit) libm.so.6(GLIBC_2.2.5)(64bit) rtld(GNU_HASH)
处理文件:main-debugsource-0.1-1.el8.x86_64
错误:空 %file 文件 /root/rpmbuild/BUILD/main-0.1/debugsourcefiles.list

在网上百度了一下,有人建议在spec文件中%define debug_package %{nil},避免生成debuginfo包,我尝试了一下不行,也有的说%_debugsource_template %{nil}只屏蔽 debugsource 包,还能保留 debuginfo 的分包和 debug 信息的剥离,我的还是不行。。。

直接查找问题没有找到,又看了一些别人汇总的关于rpm打包的问题,在rpm打包问题汇总中我看到涉及到/usr/lib/rpm/macros这个文件,直觉这是rpm打包配置文件,在这篇博客下有这样一句话:在生成rpm包同时,还会生成debuginfo包,如果要避免生成debuginfo包:这个是默认会生成的rpm包。则可以使用下面的命令:
echo ‘%debug_package %{nil}’ >> ~/.rpmmacros
因为我没找到~/.rpmmacros,所以尝试直接在/usr/lib/rpm/macros中添加%debug_package %{nil},再次rpmbuild -ba main.spec,成功。但是相比于鸟哥给出的结果,很明显少了一个debuginfo包的生成:

已写至:/root/rpmbuild/SRPMS/main-0.1-1.el8.src.rpm
已写至:/root/rpmbuild/RPMS/x86_64/main-0.1-1.el8.x86_64.rpm
正在执行(%clean):/bin/sh -e /var/tmp/rpm-tmp.4IBbIR
+ umask 022
+ cd /root/rpmbuild/BUILD
+ cd main-0.1
+ /usr/bin/rm -rf /root/rpmbuild/BUILDROOT/main-0.1-1.el8.x86_64
+ exit 0

于是我进一步在/usr/lib/rpm/macros中搜索关于debuginfo的信息,结合之前给出的debugsource.list为空,我猜测是不是我的CentOS8没有安装能够给出debuginfo的服务,然后在macros中有关于一个find-debuginfo.sh,在里面查找到了debugsource.list文件的来源,猜测应该是没有产生debug信息,该文件为空,这一猜想将在之后验证。
新手小白,如有错误,欢迎指正。
参考:
https://blog.csdn.net/u014007037/article/details/78727526 RMP打包遇到问题
http://ask.loongnix.org/?/question/1331 编译 rpm 时,debugsourcefiles.list 为空怎么解决?
http://ask.loongnix.org/?/question/256
debugsourcefiles.list文件为空是什么原因?

发布了16 篇原创文章 · 获赞 0 · 访问量 352

猜你喜欢

转载自blog.csdn.net/qq_41922018/article/details/103905243