apt-get 升级 libc 失败

apt-get 升级 libc 失败

今天早上我想升级 unetbootin 包。一切都很顺利,直到出现这个错误。

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 libc6 : Breaks: libc6:i386 (!= 2.17-0ubuntu5) but 2.17-0ubuntu5.1 is installed
 libc6:i386 : Breaks: libc6 (!= 2.17-0ubuntu5.1) but 2.17-0ubuntu5 is installed
 libc6-dbg : Depends: libc6 (= 2.17-0ubuntu5.1) but 2.17-0ubuntu5 is installed
 libc6-dev : Depends: libc6 (= 2.17-0ubuntu5.1) but 2.17-0ubuntu5 is installed
             Depends: libc-dev-bin (= 2.17-0ubuntu5.1)
 libc6-dev:i386 : Depends: libc-dev-bin:i386 (= 2.17-0ubuntu5.1)
                  Recommends: gcc:i386 but it is not installed or
                              c-compiler:i386
 libc6-i386 : Depends: libc6 (= 2.17-0ubuntu5.1) but 2.17-0ubuntu5 is installed
 libc6-x32 : Depends: libc6 (= 2.17-0ubuntu5.1) but 2.17-0ubuntu5 is installed
E: Unmet dependencies. Try using -f.

所以我确实尝试了建议apt-get -f install

但这导致了以下错误

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
  linux-headers-3.2.0-31 linux-headers-3.2.0-31-generic linux-headers-3.8.0-19
  linux-headers-3.8.0-19-generic python-central
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
  libc-dev-bin libc6
Suggested packages:
  glibc-doc
The following packages will be upgraded:
  libc-dev-bin libc6
2 upgraded, 0 newly installed, 0 to remove and 109 not upgraded.
8 not fully installed or removed.
Need to get 0 B/4,814 kB of archives.
After this operation, 6,144 B of additional disk space will be used.
Do you want to continue [Y/n]? 
Preconfiguring packages ...
(Reading database ... 661066 files and directories currently installed.)
Preparing to replace libc6:amd64 2.17-0ubuntu5 (using .../libc6_2.17-0ubuntu5.1_amd64.deb) ...

A copy of the C library was found in an unexpected directory:
  '/lib/x86_64-linux-gnu/libc-2.15.so'
It is not safe to upgrade the C library in this situation;
please remove that copy of the C library or get it out of
'/lib/x86_64-linux-gnu' and try again.

dpkg: error processing /var/cache/apt/archives/libc6_2.17-0ubuntu5.1_amd64.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/libc6_2.17-0ubuntu5.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我已经尝试过 apt-get clean apt-get update && apt-get upgrade

但这也无济于事。同样的错误正在发生。我有点不确定我是否敢于重新启动。我该如何解决这个问题?


apt-cache policy libc6 的输出

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 libc6 : Breaks: libc6:i386 (!= 2.17-0ubuntu5) but 2.17-0ubuntu5.1 is installed
 libc6:i386 : Breaks: libc6 (!= 2.17-0ubuntu5.1) but 2.17-0ubuntu5 is installed
 libc6-dbg : Depends: libc6 (= 2.17-0ubuntu5.1) but 2.17-0ubuntu5 is installed
 libc6-dev : Depends: libc6 (= 2.17-0ubuntu5.1) but 2.17-0ubuntu5 is installed
             Depends: libc-dev-bin (= 2.17-0ubuntu5.1)
 libc6-dev:i386 : Depends: libc-dev-bin:i386 (= 2.17-0ubuntu5.1)
                  Recommends: gcc:i386 but it is not installed or
                              c-compiler:i386
 libc6-i386 : Depends: libc6 (= 2.17-0ubuntu5.1) but 2.17-0ubuntu5 is installed
 libc6-x32 : Depends: libc6 (= 2.17-0ubuntu5.1) but 2.17-0ubuntu5 is installed
E: Unmet dependencies. Try using -f.

答案1

首先,将/lib/x86_64-linux-gnu 这些文件移动到/rootlibc-2.17.so libdl-2.17.so libm-2.17.so libpthread-2.17.so librt-2.17.so

进入目录/lib/x86_64-linux-gnu并将文件复制到的命令/root

sudo -s
cd /lib/x86_64-linux-gnu
cp libc-2.17.so /root
cp libdl-2.17.so /root
cp libm-2.17.so /root
cp libpthread-2.17.so /root
cp librt-2.17.so /root

然后你需要使用预定义的命令启动 bash LD_PRELOAD

LD_PRELOAD=/root/libc-2.17.so:/root/libdl-2.17.so:/root/libm-2.17.so:/root/libpthread-2.17.so:/root/librt-2.17.so bash

删除/lib/x86_64-linux-gnu目录中文件的命令,

rm libc-2.17.so
rm libdl-2.17.so
rm libm-2.17.so
rm libpthread-2.17.so
rm librt-2.17.so

之后dist-upgradefix-missing package将会起作用:

apt-get -f install

或者

apt-get -f dist-upgrade

答案2

感谢 Avinash Raj!

我按照你的方法解决了这个问题。但对你的方法做了一些小改动:

  1. sudo

    cd /lib/x86_64-linux-gnu cp libc-2.17.so /root cp libdl-2.17.so /root cp libm-2.17.so /root cp libpthread-2.17.so /root cp librt-2.17.so /root cp ld-2.17.so /root/

mkdir /root/i386

cd /lib/i386-linux-gnu cp libc-2.17.so /root/i386 cp libdl-2.17.so /root/i386 cp libm-2.17.so /root/i386 cp libpthread-2.17.so /root/i386 cp librt-2.17.so /root/i386 cp ld-2.17.so /root/i386

  1. 预加载: LD_PRELOAD=/root/libc-2.17.so:/root/libdl-2.17.so:/root/libm-2.17.so:/root/libpthread-2.17.so:/root/librt-2.17.so bash

  2. 删除库: cd /lib/i386-linux-gnu rm libc-2.17.so rm libdl-2.17.so rm libm-2.17.so rm libpthread-2.17.so rm librt-2.17.so rm ld-2.17.so

cd /lib/x86_64-linux-gnu/ rm libc-2.17.so rm libdl-2.17.so rm libm-2.17.so rm libpthread-2.17.so rm librt-2.17.so rm ld-2.17.so

  1. apt-get -f install 执行此命令时遇到错误“找不到文件 lib6”,我通过以下方式恢复它 dpkg -i /var/cache/apt/archives/*.debdpkg --configure -a

  2. 然后我就可以进行 dist-upgrade。 apt-get dist-upgrade

相关内容