失败时强制卸载包

失败时强制卸载包

我的系统有一些损坏的依赖项,但是当尝试通过apt-get purge或 via卸载它们时dpkg --purge --force-all,该过程失败并显示errors were encountered while processing.

更具体地说,我有一个linux-image-extra包,它的linux-image依赖项不再是不可安装的。我安装了更新的内核,因此删除它应该不是问题,但卸载过程总是失败。

那么我可以强制删除该软件包,这样就不再有冲突,并且我可以再次更新我的系统吗?


卸载时出现的错误:

sudo dpkg --purge --force-all linux-image-extra-3.19.0-51-generic
(Reading database ... 229019 files and directories currently installed.)
Removing linux-image-extra-3.19.0-51-generic (3.19.0-51.58) ...
depmod: FATAL: could not load /boot/System.map-3.19.0-51-generic: No such file or directory
run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 3.19.0-51-generic /boot/vmlinuz-3.19.0-51-generic
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.19.0-51-generic /boot/vmlinuz-3.19.0-51-generic
update-initramfs: Generating /boot/initrd.img-3.19.0-51-generic
WARNING: missing /lib/modules/3.19.0-51-generic
Ensure all necessary drivers are built into the linux image!
depmod: ERROR: could not open directory /lib/modules/3.19.0-51-generic: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
sed: can't read /usr/share/plymouth/themes/kubuntu-text/kubuntu-text.plymouth: No such file or directory
E: /usr/share/initramfs-tools/hooks/plymouth failed with return 2.
update-initramfs: failed for /boot/initrd.img-3.19.0-51-generic with 2.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 2
dpkg: error processing package linux-image-extra-3.19.0-51-generic (--purge):
 subprocess installed post-removal script returned error exit status 1
Errors were encountered while processing:
 linux-image-extra-3.19.0-51-generic

答案1

没有一般的程序,但需要具体情况具体分析。正如您从这些页面中看到的,有一个受到推崇的并不总是有效的方法:

如果您已尝试了推荐的步骤,那么您就已经进入了故障排除阶段。

有时,您可以通过添加虚拟文件或目录来安抚卸载脚本。在这种情况下,您可以这样做:

depmod: ERROR: could not open directory /lib/modules/3.19.0-51-generic: No such file or directory

然而,在这种情况下,

depmod: FATAL: could not load /boot/System.map-3.19.0-51-generic: No such file or directory

很难解决,因为这将是一个具有给定的文件格式。 (您可以尝试制作零长度文件,但这可能行不通)。

或者,重新安装损坏的软件包有时也有效,方法是将丢失的部分恢复到卸载程序可以处理的某种顺序。

相关内容