apt-get install 每次都无法创建依赖关系树

apt-get install 每次都无法创建依赖关系树

最近,我们使用 apt-get install 来安装“任何东西”,我得到以下内容:

amr@Ubuntu-Latitude-E6410:~$ sudo apt-get install printer- 
driver-cups-pdf
[sudo] password for amr: 
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:
linux-image-generic-hwe-16.04 : Depends: linux-image-4.15.0-34- 
generic but it is not going to be installed
linux-modules-extra-4.15.0-34-generic : Depends: linux-image- 
4.15.0-34-generic but it is not going to be installed or
                                              linux-image- 
unsigned-4.15.0-34-generic but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages 
(or specify a solution).
amr@Ubuntu-Latitude-E6410:~$ 

以前没有,我不确定发生了什么变化导致这种情况发生。有什么办法可以解决这个问题吗?我每次都尝试安装提到的依赖项,但收到相同的消息。当我尝试从不同来源安装各种软件包时,就会发生这种情况。所需的软件包每次都不同,上面就是一个例子。

答案1

好吧,今天我遇到了一些‘乐趣’,它们看起来和你遇到的问题一模一样!

这是我尝试升级后发生的情况:

$ sudo apt-get upgrade
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:
 linux-image-generic-hwe-16.04 : Depends: linux-image-4.15.0-34-generic but it is not installed
 linux-modules-extra-4.15.0-34-generic : Depends: linux-image-4.15.0-34-generic but it is not installed or
                                                  linux-image-unsigned-4.15.0-34-generic but it is not installed
E: Unmet dependencies. Try using -f.

然后如果我尝试使用 -f 修复依赖关系...

$ sudo apt-get -f install
... (some extra prints not relevant) ...
dpkg: error processing archive /var/cache/apt/archives/linux-image-4.15.0-34-generic_4.15.0-34.37~16.04.1_amd64.deb (--unpack):
 cannot copy extracted data for './boot/vmlinuz-4.15.0-34-generic' to '/boot/vmlinuz-4.15.0-34-generic.dpkg-new': failed to write (No space left on device)

声称没有空间!确实如此……我的行李箱现在已经满了。让我们尝试清理一些空间……

$ sudo apt-get autoremove 
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:
 linux-image-generic-hwe-16.04 : Depends: linux-image-4.15.0-34-generic but it is not installed
 linux-modules-extra-4.15.0-34-generic : Depends: linux-image-4.15.0-34-generic but it is not installed or
                                                  linux-image-unsigned-4.15.0-34-generic but it is not installed
E: Unmet dependencies. Try using -f.

哎呀...我不行!而且“ubuntu-cleaner”(管理员)也不起作用...


解决方案...

总而言之,我在这个链接中找到了解决方案:链接 - 删除旧内核 我必须做的是手动删除内核...所以我按照推荐的步骤进行操作。

检查当前内核:

$ uname -r
4.15.0-33-generic

打印所有可用的内核。选择一些删除...切勿删除您现在正在使用的内核!(在我的示例中为 4.15.0-33)。

$ dpkg -l | tail -n +6 | grep -E 'linux-image-[0-9]+'
ii  linux-image-4.13.0-43-generic              4.13.0-43.48~16.04.1                         amd64        Linux kernel image for version 4.13.0 on 64 bit x86 SMP
ii  linux-image-4.13.0-45-generic              4.13.0-45.50~16.04.1                         amd64        Linux kernel image for version 4.13.0 on 64 bit x86 SMP
ii  linux-image-4.15.0-24-generic              4.15.0-24.26~16.04.1                         amd64        Signed kernel image generic
ii  linux-image-4.15.0-29-generic              4.15.0-29.31~16.04.1                         amd64        Signed kernel image generic
ii  linux-image-4.15.0-30-generic              4.15.0-30.32~16.04.1                         amd64        Signed kernel image generic
ii  linux-image-4.15.0-32-generic              4.15.0-32.35~16.04.1                         amd64        Signed kernel image generic
ii  linux-image-4.15.0-33-generic              4.15.0-33.36~16.04.1                         amd64        Signed kernel image generic

清除一些内核...

$ sudo update-initramfs -d -k linux-image-4.13.0-43-generic
update-initramfs: Deleting /boot/initrd.img-linux-image-4.13.0-43-generic

$ sudo dpkg --purge linux-image-4.13.0-43-generic linux-image-extra-4.13.0-43-generic 
(Reading database ... 434301 files and directories currently installed.)
Removing linux-image-extra-4.13.0-43-generic (4.13.0-43.48~16.04.1) ...
...

现在,我有足够的空间来尝试修复依赖关系......

$ sudo 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-4.13.0-43 linux-headers-4.13.0-43-generic linux-headers-4.15.0-24 linux-headers-4.15.0-24-generic linux-headers-4.15.0-29
  linux-headers-4.15.0-29-generic linux-headers-4.15.0-30 
  ...

自由运行!运气好的话,您的依赖项现已修复。您可以照常发出更新/安装。

$ sudo apt-get update
...
$ sudo apt-get upgrade
...

在此步骤中,我还发出了一个sudo apt-get autoremove实际有效的命令,它清理了所有以前的内核。

请查看链接了解更多信息。祝你好运!

相关内容