如何清除 Elementary OS 中的舊核心包?

如何清除 Elementary OS 中的舊核心包?

在我的 Elementary OS 系統上,dpkg 會報告許多未安裝的核心軟體套件。 (我之前對它們進行了 apt-get purge。)我想讓它們完全被遺忘,但我不知道如何以這種方式得到它們。

例如:

elementary:~$ dpkg -l linux-*-3.2.0-51*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                 Version                              Description
+++-====================================-====================================-========================================================================================
un  linux-headers-3.2.0-51               <none>                               (no description available)
un  linux-headers-3.2.0-51-generic       <none>                               (no description available)
un  linux-image-3.2.0-51-generic         <none>                               (no description available)

apt-get purge 不起作用:

elementary:~$ sudo apt-get purge linux-headers-3.2.0-51
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package linux-headers-3.2.0-51 is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

dpkg 不起作用:

elementary:~$ sudo dpkg --purge linux-headers-3.2.0-51
dpkg: warning: there's no installed package matching linux-headers-3.2.0-51
elementary:~$ sudo dpkg --forget-old-unavail
dpkg: warning: obsolete '--forget-old-unavail' option, unavailable packages are automatically cleaned up.

apt-cache 顯示:

elementary:~$ apt-cache policy linux-headers-3.2.0-51
linux-headers-3.2.0-51:
  Installed: (none)
  Candidate: 3.2.0-51.77
  Version table:
     3.2.0-51.77 0
        500 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
        500 http://security.ubuntu.com/ubuntu/ precise-security/main amd64 Packages

aptitude 未安裝。

顯然,有些事情我不明白。為什麼 dpkg -l 顯示已清除的軟體包?我該如何讓 dpkg 忘記它們?

答案1

根據您的apt-cache policy輸出,它們仍然在存檔中(也稱為可用),因此 dpkg 不會忘記它們。所以簡短的回答是沒有辦法消除該記錄。

長答案是你可以編輯/var/lib/dpkg/status(它是一個純文字檔案)來做到這一點。請務必保留備份。破壞這個檔案並不是一件好事,糟糕程度接近“你考慮過重新安裝嗎?”

答案2

您可以使用dpkg --clear-availdpkgs 刪除可用的套件清單。

相關內容