如何解决linux内核的dpkg依赖? (Debian)

如何解决linux内核的dpkg依赖? (Debian)

当你运行时,你会如何解决这个错误sudo apt-get dist-upgrade

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up linux-image-4.9.0-3-amd64 (4.9.30-2+deb9u2) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-4.9.0-3-amd64
/etc/kernel/postinst.d/zz-update-grub:
/usr/sbin/grub-mkconfig: 1: /etc/default/grub: ]#: not found
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127
dpkg: error processing package linux-image-4.9.0-3-amd64 (--configure):
 subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of linux-image-amd64:
 linux-image-amd64 depends on linux-image-4.9.0-3-amd64; however:
  Package linux-image-4.9.0-3-amd64 is not configured yet.

dpkg: error processing package linux-image-amd64 (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 linux-image-4.9.0-3-amd64
 linux-image-amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)

我使用的是 Debian 9 (stretch),最新版本的内核实际上就是我目前拥有的内核 (linux-image-4.9.0-3-amd64)当我运行时,sudo dpkg --configure -a我收到以下消息:

sudo dpkg --configure -a
dpkg: dependency problems prevent configuration of linux-image-amd64:
 linux-image-amd64 depends on linux-image-4.9.0-3-amd64; however:
  Package linux-image-4.9.0-3-amd64 is not configured yet.

dpkg: error processing package linux-image-amd64 (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 linux-image-amd64

我尝试运行这些命令但无济于事:

sudo apt-get autoclean
sudo apt-get clean
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get -f install

如果我运行sudo dkpg --purge linux-image-4.9.0-3-amd64并更新并重新安装内核,我会收到此依赖项错误:

dpkg: dependency problems prevent removal of linux-image-4.9.0-3-amd64:
 linux-image-amd64 depends on linux-image-4.9.0-3-amd64.

dpkg: error processing package linux-image-4.9.0-3-amd64 (--purge):
 dependency problems - not removing
Errors were encountered while processing:
 linux-image-4.9.0-3-amd64

提前致谢。

答案1

事实证明它与依赖关系无关。更新过程中出现问题,GRUB 变得混乱。要重新安装 GRUB,请调用:

sudo apt-get update
sudo apt-get install --reinstall grub
sudo apt-get dist-upgrade
sudo apt-get upgrade
sudo apt autoremove

然后重新启动并再次尝试运行apt-get dist-upgrade,问题应该得到解决。

答案2

你没有依赖性问题。您有一个包配置问题。

文字记录的相关部分是:

/etc/kernel/postinst.d/zz-update-grub:
/usr/sbin/grub-mkconfig: 1: /etc/default/grub: ]#: not found
run-parts: /etc/kernel/postinst.d/zz-update-grub exited with return code 127

之后的一切都是这个问题的结果:内核安装后脚本失败,因此该软件包linux-image-4.9.0-3-amd64未正确安装(在 Debian 术语中,它未配置),因此依赖于它的软件包也未正确安装。

显然有一个拼写错误/etc/default/grub]看起来在行首)。解决这个问题,然后完成正在进行的安装

apt-get -f install

相关内容