在构建.deb包时,可以(或可以)调用dpkg-shlibdeps来自动添加包使用的库的依赖项。
它产生有用的输出,如:
dpkg-shlibdeps: warning: package could avoid a useless dependency if ./foo.so were not linked against libboost_regex.so.1.62.0 (they use none of the library's symbols)
是否有rpm的等效功能?或者预先存在的平台中立工具?
是的没有:)
rpmbuild自动添加.so依赖项。
您可以检查rpm -qR bash
列出此要求:
...
libc.so.6(GLIBC_2.11)(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.15)(64bit)
...
但正如你在消息来源中看到的那样:https://src.fedoraproject.org/rpms/bash/blob/master/f/bash.spec没有像这样的行:
Requires: libc.so.6(GLIBC_2.11)(64bit)
这适用于.so库,Perl模块以及最近的Fedora for Python模块。必须手动将任何其他库添加到spec文件。
但是,这些依赖项是在链接库上计算的,如果链接到库,但不使用该库中的任何符号,那么我担心RPM世界没有任何实用程序来检测这种无用的依赖项。
我有一个部分答案。
RPM不直接支持此功能。 RPM通过脚本find-requires
和find-provides
查找程序包所需的内容,通常位于/ usr / lib / rpm中。
这些运行如下:
>find . | /usr/lib/rpm/find-provides
libfoobar.so.1()(64bit)
>find . | /usr/lib/rpm/find-requires
libasound.so.2()(64bit)
libboost_atomic-mt.so.1.53.0()(64bit)
libboost_chrono-mt.so.1.53.0()(64bit)
libboost_date_time-mt.so.1.53.0()(64bit)
libboost_filesystem-mt.so.1.53.0()(64bit)
libboost_regex-mt.so.1.53.0()(64bit)
libboost_system-mt.so.1.53.0()(64bit)
libboost_thread-mt.so.1.53.0()(64bit)
libboost_unit_test_framework-mt.so.1.53.0()(64bit)
libc.so.6()(64bit)
libc.so.6(GLIBC_2.14)(64bit)
还有一个编译程序/ usr / lib / rpm / elfdeps以相同的方式工作。 rpmbuild似乎使用这个而不是脚本。
请参阅http://ftp.rpm.org/max-rpm/s1-rpm-depend-auto-depend.html(注意真实的脚本不像那里的例子)。
问题的其余部分是dpkg-shlibdeps是如何做到的?如果没有人首先到达那里,我会在有时间调查时加上这个。