解决redhat rpmbuild后ELF文件md5改变

本来想通过md5验证rpm包内容是否被篡改,打包时却发现,生成的包文件md5和原始文件md5不同了,
【解决redhat rpmbuild后ELF文件md5改变】原因是rpmbuild对可执行文件进行了strip,删除了符号表等信息。
可以在/usr/lib/rpm/redhat/macros中看到:

vim /usr/lib/rpm/redhat/macros%__os_install_post\ /usr/lib/rpm/redhat/brp-compress \ %{!?__debug_package:\ /usr/lib/rpm/redhat/brp-strip %{__strip} \ /usr/lib/rpm/redhat/brp-strip-comment-note %{__strip} %{__objdump} \ } \ /usr/lib/rpm/redhat/brp-strip-static-archive %{__strip} \ /usr/lib/rpm/brp-python-bytecompile %{__python} %{?_python_bytecompile_errors_terminate_build} \ /usr/lib/rpm/redhat/brp-python-hardlink \ %{!?__jar_repack:/usr/lib/rpm/redhat/brp-java-repack-jars} \ %{nil}#/usr/lib/rpm/redhat/brp-implant-ident-static%__spec_install_post\ %{?__debug_package:%{__debug_install_post}}\ %{__arch_install_post}\ %{__os_install_post}\ %{nil}

只需要在你打包的.spec中,重新定义这两个值,就可以跳过strip,解决此问题。
%define __spec_install_post /usr/lib/rpm/brp-compress %define __os_install_post /usr/lib/rpm/brp-compress

https://www.redhat.com/archives/rhl-devel-list/2006-June/msg00822.html
转载于:https://my.oschina.net/u/945874/blog/870837

    推荐阅读