
由於軟體包損壞,我無法升級系統。幾個月來我一直無法解決這個問題,坦白說,我即將完全重新安裝 ubuntu。這篇文章代表了我找到解決方案的最後希望。這是我嘗試過的:
版本資訊
$ uname -a && gcc --version
Linux prometheus 3.13.0-87-generic #132-Ubuntu SMP Mon May 16 20:51:42 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
...
來源清單
$ grep -v "^#" /etc/apt/sources.list /ect/apt/sources.list.d/*
deb http://za.archive.ubuntu.com/ubuntu/ trusty main universe multiverse
deb-src http://za.archive.ubuntu.com/ubuntu/ trusty main universe multiverse #Added by software-properties
deb http://za.archive.ubuntu.com/ubuntu/ trusty-updates main universe multiverse
deb-src http://za.archive.ubuntu.com/ubuntu/ trusty-updates main universe multiverse #Added by software-properties
deb http://za.archive.ubuntu.com/ubuntu/ trusty-security main universe multiverse
deb-src http://za.archive.ubuntu.com/ubuntu/ trusty-security main universe multiverse #Added by software-properties
deb http://za.archive.ubuntu.com/ubuntu/ trusty-backports main universe multiverse
deb-src http://za.archive.ubuntu.com/ubuntu/ trusty-backports main universe multiverse #Added by software-properties
deb http://archive.canonical.com/ trusty partner
deb-src http://archive.canonical.com/ trusty partner
deb-src http://archive.canonical.com/ubuntu trusty partner
apt-get 東西
$ sudo apt-get update
...
那裡沒有問題...
$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
gcc-4.9-base libgcc1
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
所以看起來我最終以某種方式得到了多個版本的 gcc !由套件管理器維護的版本是較新的版本。
查看版本表發現
$ apt-cache policy gcc-4.9-base libgcc1
gcc-4.9-base:
Installed: 4.9.2-0ubuntu1~12.04
Candidate: 4.9.3-0ubuntu4
Version table:
4.9.3-0ubuntu4 0
500 http://za.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
*** 4.9.2-0ubuntu1~12.04 0
100 /var/lib/dpkg/status
4.9-20140406-0ubuntu1 0
500 http://za.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
libgcc1:
Installed: 1:4.9.2-0ubuntu1~12.04
Candidate: 1:4.9.3-0ubuntu4
Version table:
1:4.9.3-0ubuntu4 0
500 http://za.archive.ubuntu.com/ubuntu/ trusty-updates/main amd64 Packages
*** 1:4.9.2-0ubuntu1~12.04 0
100 /var/lib/dpkg/status
1:4.9-20140406-0ubuntu1 0
500 http://za.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
看起來我在安裝 gcc 4.9 時似乎過於急切,同時仍然處於精確狀態,現在卻陷入了這種奇怪的混亂狀態。回想起來,這可能是個壞主意。我嘗試過透過 synaptic 升級 gcc,但它不可避免地要刪除一長串軟體包(包括 apt),這似乎非常不可取。
所以我的問題是:是否有希望恢復系統並解決依賴性問題?
更新
$ sudo apt-get install --reinstall gcc-4.9-base libgcc1
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:
gvfs : Depends: gvfs-daemons (>= 1.20.3-0ubuntu1.2)
Depends: gvfs-daemons (< 1.20.3-0ubuntu1.2.1~)
indicator-network : Depends: unity8 (>= 7.82) but it is not going to be installed
libegl1-mesa : Depends: libgbm1 (>= 7.11~1) but it is not going to be installed
Recommends: libegl1-mesa-drivers
libgl1-mesa-glx : Depends: libglapi-mesa (= 10.1.3-0ubuntu0.6)
Recommends: libgl1-mesa-dri (>= 7.2)
libqt5gui5 : Depends: libgbm1 (>= 8.1~0) but it is not going to be installed
libstdc++6 : Depends: gcc-4.9-base (= 4.9.2-0ubuntu1~12.04) but 4.9.3-0ubuntu4 is to be installed
libubuntu-application-api-mirserver1 : Depends: libmirserver18 (>= 0.1.8+14.04.20140408.1) but it is not going to be installed
libunity-mir1 : Depends: libmirserver18 (>= 0.1.8+14.04.20140411) but it is not going to be installed
unity-scope-mediascanner2 : Depends: mediascanner2.0 but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
我也嘗試過此修復,但無濟於事:
sudo apt-get -o Debug::pkgProblemResolver=yes dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Starting pkgProblemResolver with broken count: 7
Starting 2 pkgProblemResolver with broken count: 7
Investigating (0) libstdc++6 [ amd64 ] < 4.9.2-0ubuntu1~12.04 > ( libs )
Broken libstdc++6:amd64 Depends on gcc-4.9-base [ amd64 ] < 4.9.2-0ubuntu1~12.04 -> 4.9.3-0ubuntu4 > ( libs ) (= 4.9.2-0ubuntu1~12.04)
Considering gcc-4.9-base:amd64 17 as a solution to libstdc++6:amd64 525
Added gcc-4.9-base:amd64 to the remove list
Fixing libstdc++6:amd64 via keep of gcc-4.9-base:amd64
Investigating (0) libgcc1 [ amd64 ] < 1:4.9.2-0ubuntu1~12.04 -> 1:4.9.3-0ubuntu4 > ( libs )
Broken libgcc1:amd64 Depends on gcc-4.9-base [ amd64 ] < 4.9.2-0ubuntu1~12.04 -> 4.9.3-0ubuntu4 > ( libs ) (= 4.9.3-0ubuntu4)
Considering gcc-4.9-base:amd64 17 as a solution to libgcc1:amd64 463
Holding Back libgcc1:amd64 rather than change gcc-4.9-base:amd64
Try to Re-Instate (0) gcc-4.9-base:amd64
Try to Re-Instate (1) libgcc1:amd64
Done
Done
Starting pkgProblemResolver with broken count: 0
Starting 2 pkgProblemResolver with broken count: 0
Done
The following packages have been kept back:
gcc-4.9-base libgcc1
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
在嘗試強制重新安裝之前,我可能會嘗試回滾到 gcc-4.8,然後再次嘗試升級...
答案1
好吧,命令清單很可能解決這個問題,提醒一下,發布的選項變得更加激進,所以最好從解決方案嘗試 #1 開始。
1. 軟體包進行軟體重新安裝:
sudo apt-get install --reinstall gcc-4.9-base libgcc1
2. 強制安裝損壞的軟體包:
sudo apt-get -f install
3. 刪除dpkg
並重新安裝apt-get
:
sudo dpkg -r --force gcc-4.9-base
sudo dpkg -r --force libgcc1
sudo apt-get install gcc-4.9-base libgcc1
筆記:這可能並且可能會破壞您的系統(例如apt
),所以這樣做不是重新啟動,直到您透過下載它們重新安裝了這兩個軟體包,如果需要,也可以從以下位置下載它們的依賴項軟體包.ubuntu.com並使用dpkg -i <packacge-name>
.僅將此選項用作最後的手段。