包管理工具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.

於是就完整解決了安裝問題。接下來編譯也順利通過了。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章