尝试 apt 升级时,如何修复 Ubuntu 18.04 中 libc6-dev-armhf-cross 的错误?

尝试 apt 升级时,如何修复 Ubuntu 18.04 中 libc6-dev-armhf-cross 的错误?

今天,当我尝试根据 Ubuntu 软件建议进行升级时,我看到以下错误。这是我第一次看到这个错误。我的 18.04 系统已经运行了好几个月了。

任何帮助都将受到赞赏。

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu 
DISTRIB_RELEASE=18.04 
DISTRIB_CODENAME=bionic 
DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS"



$ sudo apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  libc6-armel-cross libc6-armhf-cross libc6-dev-armel-cross libc6-dev-armhf-cross
4 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/5,871 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 388166 files and directories currently installed.)
Preparing to unpack .../libc6-dev-armel-cross_2.27-3ubuntu1cross1.1_all.deb ...
Unpacking libc6-dev-armel-cross (2.27-3ubuntu1cross1.1) over (2.27-3ubuntu1cross1) ...
dpkg: error processing archive /var/cache/apt/archives/libc6-dev-armel-cross_2.27-3ubuntu1cross1.1_all.deb (--unpack):
 unable to open '/usr/arm-linux-gnueabi/lib/Mcrt1.o.dpkg-new': No such file or directory
No apport report written because the error message indicates an issue on the local system
                                                                                         Preparing to unpack .../libc6-armel-cross_2.27-3ubuntu1cross1.1_all.deb ...
Unpacking libc6-armel-cross (2.27-3ubuntu1cross1.1) over (2.27-3ubuntu1cross1) ...
dpkg: error processing archive /var/cache/apt/archives/libc6-armel-cross_2.27-3ubuntu1cross1.1_all.deb (--unpack):
 unable to open '/usr/arm-linux-gnueabi/lib/ld-2.27.so.dpkg-new': No such file or directory
No apport report written because the error message indicates an issue on the local system
                                                                                         Preparing to unpack .../libc6-dev-armhf-cross_2.27-3ubuntu1cross1.1_all.deb ...
Unpacking libc6-dev-armhf-cross (2.27-3ubuntu1cross1.1) over (2.27-3ubuntu1cross1) ...
dpkg: error processing archive /var/cache/apt/archives/libc6-dev-armhf-cross_2.27-3ubuntu1cross1.1_all.deb (--unpack):
 unable to open '/usr/arm-linux-gnueabihf/lib/Mcrt1.o.dpkg-new': No such file or directory
No apport report written because the error message indicates an issue on the local system
                                                                                         Preparing to unpack .../libc6-armhf-cross_2.27-3ubuntu1cross1.1_all.deb ...
Unpacking libc6-armhf-cross (2.27-3ubuntu1cross1.1) over (2.27-3ubuntu1cross1) ...
dpkg: error processing archive /var/cache/apt/archives/libc6-armhf-cross_2.27-3ubuntu1cross1.1_all.deb (--unpack):
 unable to open '/usr/arm-linux-gnueabihf/lib/ld-2.27.so.dpkg-new': No such file or directory
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 /var/cache/apt/archives/libc6-dev-armel-cross_2.27-3ubuntu1cross1.1_all.deb
 /var/cache/apt/archives/libc6-armel-cross_2.27-3ubuntu1cross1.1_all.deb
 /var/cache/apt/archives/libc6-dev-armhf-cross_2.27-3ubuntu1cross1.1_all.deb
 /var/cache/apt/archives/libc6-armhf-cross_2.27-3ubuntu1cross1.1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

答案1

我能够用以下方法的变体干净利落地解决这个问题:生成堆栈。可接受的解决方案的问题在于,它删除了相关软件包的依赖关系,但无法恢复它们。此解决方案可防止出现该问题。

首先,删除问题软件包并清除其配置但不删除依赖项:

sudo dpkg -P --force-depends libc6-armel-cross libc6-armhf-cross libc6-dev-armel-cross libc6-dev-armhf-cross

清理包缓存:

sudo apt clean

更新软件包列表:

sudo apt update

修复损坏的依赖关系(应该自动安装两个已删除的软件包):

sudo apt -f install

最后,安装剩下的两个包:

sudo apt install libc6-dev-armel-cross libc6-dev-armhf-cross

这将使您的系统恢复正常工作。

答案2

尝试重新安装libc6-dev-armhf-cross(对 执行相同操作libc6-dev-armel-cross

sudo apt remove libc6-dev-armhf-cross其次是sudo apt install libc6-dev-armhf-cross

apt install --reinstall似乎不起作用)

请注意,运行sudo apt remove可能会删除依赖于它的包。请参阅Olek Wojnar 的回答下面介绍如何在不删除依赖包的情况下执行此操作

答案3

为了防止删除太多依赖项,请尝试dpkg -P --force-depends

dpkg -P --force-depends libc6-armel-cross libc6-armhf-cross libc6-dev-armel-cross libc6-dev-armhf-cross

然后再次更新、获取并安装这些包:

apt update
[...]
apt clean
apt install libc6-armel-cross libc6-armhf-cross libc6-dev-armel-cross libc6-dev-armhf-cross
Building dependency tree       
Reading state information... Done
After this operation, 0 B of additional disk space will be used.
Get:1 http://en.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 libc6-armel-cross all 2.27-3ubuntu1cross1.1 [1,031 kB]
Get:2 http://en.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libc6-armhf-cross all 2.27-3ubuntu1cross1.1 [1,005 kB]
Get:3 http://en.archive.ubuntu.com/ubuntu bionic-updates/universe amd64 libc6-dev-armel-cross all 2.27-3ubuntu1cross1.1 [1,936 kB]
Get:4 http://en.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libc6-dev-armhf-cross all 2.27-3ubuntu1cross1.1 [1,899 kB]
Fetched 5,871 kB in 9s (661 kB/s)                                                                                                                                                           
Selecting previously unselected package libc6-armel-cross.
(Reading database ... 760110 files and directories currently installed.)
Preparing to unpack .../libc6-armel-cross_2.27-3ubuntu1cross1.1_all.deb ...
Unpacking libc6-armel-cross (2.27-3ubuntu1cross1.1) ...
dpkg: error processing archive /var/cache/apt/archives/libc6-armel-cross_2.27-3ubuntu1cross1.1_all.deb (--unpack):
 unable to open '/usr/arm-linux-gnueabi/lib/ld-2.27.so.dpkg-new': No such file or directory
No apport report written because the error message indicates an issue on the local system
[...]

--reinstall因此,无论是通过重新安装、手动安装依赖项还是使用都无法成功dpkg -[P|i] --force-depends

2018-10-09:由于这些软件包仍然损坏,但看不到任何更新,我将它们全部删除,以便能够使用 apt 安装(卸载)软件包。保持现状意味着无法安装或删除软件包。我正在使用本地安装的工具链来满足我的要求。

编辑:注意删除所有有问题的包和依赖项。

答案4

我使用 Ubuntu 18.04 中的 synaptic 包管理器通过删除有问题的包并稍后重新安装它们解决了该错误。

相关内容