我如何解决 dpkg 依赖性?

我如何解决 dpkg 依赖性?
administrator@zlounes:~$ sudo apt-get dist-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-server : Depends: linux-headers-server (= 3.2.0.37.44) but 3.2.0.37.45 is installed
E: Unmet dependencies. Try using -f.
administrator@zlounes:~$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  linux-image-server linux-server
The following packages will be upgraded:
  linux-image-server linux-server
2 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
4 not fully installed or removed.
Need to get 0 B/4,458 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
Traceback (most recent call last):
  File "/usr/bin/apt-listchanges", line 237, in <module>
    main()
  File "/usr/bin/apt-listchanges", line 48, in main
    debs = apt_listchanges.read_apt_pipeline(config)
  File "/usr/share/apt-listchanges/apt_listchanges.py", line 83, in read_apt_pipeline
    return map(lambda pkg: filenames[pkg], order)
  File "/usr/share/apt-listchanges/apt_listchanges.py", line 83, in <lambda>
    return map(lambda pkg: filenames[pkg], order)
KeyError: 'linux-image-server'
Setting up initramfs-tools (0.99ubuntu13.1) ...
update-initramfs: deferring update (trigger activated)
Setting up linux-image-3.2.0-37-generic (3.2.0-37.58) ...
Running depmod.
update-initramfs: deferring update (hook will be called later)
The link /initrd.img is a dangling linkto /boot/initrd.img-3.2.0-37-generic
Examining /etc/kernel/postinst.d.
run-parts: executing /etc/kernel/postinst.d/initramfs-tools 3.2.0-37-generic /boot/vmlinuz-3.2.0-37-generic
update-initramfs: Generating /boot/initrd.img-3.2.0-37-generic

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.2.0-37-generic with 1.
run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-3.2.0-37-generic.postinst line 1010.
dpkg: error processing linux-image-3.2.0-37-generic (--configure):
 subprocess installed post-installation script returned error exit status 2
dpkg: dependency problems prevent configuration of linux-image-server:
 linux-image-server depends on linux-image-3.2.0-37-generic; however:
  Package linux-image-3.2.0-37-generic is not configured yet.
dpkg: error processing linux-image-server (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of linux-server:
 linux-server depends on linux-image-server (= 3.2.0.37.44); however:
  Package linux-image-server is not configured yet.
 linux-server depends on linux-headers-server (= 3.2.0.37.44); however:
  Version of linux-headers-server on system is 3.2.0.37.45.
dpkg: error processing linux-server (--configure):
 dependency problems - leaving unconfigured
Processing triggers for initramfs-tools ...
update-initramfs: Generating /boot/initrd.img-3.2.0-36-generic
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          No apport report written because the error message indicates its a followup error from a previous failure.

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-3.2.0-36-generic with 1.
dpkg: error processing initramfs-tools (--configure):
 subprocess installed post-installation script returned error exit status 1
No apport report written because MaxReports is reached already
                                                              Errors were encountered while processing:
 linux-image-3.2.0-37-generic
 linux-image-server
 linux-server
 initramfs-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

我尝试了很多方法,但还是无法让它正常工作。我想我中断了安装,结果一切都搞砸了。我在 Google 上搜索并尝试了各种修复方法。

编辑(清理我的 /boot 文件夹后):

administrator@zlounes:/boot$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following extra packages will be installed:
  linux-server
The following packages will be upgraded:
  linux-server
1 upgraded, 0 newly installed, 0 to remove and 9 not upgraded.
1 not fully installed or removed.
Need to get 0 B/1,734 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue [Y/n]? y
Traceback (most recent call last):
  File "/usr/bin/apt-listchanges", line 237, in <module>
    main()
  File "/usr/bin/apt-listchanges", line 48, in main
    debs = apt_listchanges.read_apt_pipeline(config)
  File "/usr/share/apt-listchanges/apt_listchanges.py", line 83, in read_apt_pipeline
    return map(lambda pkg: filenames[pkg], order)
  File "/usr/share/apt-listchanges/apt_listchanges.py", line 83, in <lambda>
    return map(lambda pkg: filenames[pkg], order)
KeyError: 'linux-server'
dpkg: dependency problems prevent configuration of linux-server:
 linux-server depends on linux-image-server (= 3.2.0.37.44); however:
  Version of linux-image-server on system is 3.2.0.37.45.
 linux-server depends on linux-headers-server (= 3.2.0.37.44); however:
  Version of linux-headers-server on system is 3.2.0.37.45.
dpkg: error processing linux-server (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          E: Sub-process /usr/bin/dpkg returned an error code (1)
administrator@zlounes:/boot$

答案1

为确保系统状况良好且不会出现安装中止问题,可以尝试调用

  dpkg --configure -a 

确保软件包列表已更新并且没有显示任何问题:

 apt-get update

您可以选择在更新之前删除所有旧数据:

 find /var/lib/apt/lists -type f  |xargs rm -f >/dev/null \

解决问题的下一步是删除Linux 服务器暂时不要使用它。这样做是因为它没有实际内容,只引入了依赖项:

该软件包将始终依赖于可用于服务器设备的最新完整的 Linux 内核。

 dpkg --remove linux-server

完成此步骤后,检查所有当前依赖项是否都已安装:

apt-get install -f

如果一切正常,你现在可以安装Linux 服务器再次:

apt-get install linux-server

后记

Linux 服务器已弃用12.04. 也适用于服务器设备使用通用内核。请参阅apt-cache show linux-image-server

软件包:linux-image-server...

部分:元包

....

依赖: linux-image-3.2.0-23-通用的, Linux 固件

答案2

我经常需要清理机器的 /boot,通常因为太满而中断更新 - 不确定最终的解决方案是什么,但我使用的流程似乎有效:

sudo su

然后转到 /boot 并执行ls -lSrh- 底部的是最大的 -rm足够多的较旧的以清除足够的空间。

然后尝试以下步骤(摘录自上面):

  1. sudo apt-get remove linux-server
  2. dpkg --configure -a
  3. apt-get update
  4. apt-get install -f
  5. apt-get autoremove
  6. dpkg --get-selections|grep 'linux-image*'|awk '{print $1}'|egrep -v "linux-image-$(uname -r)|linux-image-generic" |while read n;done
  7. apt-get install linux-image-server linux-server
  8. reboot

如果出现任何问题,请在此处发表评论,我会查看问题可能是什么。

当使用 pitti PPA 时,我也看到过这种情况对于 postgresql-9.1 包问题有效。

有一次,当我运行该程序时,我遇到了 grub 问题。做了修复apt-get install --reinstall grub

感谢你的一句:http://ubuntuforums.org/showpost.php?p=12180959&postcount=7

祝你好运!

答案3

我在使用 dpkg 时遇到了类似的问题:

dpkg: dependency problems prevent configuration of rpi-imager:
 rpi-imager depends on qml-module-qtquick2; however:
 Package qml-module-qtquick2 is not installed.

解决方案是运行sudo apt --fix-broken install

答案4

TL;DR 使用dpkg --ignore-depends=...


我尝试安装 pulse-secure vpn 客户端。

dpkg: regarding .../ps-pulse-ubuntu-debian.deb containing pulsesecure, pre-dependency problem:
 pulsesecure pre-depends on libcurl4
  libcurl4 is not installed.

dpkg: warning: ignoring pre-dependency problem!
(Reading database ... 208790 files and directories currently installed.)
Preparing to unpack .../ps-pulse-ubuntu-debian.deb ...

解决了有旗子--ignore-depends=...

sudo dpkg --ignore-depends=libcurl4 -i /valo/pulse-secure-ubuntu-debian.deb

相关内容