當前位置: 首頁>>技術教程>>正文


apt – 如何解決 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)

我已經嘗試了很多,但無法正常工作。我想我中斷了安裝,它隻是把它搞砸了。我用穀歌搜索並嘗試了各種修複。

編輯(清理我的 /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$

最佳思路

確保您的係統處於良好狀態並且沒有中止安裝問題的一個很好的嘗試是調用

  dpkg --configure -a 

確保包列表已更新並且沒有問題顯示在:

 apt-get update

您可以選擇在更新前刪除所有舊數據:

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

解決問題的下一步是暫時刪除 linux-server 包。可以這樣做,因為它沒有真正的內容,隻引入了一個依賴項:

This package will always depend on the latest complete Linux kernel available for Server Equipment.

 dpkg --remove linux-server

在此步驟之後,檢查是否安裝了所有當前依賴項:

apt-get install -f

如果一切正常您現在可以再次安裝 linux-server:

apt-get install linux-server

Postscriptum

linux-server 在 12.04 中已棄用。對於服務器設備,也使用通用內核。見 apt-cache show linux-image-server

Package: linux-image-server…

Section: metapackages

….

Depends: linux-image-3.2.0-23-generic, linux-firmware

次佳思路

我經常不得不清理我的機器的 /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

祝你好運!

參考資料

本文由Ubuntu問答整理, 博文地址: https://ubuntuqa.com/zh-tw/article/11939.html,未經允許,請勿轉載。