1. 程式人生 > >【工具使用】Linux日常使用之軟體安裝失敗的處理方式

【工具使用】Linux日常使用之軟體安裝失敗的處理方式

從古董系統Ubuntu12.04一路升級到較新的16.04,發現有些軟體,如samba,不能用了。用一般的處理方式如apt -f install也沒辦法處理。一直放著,今天還是覺得samba有一些方便,便花了一點時間去看這個問題。

錯誤詳情

➜ ~ sudo apt install samba

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:
samba : Depends: python-samba but it is not going to be installed
Depends: samba-common (= 2:4.3.8+dfsg-0ubuntu1) but 2:4.3.11+dfsg-0ubuntu0.14.04.11 is to be installed
Depends: samba-common-bin (= 2:4.3.8+dfsg-0ubuntu1) but it is not going to be installed
Depends: libwbclient0 (= 2:4.3.8+dfsg-0ubuntu1) but 2:4.3.11+dfsg-0ubuntu0.14.04.11 is to be installed
Depends: samba-libs (= 2:4.3.8+dfsg-0ubuntu1) but it is not going to be installed
Recommends: attr
Recommends: samba-dsdb-modules but it is not going to be installed
Recommends: samba-vfs-modules but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

原因

我覺得大致如下:
提示是packages have unmet dependencies,再仔細看一下下面的描述,這種問題其實就是軟體所依賴的包的版本不對,基本一可以通過sudo apt -f install解決,但是該包被以為是最新的,無法被替換掉。

解決辦法

先把這些依賴包全部解除安裝掉,然後再安裝回來。

過程如下:

➜ ~ sudo apt install python-samba

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:
python-samba : Depends: samba-libs (= 2:4.3.8+dfsg-0ubuntu1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

➜ ~ sudo apt install samba-libs

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:
samba-libs : Depends: libwbclient0 (= 2:4.3.8+dfsg-0ubuntu1) but 2:4.3.11+dfsg-0ubuntu0.14.04.11 is to be installed
E: Unable to correct problems, you have held broken packages.

➜ ~ sudo apt install libwbclient0

Reading package lists… Done
Building dependency tree
Reading state information… Done
libwbclient0 is already the newest version (2:4.3.11+dfsg-0ubuntu0.14.04.11).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

➜ ~ sudo apt remove libwbclient0:amd64

Reading package lists… Done
Building dependency tree
Reading state information… Done
The following packages will be REMOVED:
libwbclient0
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
After this operation, 209 kB disk space will be freed.
Do you want to continue? [Y/n]
(Reading database … 318410 files and directories currently installed.)
Removing libwbclient0:amd64 (2:4.3.11+dfsg-0ubuntu0.14.04.11) …
Processing triggers for libc-bin (2.23-0ubuntu3) …

➜ ~ sudo apt install libwbclient0

Reading package lists… Done
Building dependency tree
Reading state information… Done
The following NEW packages will be installed:
libwbclient0
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 30.4 kB of archives.
After this operation, 186 kB of additional disk space will be used.
Get:1 http://mirrors.aliyun.com/ubuntu xenial/main amd64 libwbclient0 amd64 2:4.3.8+dfsg-0ubuntu1 [30.4 kB]
Fetched 30.4 kB in 0s (146 kB/s)
Selecting previously unselected package libwbclient0:amd64.
(Reading database … 318404 files and directories currently installed.)
Preparing to unpack …/libwbclient0_2%3a4.3.8+dfsg-0ubuntu1_amd64.deb …
Unpacking libwbclient0:amd64 (2:4.3.8+dfsg-0ubuntu1) …
Processing triggers for libc-bin (2.23-0ubuntu3) …
Setting up libwbclient0:amd64 (2:4.3.8+dfsg-0ubuntu1) …
Processing triggers for libc-bin (2.23-0ubuntu3) …

➜ ~ sudo apt install libwbclient0

Reading package lists… Done
Building dependency tree
Reading state information… Done
libwbclient0 is already the newest version (2:4.3.8+dfsg-0ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

其它的依賴包按照此方法去一一操作,操作完成了之後便可以安裝好之前想安裝的軟體了。