Yum 安装损坏了 Redhat Ubi8 上的 lib

Yum 安装损坏了 Redhat Ubi8 上的 lib

我正在开发 Redhat Ubi8-minimal 容器。我的目标是从文件安装 .rpm 及其依赖项。Ubi8-minimal 仅提供microdnf无法安装本地 .rpm 的版本。因此,我yum使用可以microdnf install yum顺利安装的版本进行了安装。在输出中,它显示libmodulemd正在更新:

Updating: libmodulemd;2.13.0-2.fc34;x86_64;Clients_Fedora_34_Fedora_34_Updates

但第一次调用时yum我得到:

[root@7fc9c0e586b1]# yum --version
Traceback (most recent call last):
  File "/usr/bin/yum", line 57, in <module>
    from dnf.cli import main
  File "/usr/lib/python3.9/site-packages/dnf/__init__.py", line 30, in <module>
    import dnf.base
  File "/usr/lib/python3.9/site-packages/dnf/base.py", line 29, in <module>
    import libdnf.transaction
  File "/usr/lib64/python3.9/site-packages/libdnf/__init__.py", line 12, in <module>
    from . import conf
  File "/usr/lib64/python3.9/site-packages/libdnf/conf.py", line 13, in <module>
    from . import _conf
ImportError: /lib64/libmodulemd.so.2: undefined symbol: g_ptr_array_extend_and_steal

此后microdnf也出现此问题并且无法再使用:

[root@7fc9c0e586b1]# microdnf --version
microdnf: symbol lookup error: /lib64/libmodulemd.so.2: undefined symbol: g_ptr_array_extend_and_steal

所以我无法再管理任何包和安装。

我该如何修复这个问题并让 yum 在 Ubi8 上运行?

细节

这是我在跑步后在新容器中发现的东西podman --it --rm docker.io/redhat/ubi8-minimal bash

/etc/yum.repos.d/ubi.repo

以下是 的内容/etc/yum.repos.d/ubi.repo

[ubi-8-baseos]
name = Red Hat Universal Base Image 8 (RPMs) - BaseOS
baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi8/8/$basearch/baseos/os
enabled = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
gpgcheck = 1

[ubi-8-baseos-debug]
name = Red Hat Universal Base Image 8 (Debug RPMs) - BaseOS
baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi8/8/$basearch/baseos/debug
enabled = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
gpgcheck = 1

[ubi-8-baseos-source]
name = Red Hat Universal Base Image 8 (Source RPMs) - BaseOS
baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi8/8/$basearch/baseos/source/SRPMS
enabled = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
gpgcheck = 1

[ubi-8-appstream]
name = Red Hat Universal Base Image 8 (RPMs) - AppStream
baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi8/8/$basearch/appstream/os
enabled = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
gpgcheck = 1

[ubi-8-appstream-debug]
name = Red Hat Universal Base Image 8 (Debug RPMs) - AppStream
baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi8/8/$basearch/appstream/debug
enabled = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
gpgcheck = 1

[ubi-8-appstream-source]
name = Red Hat Universal Base Image 8 (Source RPMs) - AppStream
baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi8/8/$basearch/appstream/source/SRPMS
enabled = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
gpgcheck = 1

[ubi-8-codeready-builder]
name = Red Hat Universal Base Image 8 (RPMs) - CodeReady Builder
baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi8/8/$basearch/codeready-builder/os
enabled = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
gpgcheck = 1

[ubi-8-codeready-builder-debug]
name = Red Hat Universal Base Image 8 (Debug RPMs) - CodeReady Builder
baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi8/8/$basearch/codeready-builder/debug
enabled = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
gpgcheck = 1

[ubi-8-codeready-builder-source]
name = Red Hat Universal Base Image 8 (Source RPMs) - CodeReady Builder
baseurl = https://cdn-ubi.redhat.com/content/public/ubi/dist/ubi8/8/$basearch/codeready-builder/source/SRPMS
enabled = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
gpgcheck = 1

这也是目录中唯一的 .repo 文件。我没有主动启用任何其他 repo。

microdnf repolist——已启用

这是命令的输出microdnf repolist --enabled

repo id                                                                                            repo name
Clients_Extra-Software_Fedora                                                                      Fedora
Clients_Fedora_34_Fedora_34_Everything                                                             Fedora 34 Everything
Clients_Fedora_34_Fedora_34_Updates                                                                Fedora 34 Updates
Clients_RPM_Fusion_Fedora_34_RPM_Fusion_Free_OS                                                    RPM Fusion Free OS 34
Clients_RPM_Fusion_Fedora_34_RPM_Fusion_Free_Updates                                               RPM Fusion Free Updates 34
Clients_RPM_Fusion_Fedora_34_RPM_Fusion_Nonfree_OS                                                 RPM Fusion Nonfree OS 34
Clients_RPM_Fusion_Fedora_34_RPM_Fusion_Nonfree_Updates                                            RPM Fusion Nonfree Updates 34
Clients_Trinity_Desktop_Environment_Fedora_34_Trinity_Desktop_Environment_Fedora_34_noarch         Trinity Desktop Environment Fedora 34 noarch
Clients_Trinity_Desktop_Environment_Fedora_34_Trinity_Desktop_Environment_Fedora_34_x86_64         Trinity Desktop Environment Fedora 34 x86_64
ubi-8-appstream                                                                                    Red Hat Universal Base Image 8 (RPMs) - AppStream
ubi-8-baseos                                                                                       Red Hat Universal Base Image 8 (RPMs) - BaseOS
ubi-8-codeready-builder                                                                            Red Hat Universal Base Image 8 (RPMs) - CodeReady Builder

这让我很困惑,因为它与的内容不匹配ubi.repo

答案1

当任何 dnf 命令导致未定义符号时,您的包管理器就严重损坏了。fc34 标签表示基于 Fedora 34 的更新,这不适用于基于 el8 的发行版。在此处了解使用 Fedora 存储库的内容。

查看文档以获取有关如何在容器上运行完整 dnf 命令的提示。RHEL 8 构建容器利用 yum 的安装到 chroot 功能来执行此操作,即使使用微型容器也是如此。从主机:

yum install \
    --installroot $micromount \
    --releasever 8 \
    --setopt install_weak_deps=false \
    --nodocs -y \
    httpd

$micromount已安装的容器根文件系统在哪里,--releasever 8是 el 版本的 continer,httpd是您要安装的包。还可以修复您的 dnf 安装,可能使用 yum reinstall libmodulemd microdnf

答案2

感谢以下人士的提示约翰·马霍瓦尔德指向 fc34 repos 参与,一个解决方法是在安装时排除 Fedora repos yum

microdnf install --disablerepo="Clients_*" yum

这将导致yum安装成功:

[root@4f6b589029d5]# yum --version
4.7.0
  Installed: dnf-0:4.7.0-8.el8.noarch at Mon Aug 22 06:56:42 2022
  Built    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> at Fri Mar 18 15:21:28 2022

  Installed: rpm-0:4.14.3-23.el8.x86_64 at Tue Jul 26 12:26:21 2022
  Built    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> at Tue Apr  5 18:38:09 2022

首先,这样做的必要性似乎是容器与subscription-manager主机系统的交互,它将订阅信息投射到正在运行的容器中。除了其他用户的提及和我自己的经验外,我还没有找到关于此的任何主要文档。

相关内容