包管理工具aptitude确实比apt更好用

最近在Ubuntu 22.04上编译开源项目biyi遇到一些问题,让我又重新认识到aptitude对比apt的优越性。

 

biyi,一个优秀的便捷翻译和词典应用,支持划词/截图翻译,适用于 Windows、macOS 和 Linux。

编译过程中,需要安装一些依赖,比如:libastreamer-plugins-base1.0-dev,习惯性用apt安装:

spt@spt-pc:~/biyidev/biyi/apps/biyi_app$ sudo apt install libgstreamer-plugins-base1.0-dev
Reading package lists... Done
Building dependency tree... Done
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:
libegl-mesa0 : Depends: libgbm1 (= 22.0.1-1ubuntu2.1) but 22.2.5-0ubuntu0.1~22.04.1 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

apt工具提示很普通,给出了安装失败的原因,在于依赖libgbm1的版本太新。

如果换成aptitude再试试呢?

spt@spt-pc:~/biyidev/biyi/apps/biyi_app$ sudo aptitude install libgstreamer-plugins-base1.0-dev 
The following NEW packages will be installed:
  libdrm-dev{a} libgbm-dev{a} libgstreamer-plugins-base1.0-dev libgudev-1.0-dev{a} liborc-0.4-dev{a} 
  liborc-0.4-dev-bin{a} libpciaccess-dev{a} libudev-dev{a} libx11-xcb-dev{a} 
The following packages will be upgraded:
  libdrm-amdgpu1 libdrm-common libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libgbm1 
7 packages upgraded, 9 newly installed, 0 to remove and 215 not upgraded.
Need to get 1,461 kB of archives. After unpacking 10.7 MB will be used.
The following packages have unmet dependencies:
 libegl-mesa0 : Depends: libgbm1 (= 22.0.1-1ubuntu2.1) but 22.2.5-0ubuntu0.1~22.04.1 is to be installed
The following actions will resolve these dependencies:

     Install the following packages:                                                         
1)     libllvm15 [1:15.0.6-3~ubuntu0.22.04.2 (jammy-updates)]                                

     Upgrade the following packages:                                                         
2)     libegl-mesa0 [22.0.1-1ubuntu2.1 (now) -> 22.2.5-0ubuntu0.1~22.04.1 (jammy-updates)]   
3)     libgl1-mesa-dri [22.0.1-1ubuntu2.1 (now) -> 22.2.5-0ubuntu0.1~22.04.1 (jammy-updates)]
4)     libglapi-mesa [22.0.1-1ubuntu2.1 (now) -> 22.2.5-0ubuntu0.1~22.04.1 (jammy-updates)]  
5)     libglx-mesa0 [22.0.1-1ubuntu2.1 (now) -> 22.2.5-0ubuntu0.1~22.04.1 (jammy-updates)]   


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

aptitude不仅仅指出失败的原因,还给出了解决方案。

如果你不同意这个解决方案,输入n,还会接着给你另外的解决方案:

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

     Keep the following packages at their current version:
1)     libgbm-dev [Not Installed]                         
2)     libgbm1 [22.0.1-1ubuntu2.1 (now)]                  
3)     libgstreamer-plugins-base1.0-dev [Not Installed]   

当然针对这个问题,我认为aptitude默认给出的解决方案是可行的。

Accept this solution? [Y/n/q/?] Y
The following NEW packages will be installed:
  libdrm-dev{a} libgbm-dev{a} libgstreamer-plugins-base1.0-dev libgudev-1.0-dev{a} libllvm15{a} liborc-0.4-dev{a} 
  liborc-0.4-dev-bin{a} libpciaccess-dev{a} libudev-dev{a} libx11-xcb-dev{a} 
The following packages will be upgraded:
  libdrm-amdgpu1 libdrm-common libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libdrm2 libegl-mesa0 libgbm1 libgl1-mesa-dri 
  libglapi-mesa libglx-mesa0 
11 packages upgraded, 10 newly installed, 0 to remove and 211 not upgraded.
Need to get 34.7 MB of archives. After unpacking 128 MB will be used.
Do you want to continue? [Y/n/?] Y
Get: 1 http://mirrors.yun-idc.com/ubuntu jammy-updates/main amd64 libdrm-common all 2.4.113-2~ubuntu0.22.04.1 [5,450 B]
Get: 2 http://mirrors.yun-idc.com/ubuntu jammy-updates/main amd64 libdrm2 amd64 2.4.113-2~ubuntu0.22.04.1 [38.1 kB]
......................
Setting up libdrm2:amd64 (2.4.113-2~ubuntu0.22.04.1) ...
Setting up libdrm-amdgpu1:amd64 (2.4.113-2~ubuntu0.22.04.1) ...
Setting up libdrm-nouveau2:amd64 (2.4.113-2~ubuntu0.22.04.1) ...
Setting up libgbm1:amd64 (22.2.5-0ubuntu0.1~22.04.1) ...
Setting up libdrm-radeon1:amd64 (2.4.113-2~ubuntu0.22.04.1) ...
Setting up libdrm-intel1:amd64 (2.4.113-2~ubuntu0.22.04.1) ...
Setting up libgl1-mesa-dri:amd64 (22.2.5-0ubuntu0.1~22.04.1) ...
Setting up libgbm-dev:amd64 (22.2.5-0ubuntu0.1~22.04.1) ...
Setting up libegl-mesa0:amd64 (22.2.5-0ubuntu0.1~22.04.1) ...
Setting up libdrm-dev:amd64 (2.4.113-2~ubuntu0.22.04.1) ...
Setting up libglx-mesa0:amd64 (22.2.5-0ubuntu0.1~22.04.1) ...
Setting up libgstreamer-plugins-base1.0-dev:amd64 (1.20.1-1) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3) ...
                                         
Current status: 211 (-11) upgradable.

于是就完整解决了安装问题。接下来编译也顺利通过了。

 

posted @ 2023-05-25 15:06  水上云天  阅读(426)  评论(0编辑  收藏  举报