无法在 Ubuntu 20.04 上安装“libdrm-dev”,因为它需要的依赖项比我现有的更旧

无法在 Ubuntu 20.04 上安装“libdrm-dev”,因为它需要的依赖项比我现有的更旧
$ sudo apt install libdrm-dev
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:
 libdrm-dev : Depends: libdrm2 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is to be installed
              Depends: libdrm-intel1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is to be installed
              Depends: libdrm-radeon1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is to be installed
              Depends: libdrm-nouveau2 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is to be installed
              Depends: libdrm-amdgpu1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is to be installed
E: Unable to correct problems, you have held broken packages.

我可以强制它使用我的新版本吗?我遗漏了什么吗?sudo aptitude install libdrm-dev显示我当前的版本较新:

$ sudo aptitude install libdrm-dev
The following NEW packages will be installed:
  libdrm-dev{b} 
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 126 kB of archives. After unpacking 658 kB will be used.
The following packages have unmet dependencies:
 libdrm-dev : Depends: libdrm2 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
              Depends: libdrm-intel1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
              Depends: libdrm-radeon1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
              Depends: libdrm-nouveau2 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
              Depends: libdrm-amdgpu1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     libdrm-dev [Not Installed]                         



Accept this solution? [Y/n/q/?] 

答案1

[我的建议] 使用自动降级安装的依赖项aptitude进行安装libdrm-dev

我明白了,并且这有效:用来aptitude降级依赖项。

仅命令:

sudo aptitude install libdrm-dev
# then choose these options:
n  # do NOT leave things as-is
y  # DO downgrade dependencies
y  # Do continue with the install

运行 后sudo aptitude install libdrm-dev,选择no其建议Keep the following packages at their current version,并选择yes其建议 ,其中它表示Remove the following packagesInstall the following packagesDowngrade the following packages。然后yes再次选择 ,其中它表示0 packages upgraded, 2 newly installed, 13 downgraded, 5 to remove and 0 not upgraded. Need to get 33.4 MB of archives. After unpacking 140 MB will be freed. Do you want to continue? [Y/n/?]。就是这样!它会(稍微)降级一些软件包,现在可以正常安装!

细节:

以下是完整的命令和输出(我将在下面解释)。我用一些标记标记了我输入ny和 的位置:y<======

$ sudo aptitude install libdrm-dev
The following NEW packages will be installed:
  libdrm-dev{b} 
0 packages upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 126 kB of archives. After unpacking 658 kB will be used.
The following packages have unmet dependencies:
 libdrm-dev : Depends: libdrm2 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
              Depends: libdrm-intel1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
              Depends: libdrm-radeon1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
              Depends: libdrm-nouveau2 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
              Depends: libdrm-amdgpu1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     libdrm-dev [Not Installed]                         



Accept this solution? [Y/n/q/?] n                           <=================
The following actions will resolve these dependencies:

      Remove the following packages:                                                    
1)      mesa-va-drivers [21.2.6-0ubuntu0.1~20.04.2 (now)]                               
2)      va-driver-all [2.7.0-2 (focal, now)]                                            

      Install the following packages:                                                   
3)      libllvm9 [1:9.0.1-12 (focal)]                                                   

      Downgrade the following packages:                                                 
