web-dev-qa-db-ja.com

17.04へのアップグレード後にbuild-essential / gcc / g ++をインストールできません

Ubuntu 16.04から17.04にアップグレードしてから、 http://ppa.launchpad.net/ubuntu-toolchain-r/testからgcc-7またはg++-7をインストールできなくなりました/ ubuntu リポジトリ。実際、build-essentialをインストールすることさえできません。

Software&Updates>Other Softwareでは、リポジトリは次のようにリストされます:

http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu zesty main

build-essentialをインストールしようとしています:

$ Sudo apt install build-essential
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:
 build-essential : Depends: gcc (>= 4:5.2) but it is not going to be installed
                   Depends: g++ (>= 4:5.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

しかしながら:

$ gcc --version
gcc (Ubuntu 5.4.1-8ubuntu1) 5.4.1 20170304
...
$ g++ --version
g++ (Ubuntu 5.4.1-8ubuntu1) 5.4.1 20170304
...

では、どのようにしてbuild-essentialを再度インストールできますか?

7
kleinfreund

そのため、次の手順に従ってbuild-essentialを再度インストールできました。

$ Sudo apt install build-essential
...
The following packages have unmet dependencies:
 build-essential : Depends: gcc (>= 4:5.2) but it is not going to be installed
                   Depends: g++ (>= 4:5.2) but it is not going to be installed

5.2以上のgccバージョンが必要なので、gccをインストールしてみてください。

$ Sudo apt install gcc
...
The following packages have unmet dependencies:
gcc : Depends: cpp (>= 4:6.3.0-2ubuntu1) but it is not going to be installed
      Depends: gcc-6 (>= 6.3.0-9~) but it is not going to be installed

はい。他の何かが欠落しています。それをインストールしてみましょう。

$ Sudo apt install cpp
...
The following packages have unmet dependencies:
 cpp : Depends: cpp-6 (>= 6.3.0-9~) but it is not going to be installed

まだ何もありません。再試行します。

$ Sudo apt install cpp-6
...
The following packages have unmet dependencies:
 cpp-6 : Depends: gcc-6-base (= 6.3.0-12ubuntu2) but 6.3.0-18ubuntu2~16.04 is to be installed

もう一度。

$ Sudo apt install gcc-6-base
...
gcc-6-base is already the newest version (6.3.0-18ubuntu2~16.04).

ですから、ここで何が間違っていたのかわかりません。バージョン番号の末尾に16.04文字列があることに注意してください。それは奇妙に思えた。そのパッケージを削除しました。

$ Sudo apt remove gcc-6-base

これで、build-essentialを再度インストールできました。これにより、gcc-6-baseも再インストールされます。

$ Sudo apt install build-essential

残りの問題:

$ Sudo apt upgrade
...
The following packages have been kept back:
  cpp g++ gcc

問題の根本は上記と同様で、gcc-7-baseに欠陥がありますが、これを取得するため、単純に削除することはできません。

The following packages have unmet dependencies:
 libgcc1 : Depends: gcc-7-base (= 7.1.0-5ubuntu2~16.04) but it is not going to be installed
 va-driver-all : Depends: mesa-va-drivers but it is not going to be installed or
                          vdpau-va-driver but it is not going to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

危険ゾーン

私は次の手順でこの問題を解決できました。

$ Sudo apt install aptitude
$ Sudo dpkg --force-all -P gcc-7-base
$ Sudo dpkg --force-all -P gcc-7-base:i386
$ Sudo aptitude install gcc-7-base

これは非常に危険であり、インストールを中断する可能性があります。 dpkg --force-all -Pを実行すると、パッケージが強制的に削除され、このパッケージへの依存関係は無視されます。これに続いて通常のapt upgradeを実行すると、インストールから関連するほとんどすべてのソフトウェアが削除される場合があります。

私が持っていたすべての依存関係の問題を解決したaptitudeを使用して、そこから回復することができました。

5
kleinfreund