Linux-Mint

如何在 Mint 19 上使用 Nvidia 465 處理這個“損壞的包”問題?

  • May 4, 2021

因此,Mint 19 在更新管理器中使用 Nvidia 的 465 驅動程序讓我感到驚訝,我嘗試安裝它;但它所做的一切(很難說它是否下載了任何東西)告訴我它“無法應用更改!首先修復損壞的包。”

彈出錯誤

令人擔憂的是,沒有關於哪個包被破壞的註釋,而且我沒有任何 Synaptic 知道被破壞的東西。我還沒有重新啟動我的系統,因為我不知道我目前的驅動程序是否仍然可行。

嘗試通過 apt 執行此操作告訴我,許多軟體包已被“保留”;雖然有趣的是,它們都以 455 結尾。

$ sudo apt upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
 libnvidia-cfg1-455 libnvidia-common-455 libnvidia-compute-455
 libnvidia-compute-455:i386 libnvidia-decode-455 libnvidia-decode-455:i386
 libnvidia-encode-455 libnvidia-encode-455:i386 libnvidia-extra-455
 libnvidia-fbc1-455 libnvidia-fbc1-455:i386 libnvidia-gl-455
 libnvidia-ifr1-455 libnvidia-ifr1-455:i386 nvidia-compute-utils-455
 nvidia-kernel-common-455 nvidia-kernel-source-455
 xserver-xorg-video-nvidia-455
0 upgraded, 0 newly installed, 0 to remove and 18 not upgraded.

我只能假設我的包組織出現了嚴重問題,但我真的不知道它是什麼或如何解決它。我希望有人可以為我闡明這一點。我從來沒有以不恰當的方式在這台機器上安裝驅動程序,而且我很少有一個損壞的包開始。

嘗試手動安裝上述軟體包給了我這個。

$ sudo apt install libnvidia-cfg1-455 libnvidia-common-455 libnvidia-compute-455 libnvidia-compute-455:i386 libnvidia-decode-455 libnvidia-decode-455:i386 libnvidia-encode-455 libnvidia-encode-455:i386 libnvidia-extra-455 libnvidia-fbc1-455 libnvidia-fbc1-455:i386 libnvidia-gl-455 libnvidia-ifr1-455 libnvidia-ifr1-455:i386 nvidia-compute-utils-455 nvidia-kernel-common-455 nvidia-kernel-source-455 xserver-xorg-video-nvidia-455
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
nvidia-kernel-common-455 : Depends: nvidia-kernel-common-465 but it is not going to be installed
nvidia-kernel-source-455 : Depends: nvidia-kernel-source-465 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

這對我來說特別奇怪,因為它暗示 455 依賴於 465,它本來就不應該存在。

#!/bin/bash

# script: list-nvidia.sh
# author: Craig Sanders <cas@taz.net.au>
# license: Public Domain (this script is too trivial to be anything else)

# options:
# default/none    list the packages, one per line
# -v              verbose (dpkg -l) list the packages
# -h              hold the packages with apt-mark
# -u              unhold the packages with apt-mark

# build an array of currently-installed nvidia packages.
PKGS=( $(dpkg -l '*nvidia*' '*cuda*' '*vdpau*' 2>/dev/null |
          awk '/^[hi][^n]/ && ! /mesa/ {print $2}') )

case "$1" in
 "-v") dpkg -l "${PKGS[@]}" ;;
 "-h") apt-mark hold "${PKGS[@]}" ;;
 "-u") apt-mark unhold "${PKGS[@]}" ;;
 *) printf "%s\n" "${PKGS[@]}" ;;
esac

此腳本可以每行列出一個已安裝的與 nvidia 相關的軟體包,或者以詳細dpkg -l格式列出。

它還可以apt-mark用來保留和取消保留 nvidia 包 - 我在之前和之後立即使用這些選項apt-get dist-upgrade以確保 nvidia 驅動程序僅在想要它時升級(即當我準備重新啟動系統時,或者殺死和重新啟動 X)。

printf如果我想用列表做其他事情,比如在命令替換中使用它——例如apt purge $(list-nvidia.sh). Debian 軟體包名稱中永遠不會有空格或換行符等,因此無需對引用感到偏執。

引用自:https://unix.stackexchange.com/questions/647928