yum/rpm 无法在 chroot 中初始化 NSS 库

Arl*_*ion 2 centos chroot yum rpm nss

我正在执行从 CentOS 7.4 到 CentOS 7.5 的 yum 更新,当 nspr 和 nss soft-softoken 收到更新时,出现以下错误:

yum update nspr
error: Failed to initialize NSS library
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   cannot import name ts

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.5 (default, Apr 11 2018, 07:36:10) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]

If you cannot solve this problem yourself, please go to 
the yum faq at:
  http://yum.baseurl.org/wiki/Faq
Run Code Online (Sandbox Code Playgroud)

更新到的软件包:

nss                         3.34.0-4.el7                                           
nss-softokn                 3.34.0-2.el7                                           
nss-softokn-freebl          3.34.0-2.el7                                           
nss-sysinit                 3.34.0-4.el7                                           
nss-tools                   3.34.0-4.el7                                           
nss-util                    3.34.0-2.el7  
Run Code Online (Sandbox Code Playgroud)

故障排除尝试:读者应该注意,升级后的文件系统是版本控制的。以下每个步骤都在同一时间点执行,并在继续进行下一个故障排除步骤之前恢复。

这些文章和解决方案中的每一个都没有提供解决我的特定问题。

感谢您的时间。

Arl*_*ion 8

特别感谢 #centos 上的 TrevorH 和 jhodrien。

问题是 chroot 阻止访问 /dev/urandom (如设计)。安装成功的更新需要这些随机位来初始化 GnuTLS。

解决办法是:

mount -o bind /dev dev/
Run Code Online (Sandbox Code Playgroud)

到 chroot 并照常进行更新。

或者,如果您不想挂载整个 /dev 目录,您可以创建自己的目录!

mknod -m 666 /dev/random c 1 8
mknod -m 666 /dev/urandom c 1 9
Run Code Online (Sandbox Code Playgroud)

问题已解决。

  • 谢谢工作。需要注意的是,您在 chroot 之前运行此命令,或者如果您已经可以从另一个终端运行,则在您的挂载根目录中运行,而无需 chroot,并且在具有打开的 chroot 环境的术语上,将变得自动可访问。 (2认同)