依赖问题:gcc-4.9-base 被保留

依赖问题:gcc-4.9-base 被保留

由于软件包损坏,我无法升级系统。几个月来我一直无法解决这个问题,坦率地说,我正准备完全重新安装 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 时过于急切,而此时仍使用 precise,结果却陷入了这种奇怪的混乱状态。回想起来,这可能是一个坏主意。我曾尝试通过 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),所以不是重新启动,直到你重新安装这两个软件包,并下载它们,如果需要它们的依赖项,请从packages.ubuntu.com并使用 进行安装dpkg -i <packacge-name>。仅在万不得已的情况下才使用此选项。

相关内容