4)      libdrm-amdgpu1 [2.4.107-8ubuntu1~20.04.2 (now) -> 2.4.101-2 (focal)]            
5)      libdrm-intel1 [2.4.107-8ubuntu1~20.04.2 (now) -> 2.4.101-2 (focal)]             
6)      libdrm-nouveau2 [2.4.107-8ubuntu1~20.04.2 (now) -> 2.4.101-2 (focal)]           
7)      libdrm-radeon1 [2.4.107-8ubuntu1~20.04.2 (now) -> 2.4.101-2 (focal)]            
8)      libdrm2 [2.4.107-8ubuntu1~20.04.2 (now) -> 2.4.101-2 (focal)]                   
9)      libegl-mesa0 [21.2.6-0ubuntu0.1~20.04.2 (now) -> 20.0.4-2ubuntu1 (focal)]       
10)     libgbm1 [21.2.6-0ubuntu0.1~20.04.2 (now) -> 20.0.4-2ubuntu1 (focal)]            
11)     libgl1-mesa-dri [21.2.6-0ubuntu0.1~20.04.2 (now) -> 20.0.4-2ubuntu1 (focal)]    
12)     libglapi-mesa [21.2.6-0ubuntu0.1~20.04.2 (now) -> 20.0.4-2ubuntu1 (focal)]      
13)     libglx-mesa0 [21.2.6-0ubuntu0.1~20.04.2 (now) -> 20.0.4-2ubuntu1 (focal)]       
14)     libosmesa6 [21.2.6-0ubuntu0.1~20.04.2 (now) -> 20.0.4-2ubuntu1 (focal)]         
15)     mesa-vdpau-drivers [21.2.6-0ubuntu0.1~20.04.2 (now) -> 20.0.4-2ubuntu1 (focal)] 
16)     mesa-vulkan-drivers [21.2.6-0ubuntu0.1~20.04.2 (now) -> 20.0.4-2ubuntu1 (focal)]



Accept this solution? [Y/n/q/?] y                           <=================
The following packages will be DOWNGRADED:
  libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libegl-mesa0 libgbm1 libgl1-mesa-dri libglapi-mesa libglx-mesa0 libosmesa6 mesa-vdpau-drivers mesa-vulkan-drivers 
The following NEW packages will be installed:
  libdrm-dev libllvm9{a} 
The following packages will be REMOVED:
  i965-va-driver{u} intel-media-va-driver{u} libigdgmm11{u} mesa-va-drivers{a} va-driver-all{a} 
0 packages upgraded, 2 newly installed, 13 downgraded, 5 to remove and 0 not upgraded.
Need to get 33.4 MB of archives. After unpacking 140 MB will be freed.
Do you want to continue? [Y/n/?] y                          <=================

注意未满足的依赖关系。如你所见,它说需要 libdrm2 版本 2.4.101-2,但我安装了版本 2.4.107-8ubuntu1~20.04.2,等等。奇怪的是,我的版本也是新的为了它。

The following packages have unmet dependencies:
 libdrm-dev : Depends: libdrm2 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
              Depends: libdrm-intel1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
              Depends: libdrm-radeon1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
              Depends: libdrm-nouveau2 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed
              Depends: libdrm-amdgpu1 (= 2.4.101-2) but 2.4.107-8ubuntu1~20.04.2 is installed

所以,aptitude首先提出一个解决方案:

     Keep the following packages at their current version:
1)     libdrm-dev [Not Installed] 

我按下n拒绝该解决方案。然后它提出了一个更好的解决方案来降低依赖项并执行安装。我选择y该选项。然后我必须y稍后再次选择。

完成后,您可以看到常规sudo apt install libdrm-dev工作现在也可以正常工作,表明libdrm-dev已经成功安装!:

$ sudo apt install libdrm-dev
[sudo] password for gabriel: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libdrm-dev is already the newest version (2.4.101-2).
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.

完毕!

现在我可以回到在 Ubuntu 20.04 上安装 displaylink-driver,这样我就可以使用我的新双 4k 60 Hz USB-A 适配器了!请在此处查看我的答案:适用于 Ubuntu 的 USB 转 HDMI 适配器

替代方案:如何libdrm从源代码构建和安装最新版本

这并没有完全回答我的问题,但是这里是如何libdrm从源代码构建的:

源代码在这里:https://gitlab.freedesktop.org/mesa/drm

在此获取最新标记版本:https://gitlab.freedesktop.org/mesa/drm/-/tags

下载并解压。

请参阅自述文件中的“编译”说明:https://gitlab.freedesktop.org/mesa/drm

跑步:

meson builddir/  # prep a folder
time sudo ninja -C builddir/ install  # build and install

仅需 20 秒即可构建和安装。它安装到/usr/local/include/libdrm

相关内容