dpkg 尝试卸载不存在的包

dpkg 尝试卸载不存在的包

linux-modules-nvidia-390-5.8.0-59-generic 的 dpkg 预删除退出状态 1

我尝试过sudo apt update,,sudo apt upgrade但问题在于此。

$ sudo 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:
 linux-modules-nvidia-390-5.8.0-59-generic : Depends: nvidia-kernel-common-390 (<=390.143-1) but 390.157-0ubuntu0.20.04.1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

然后我按照说明进行操作。sudo apt --fix-broken install

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages will be REMOVED:
  linux-modules-nvidia-390-5.8.0-59-generic
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 32.8 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 292270 files and directories currently installed.)
Removing linux-modules-nvidia-390-5.8.0-59-generic (5.8.0-59.66~20.04.1) ...
/var/lib/dpkg/info/linux-modules-nvidia-390-5.8.0-59-generic.prerm: 14: cd: can'
t cd to /lib/modules/5.8.0-59-generic/kernel/nvidia-390/bits
dpkg: error processing package linux-modules-nvidia-390-5.8.0-59-generic (--remo
ve):
 installed linux-modules-nvidia-390-5.8.0-59-generic package pre-removal script 
subprocess returned error exit status 1
dpkg: too many errors, stopping
Errors were encountered while processing:
 linux-modules-nvidia-390-5.8.0-59-generic
Processing was halted because there were too many errors.
E: Sub-process /usr/bin/dpkg returned an error code (1)

我也尝试过这个。sudo dpkg -P linux-modules-nvidia-390-5.8.0-59-generic

(Reading database ... 292270 files and directories currently installed.)
Removing linux-modules-nvidia-390-5.8.0-59-generic (5.8.0-59.66~20.04.1) ...
/var/lib/dpkg/info/linux-modules-nvidia-390-5.8.0-59-generic.prerm: 14: cd: can't cd to /lib/modules/5.8.0-59-generic/kernel/nvidia-390/bits
dpkg: error processing package linux-modules-nvidia-390-5.8.0-59-generic (--purge):
 installed linux-modules-nvidia-390-5.8.0-59-generic package pre-removal script subprocess returned error exit status 1
Errors were encountered while processing:
 linux-modules-nvidia-390-5.8.0-59-generic

我也尝试过这些(使用 sudo),但它们不起作用。

apt autoremove
apt autoclean
sudo dpkg --force-all -P linux-modules-nvidia-390-5.8.0-59-generic
apt autoremove -f
apt --fix-broken install
sudo apt full-upgrade

我也尝试了 GUI 更新程序。在此处输入图片描述(翻译:并非所有更新都可以安装) 在此处输入图片描述(翻译:apt 索引损坏)

附言:我不确定这是否相关。这是同时发生的。更新后屏幕出现故障

更新:看来相关软件包已被某人删除(可能是 livepatch?)但它并未在 dpkg/apt 目录中取消注册。

有没有办法更新 dpkg/apt 目录以便将其标记为未安装?

答案1

由于该包不再存在(可能是被 livepatch 卸载了?),我所要做的就是将其从目录中删除。
所以我编辑了/var/lib/dpkg/status。我删除了这些行。

Package: linux-modules-nvidia-390-5.8.0-59-generic
Status: deinstall ok installed
Priority: optional
Section: kernel
Installed-Size: 32
Maintainer: Canonical Kernel Team <[email protected]>
Architecture: amd64
Source: linux-restricted-modules-hwe-5.8
Version: 5.8.0-59.66~20.04.1
Depends: debconf (>= 0.5) | debconf-2.0, linux-image-5.8.0-59-generic | linux-image-unsigned-5.8.0-59-generic, linux-signatures-nvidia-5.8.0-59-generic (= 5.8.0-59.66~20.04.1), linux-objects-nvidia-390-5.8.0-59-generic (= 5.8.0-59.66~20.04.1), nvidia-kernel-common-390 (<= 390.143-1), nvidia-kernel-common-390 (>= 390.143)
Description: Linux kernel nvidia modules for version 5.8.0-59
 This package pulls together the Linux kernel nvidia modules for
 version 5.8.0-59 with the appropriate signatures.
 .
 You likely do not want to install this package directly. Instead, install the
 one of the linux-modules-nvidia-390-generic* meta-packages,
 which will ensure that upgrades work correctly, and that supporting packages are also installed.

此时 apt 目录就修复了,上面的方法(如sudo apt full-upgrade)就可以起作用了。

相关内容