![RPM 忽略需要版本](https://linux22.com/image/604421/RPM%20%E5%BF%BD%E7%95%A5%E9%9C%80%E8%A6%81%E7%89%88%E6%9C%AC.png)
我已经将 clamav 打包成一些 rpm 以便在我们的 rhn 内部分发,但是在升级时我遇到了一些依赖关系解析问题。
spec 文件构建了 4 个包:
clamav - 包含主要文件
clamav-db - 包含病毒定义文件 libclamav - 包含 clamav 库 libclamav-devel - 包含 devel 文件
我需要 clamav 要求安装的 libclamav 与其自身是相同的版本和发行版。例如 clamav-0.96.3-9 应该要求 libclamav-0.96.3-9
但是 clamav-db 可以是任意版本(它会随着 freshclam 而更新,并且只在安装时才真正需要,以尽量减少 rpm 事务期间的网络流量)
现在,我在 spec 文件中定义了如下包
Version: 0.97.6
Release: 1
%package -n clamav
Summary: ClamAV Anti-Virus Software
Requires: libclamav = %{version}-%{release}
Requires: clamav-db
%description -n clamav
Provides the server daemon and standard client utilities for antivirus scanning.
%package -n clamav-db
Summary: ClamAV Anti-Virus Software (Initial Databases)
%description -n clamav-db
Provides the initial antivirus databases for clamav.
%package -n libclamav
Summary: ClamAV Anti-Virus Software (libraries)
%description -n libclamav
Provides support libraries for clamav.
%package -n libclamav-devel
Summary: ClamAV Anti-Virus Software (development libraries)
Requires: libclamav = %{version}-%{release}
%description -n libclamav-devel
Provides development libraries and headers for clamav.
这可以在干净的 chroot 中顺利构建 4 个包。我将它们 scp 到我的测试服务器。
当前 Clam 版本:
[root@localhost clamav]# rpm -qa '(lib)?clam*'
libclamav-0.97.3-9.i386
clamav-db-0.97.3-9.i386
clamav-0.97.3-9.i386
我在本地文件系统上有符合正确要求的新 rpm:
[root@localhost clamav]# rpm -qp --qf '%{NAME}\n\t[%{REQUIRES} %|REQUIREVERSION?{%{REQUIREVERSION}}:{}|\n\t]\n' *
clamav
/bin/bash
/bin/sh
/bin/sh
/bin/sh
clamav-db
config(clamav) 0.97.6-1
libbz2.so.1
libc.so.6
libc.so.6(GLIBC_2.0)
libc.so.6(GLIBC_2.1)
libc.so.6(GLIBC_2.1.3)
libc.so.6(GLIBC_2.2)
libc.so.6(GLIBC_2.3)
libc.so.6(GLIBC_2.3.4)
libc.so.6(GLIBC_2.7)
--> libclamav 0.97.6-1
libclamav.so.6
libclamav.so.6(CLAMAV_PRIVATE)
libclamav.so.6(CLAMAV_PUBLIC)
libdl.so.2
libpthread.so.0
libpthread.so.0(GLIBC_2.0)
libpthread.so.0(GLIBC_2.1)
libpthread.so.0(GLIBC_2.3.2)
libresolv.so.2
libresolv.so.2(GLIBC_2.2)
libz.so.1
rpmlib(CompressedFileNames) 3.0.4-1
rpmlib(PayloadFilesHavePrefix) 4.0-1
rtld(GNU_HASH)
clamav-db
/bin/sh
config(clamav-db) 0.97.6-1
rpmlib(CompressedFileNames) 3.0.4-1
rpmlib(PayloadFilesHavePrefix) 4.0-1
libclamav
/bin/sh
libbz2.so.1
libc.so.6
libc.so.6(GLIBC_2.0)
libc.so.6(GLIBC_2.1)
libc.so.6(GLIBC_2.1.3)
libc.so.6(GLIBC_2.3)
libc.so.6(GLIBC_2.7)
libclamav.so.6
libclamunrar.so.6
libclamunrar.so.6(CLAMAV_PRIVATE_UNRAR)
libclamunrar_iface.so.6
libdl.so.2
libdl.so.2(GLIBC_2.0)
libdl.so.2(GLIBC_2.1)
libm.so.6
libm.so.6(GLIBC_2.0)
libpthread.so.0
libpthread.so.0(GLIBC_2.0)
libpthread.so.0(GLIBC_2.2)
libz.so.1
rpmlib(CompressedFileNames) 3.0.4-1
rpmlib(PayloadFilesHavePrefix) 4.0-1
rtld(GNU_HASH)
libclamav-devel
/bin/sh
/usr/bin/pkg-config
libclamav 0.97.6-1
libclamav.so.6
libclamunrar.so.6
libclamunrar_iface.so.6
rpmlib(CompressedFileNames) 3.0.4-1
rpmlib(PayloadFilesHavePrefix) 4.0-1
rpmlib(VersionedDependencies) 3.0.3-1
所以我可以看到rpm包中有正确的版本要求。
因此我使用 yum 安装了新的 clamav,我预计 yum 会抱怨,因为它在其存储库中找不到 libclamav-0.97.6-1。但我得到的是:
[root@localhost clamav]# yum install ./clamav-0.97.6-1.i386.rpm
Loaded plugins: product-id, rhnplugin, subscription-manager
Updating certificate-based repositories.
Setting up Install Process
Examining ./clamav-0.97.6-1.i386.rpm: clamav-0.97.6-1.i386
Marking ./clamav-0.97.6-1.i386.rpm as an update to clamav-0.97.3-9.i386
Resolving Dependencies
--> Running transaction check
---> Package clamav.i386 0:0.97.3-9 will be updated
---> Package clamav.i386 0:0.97.6-1 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================
Package Arch Version Repository Size
==========================================================================================================
Updating:
clamav i386 0.97.6-1 /clamav-0.97.6-1.i386 825 k
Transaction Summary
==========================================================================================================
Upgrade 1 Package(s)
Total size: 825 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : clamav-0.97.6-1.i386 1/2
error reading information on service clamav: No such file or directory
Cleanup : clamav-0.97.3-9.i386 2/2
Installed products updated.
Updated:
clamav.i386 0:0.97.6-1
Complete!
[root@localhost clamav]# rpm -qa '(lib)?clam*'
libclamav-0.97.3-9.i386
clamav-0.97.6-1.i386
clamav-db-0.97.3-9.i386
很奇怪吧?
如果我删除所有当前安装的 clam 包并尝试安装新版本:
[root@localhost clamav]# rpm -qa '(lib)?clam*'
[root@localhost clamav]# yum install ./clamav-0.97.6-1.i386.rpm
Loaded plugins: product-id, rhnplugin, subscription-manager
Updating certificate-based repositories.
Setting up Install Process
Examining ./clamav-0.97.6-1.i386.rpm: clamav-0.97.6-1.i386
Marking ./clamav-0.97.6-1.i386.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package clamav.i386 0:0.97.6-1 will be installed
--> Processing Dependency: libclamav = 0.97.6-1 for package: clamav-0.97.6-1.i386
--> Processing Dependency: clamav-db for package: clamav-0.97.6-1.i386
--> Processing Dependency: libclamav.so.6 for package: clamav-0.97.6-1.i386
--> Processing Dependency: libclamav.so.6(CLAMAV_PRIVATE) for package: clamav-0.97.6-1.i386
--> Processing Dependency: libclamav.so.6(CLAMAV_PUBLIC) for package: clamav-0.97.6-1.i386
--> Running transaction check
---> Package clamav-db.i386 0:0.97.3-9 will be installed
---> Package libclamav.i386 0:0.97.3-9 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
==========================================================================================================
Package Arch Version Repository Size
==========================================================================================================
Installing:
clamav i386 0.97.6-1 /clamav-0.97.6-1.i386 825 k
Installing for dependencies:
clamav-db i386 0.97.3-9 frog-i386-6-trunk 30 M
libclamav i386 0.97.3-9 frog-i386-6-trunk 1.4 M
Transaction Summary
==========================================================================================================
Install 3 Package(s)
Total size: 32 M
Total download size: 31 M
Installed size: 825 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): clamav-db-0.97.3-9.i386.rpm | 30 MB 00:07
(2/2): libclamav-0.97.3-9.i386.rpm | 1.4 MB 00:00
----------------------------------------------------------------------------------------------------------
Total 4.0 MB/s | 31 MB 00:07
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : clamav-db-0.97.3-9.i386 1/3
Installing : libclamav-0.97.3-9.i386 2/3
Installing : clamav-0.97.6-1.i386 3/3
error reading information on service clamav: No such file or directory
Installed products updated.
Installed:
clamav.i386 0:0.97.6-1
Dependency Installed:
clamav-db.i386 0:0.97.3-9 libclamav.i386 0:0.97.3-9
Complete!
因此,它会在 repo 中查找依赖项并忽略版本部分。如果我再次使用 -v 标志运行它,我会得到如下所示的依赖解析输出
Checking deps for clamav.i386 0:0.97.6-1 - u
looking for ('config(clamav)', 'EQ', ('0', '0.97.6', '1')) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libclamav', 'EQ', ('0', '0.97.6', '1')) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('/bin/bash', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('/bin/sh', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('/bin/sh', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('/bin/sh', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('clamav-db', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libbz2.so.1', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libc.so.6', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libc.so.6(GLIBC_2.0)', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libc.so.6(GLIBC_2.1)', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libc.so.6(GLIBC_2.1.3)', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libc.so.6(GLIBC_2.2)', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libc.so.6(GLIBC_2.3)', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libc.so.6(GLIBC_2.3.4)', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libc.so.6(GLIBC_2.7)', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libclamav.so.6', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libclamav.so.6(CLAMAV_PRIVATE)', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libclamav.so.6(CLAMAV_PUBLIC)', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libdl.so.2', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libpthread.so.0', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libpthread.so.0(GLIBC_2.0)', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libpthread.so.0(GLIBC_2.1)', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libpthread.so.0(GLIBC_2.3.2)', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libresolv.so.2', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libresolv.so.2(GLIBC_2.2)', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('libz.so.1', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
looking for ('rtld(GNU_HASH)', None, (None, None, None)) as a requirement of clamav.i386 0:0.97.6-1 - u
clamav-0.97.6-1.i386 requires: libclamav = 0.97.6-1
--> Processing Dependency: libclamav = 0.97.6-1 for package: clamav-0.97.6-1.i386
Searching pkgSack for dep: libclamav
TSINFO: Marking libclamav-0.97.3-9.i386 as install for clamav-0.97.6-1.i386
clamav-0.97.6-1.i386 requires: clamav-db
--> Processing Dependency: clamav-db for package: clamav-0.97.6-1.i386
Searching pkgSack for dep: clamav-db
TSINFO: Marking clamav-db-0.97.3-9.i386 as install for clamav-0.97.6-1.i386
clamav-0.97.6-1.i386 requires: libclamav.so.6
--> Processing Dependency: libclamav.so.6 for package: clamav-0.97.6-1.i386
Searching pkgSack for dep: libclamav.so.6
libclamav-0.97.3-9.i386 already in ts, skipping this one
clamav-0.97.6-1.i386 requires: libclamav.so.6(CLAMAV_PRIVATE)
--> Processing Dependency: libclamav.so.6(CLAMAV_PRIVATE) for package: clamav-0.97.6-1.i386
Quick matched libclamav-0.97.3-9.i386 to require for libclamav.so.6(CLAMAV_PRIVATE)
clamav-0.97.6-1.i386 requires: libclamav.so.6(CLAMAV_PUBLIC)
--> Processing Dependency: libclamav.so.6(CLAMAV_PUBLIC) for package: clamav-0.97.6-1.i386
Quick matched libclamav-0.97.3-9.i386 to require for libclamav.so.6(CLAMAV_PUBLIC)
--> Running transaction check
---> Package clamav-db.i386 0:0.97.3-9 will be installed
Checking deps for clamav-db.i386 0:0.97.3-9 - u
looking for ('config(clamav-db)', 'EQ', ('0', '0.97.3', '9')) as a requirement of clamav-db.i386 0:0.97.3-9 - u
looking for ('/bin/sh', None, (None, None, None)) as a requirement of clamav-db.i386 0:0.97.3-9 - u
---> Package libclamav.i386 0:0.97.3-9 will be installed
Checking deps for libclamav.i386 0:0.97.3-9 - u
looking for ('libclamunrar_iface.so.6', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libclamunrar.so.6', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libclamunrar.so.6(CLAMAV_PRIVATE_UNRAR)', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libclamav.so.6', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libbz2.so.1', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libpthread.so.0(GLIBC_2.0)', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libc.so.6(GLIBC_2.1)', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libz.so.1', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libc.so.6(GLIBC_2.1.3)', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libc.so.6(GLIBC_2.3)', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libdl.so.2(GLIBC_2.1)', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libdl.so.2', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libm.so.6(GLIBC_2.0)', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libdl.so.2(GLIBC_2.0)', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libc.so.6(GLIBC_2.0)', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libm.so.6', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libc.so.6(GLIBC_2.7)', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libc.so.6', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('rtld(GNU_HASH)', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('/bin/sh', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libpthread.so.0(GLIBC_2.2)', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
looking for ('libpthread.so.0', None, (None, None, None)) as a requirement of libclamav.i386 0:0.97.3-9 - u
--> Finished Dependency Resolution
Dependency Process ending
Depsolve time: 0.339
Dependencies Resolved
因此,它似乎找不到 libclamav 的新版本,而是标记旧版本,因为它为 clamav 提供了其中一个文件。
谁能帮助我弄清楚这件事?这真是让我抓狂!
谢谢
答案1
检查 libclamav 包提供的符号:
rpm -qp --provides ./libclamav-0.97.6-1.i386.rpm
并确保没有未版本化的libclamav
符号。在我的例子中,这是导致问题的原因,因为未版本化的符号满足任何版本化的提供/冲突节。
答案2
看起来好像找不到其他软件包,好像它们没有复制到存储库中,并且存储库数据已重新生成。如果您尝试使用 yum install libclamav-0.97.6-1 安装正确版本的 libclamav,会发生什么情况?如果找不到,我会检查它应该所在的存储库,确保存储库可以正确重新生成。