有没有办法告诉 rpm 管理器 "don't seek XXX.so, because it is included in this rpm."?

Is there a way to tell rpm manager "don't seek XXX.so, because it is included in this rpm."?

我构建了一个 RPM,其中包含一些我制作的可执行文件和一些由 3rd SDKs 提供的 .so

如果我手动进行复制工作,如make install DESTDIR=/,那么所有 ld 依赖都可以。

[shaozr@centos1 lib]$ cd /opt/tymonitor/SDKs/Hik64/lib
[shaozr@centos1 lib]$ ll
total 18444
drwxr-xr-x. 2 root root    4096 Jul 23 14:31 HCNetSDKCom
-rwxr-xr-x. 1 root root  343864 Jul 23 14:31 HikAdapter        <== This is my exe, all other binaries come from 3rd SDK
-rw-r--r--. 1 root root   29192 Jul 23 14:31 libAudioRender.so
-rw-r--r--. 1 root root 2484814 Jul 23 14:31 libcrypto.so
-rw-r--r--. 1 root root 2484814 Jul 23 14:31 libcrypto.so.1.0.0
-rw-r--r--. 1 root root 2252728 Jul 23 14:31 libHCCore.so
-rw-r--r--. 1 root root  541128 Jul 23 14:31 libhcnetsdk.so
-rw-r--r--. 1 root root  400144 Jul 23 14:31 libhpr.so
-rw-r--r--. 1 root root 2024584 Jul 23 14:31 libNPQos.so
-rw-r--r--. 1 root root 1956138 Jul 23 14:31 libopenal.so.1
-rw-r--r--. 1 root root 4705408 Jul 23 14:31 libPlayCtrl.so
-rw-r--r--. 1 root root  495218 Jul 23 14:31 libssl.so
-rw-r--r--. 1 root root 1032864 Jul 23 14:31 libSuperRender.so
-rw-r--r--. 1 root root  103941 Jul 23 14:31 libz.so

然后让我们检查 ld 依赖性:

[shaozr@centos1 lib]$ ldd ./HikAdapter
    linux-vdso.so.1 =>  (0x00007ffef3e8c000)
    libhcnetsdk.so => /opt/tymonitor/SDKs/Hik64/lib/libhcnetsdk.so (0x00007f8dfe762000)
    libhpr.so => /opt/tymonitor/SDKs/Hik64/lib/libhpr.so (0x00007f8dfdd58000)
    libHCCore.so => /opt/tymonitor/SDKs/Hik64/lib/libHCCore.so (0x00007f8dfd744000)
    libevent-2.0.so.5 => /lib64/libevent-2.0.so.5 (0x00007f8dfd4fc000)
    libevent_pthreads-2.0.so.5 => /lib64/libevent_pthreads-2.0.so.5 (0x00007f8dfd2f9000)
    libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f8dfcff2000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f8dfccf0000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f8dfcada000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f8dfc8be000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f8dfc4f0000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f8dfc2e8000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f8dfc0e4000)
    libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f8dfbedf000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f8dfe6c6000)

因为我在exe中嵌入了rpath。

readelf -d HikAdapter |grep rpath
 0x000000000000000f (RPATH)              Library rpath: [/opt/tymonitor/SDKs/Hik64/lib:./:./HCNetSDKCom]

问题是当我安装 rpm 时, 似乎 rpm 管理器不知道我已经携带了依赖项,它试图寻找什么包可以提供它们, 显然失败了。

#yum install tymonitor-0.0.1-1.el7.x86_64.rpm
...  
Examining tymonitor-0.0.1-1.el7.x86_64.rpm: tymonitor-0.0.1-1.el7.x86_64
Marking tymonitor-0.0.1-1.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package tymonitor.x86_64 0:0.0.1-1.el7 will be installed
--> Processing Dependency: libHCCore.so()(64bit) for package: tymonitor-0.0.1-1.el7.x86_64
--> Processing Dependency: libhcnetsdk.so()(64bit) for package: tymonitor-0.0.1-1.el7.x86_64
--> Processing Dependency: libhpr.so()(64bit) for package: tymonitor-0.0.1-1.el7.x86_64
--> Finished Dependency Resolution
Error: Package: tymonitor-0.0.1-1.el7.x86_64 (/tymonitor-0.0.1-1.el7.x86_64)
           Requires: libHCCore.so()(64bit)
Error: Package: tymonitor-0.0.1-1.el7.x86_64 (/tymonitor-0.0.1-1.el7.x86_64)
           Requires: libhpr.so()(64bit)
Error: Package: tymonitor-0.0.1-1.el7.x86_64 (/tymonitor-0.0.1-1.el7.x86_64)
           Requires: libhcnetsdk.so()(64bit)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

有没有办法告诉 rpm 管理器“不要寻找 XXX.so,因为它包含在这个 rpm 中。” ?

作为解决方法,您可以使用

关闭 RPM 的自动依赖处理
AutoReqProv: no

虽然可能有更好的解决方案。

RPM 有两个脚本 find-provides 和 find-requires,在 /usr/lib/rpm 或类似的地方,它用来计算所有捆绑可执行文件的共享库依赖关系。看起来您所做的事情混淆了其中一个或两个。我想最好的答案是更正这些列表,也许使用 Provides:%files,但我不知道该怎么做。 (看起来Fedora's solution是修改find_provides和find_requires处理的文件列表。)