Ubuntu20.04 + WLS1,降级libc后APT损坏

Ubuntu20.04 + WLS1,降级libc后APT损坏

我使用的是Ubuntu20.04+WSL1。我注意到睡眠命令不起作用。经过查找错误,发现了这个问题https://github.com/microsoft/WSL/issues/4898

然后,根据其中的评论之一,我应用了以下解决方法:

wget "https://launchpad.net/~rafaeldtinoco/+archive/ubuntu/lp1871129/+build/19152555/+files/libc6_2.31-0ubuntu8+lp1871129~1_amd64.deb"
sudo dpkg -i libc6_2.31-0ubuntu8+lp1871129~1_amd64.deb

现在睡眠命令起作用了。但很多东西停止工作,apt upgrade给出以下错误

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 libc6-dev : Depends: libc6 (= 2.31-0ubuntu9) but 2.31-0ubuntu8+lp1871129~1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

尝试按照它的建议执行操作,即apt --fix-broken install,我收到以下错误:

sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  libc6
Suggested packages:
  glibc-doc
The following packages will be upgraded:
  libc6
1 upgraded, 0 newly installed, 0 to remove and 43 not upgraded.
Need to get 0 B/2713 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
(Reading database ... 63162 files and directories currently installed.)
Preparing to unpack .../libc6_2.31-0ubuntu9_amd64.deb ...
Unpacking libc6:amd64 (2.31-0ubuntu9) over (2.31-0ubuntu8+lp1871129~1) ...
Setting up libc6:amd64 (2.31-0ubuntu9) ...
sleep: cannot read realtime clock: Invalid argument
dpkg: error processing package libc6:amd64 (--configure):
 installed libc6:amd64 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 libc6:amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)

问题是,我怎样才能扭转我所做的改变?或者我该如何修复从 apt 收到的上述错误?

答案1

首先,你在这里做了什么:

wget "https://launchpad.net/~rafaeldtinoco/+archive/ubuntu/lp1871129/+build/19152555/+files/libc6_2.31-0ubuntu8+lp1871129~1_amd64.deb"
sudo dpkg -i libc6_2.31-0ubuntu8+lp1871129~1_amd64.deb

创建该内容的人.deb可能会完全危害您的计算机。遵循随机指令可能会出现问题。

如果您要从该存储库安装,则应该添加到您的软件源中

deb http://ppa.launchpad.net/rafaeldtinoco/lp1871129/ubuntu focal main 

这样,它就能够拉取依赖项(或提前拒绝)。

现在,发生的事情如下:

  • 您已安装 glibc 版本 2.31-0ubuntu9
  • 使用这些命令,您安装了版本 2.31-0ubuntu8+lp1871129(reafaeldtinoco 添加了补丁的版本 2.31-0ubuntu8)。你降级到以前的 glibc 版本
  • libc 包几乎用于系统中的每个程序
  • apt --fix-broken install正在寻找一个解决方案:安装回 2.31-0ubuntu9。但是,安装的后处理步骤失败,因为它使用了sleep,现在又被破坏了。

或者,您可以将所有内容降级到 2.31-0ubuntu8,但您可能有大量软件包需要手动强制降级。另一个解决方案是创建 2.31-0ubuntu9 的修补版本,但您可能不愿意这样做。

现在,您已经安装了 2.31-0ubuntu8,但尚未配置。

可以强制降级到 rafaeldtinoco libc6 版本,并通过执行以下操作保持不变:

sudo add-apt-repository ppa:rafaeldtinoco/lp1871129 # Install rafaeldtinoco/lp1871129 repo
sudo apt-get update
sudo apt-get install libc6=2.31-0ubuntu8+lp1871129~1 # Downgrade to exactly this version
sudo apt-mark hold libc6 # Do not upgrade libc6

相关内容