我最近将服务器从 Ubuntu 12.04 升级到了 14.10。升级之前我已经安装了 GCC 4.9(显然是 4.9.2),今天我想安装 gcc-4.9-multilib,但是 apt-get 给了我:
gcc-4.9-multilib : Depends: gcc-4.9 (= 4.9.1-16ubuntu6) but 4.9.2-0ubuntu1~12.04 is to be installed
因此我删除了 gcc-4.9 并想重新安装它,但 gcc-4.9-base 也出现了同样的情况:
gcc-4.9 : Depends: cpp-4.9 (= 4.9.1-16ubuntu6) but 4.9.2-0ubuntu1~12.04 is to be installed
Depends: gcc-4.9-base (= 4.9.1-16ubuntu6) but 4.9.2-0ubuntu1~12.04 is to be installed
我可以删除 cpp-4.9,但我猜删除 gcc-4.9-base 不会留下太多内核……
[太长,点击粘贴]
我也尝试aptitude
删除 4.9.2-0ubuntu1~12.04 并安装 4.9.1-16ubuntu6,但是当我尝试应用所选的更改时,它给了我:
Some packages were broken and have been fixed:
Keep the following packages at their current version:
gcc-4.9-base [4.9.2-0ubuntu1~12.04 (now)]
那么,我怎样才能在不删除整个操作系统的情况下删除 12.04 的内容呢?
编辑:
我的消息来源:
bash$ cat /etc/apt/sources.list /etc/apt/sources.list.d/*.list
deb http://archive.ubuntu.com/ubuntu utopic main
deb http://archive.ubuntu.com/ubuntu utopic-updates main
deb http://security.ubuntu.com/ubuntu utopic-security main universe restricted
deb http://archive.ubuntu.com/ubuntu utopic universe restricted
deb http://archive.ubuntu.com/ubuntu utopic-updates universe restricted
deb http://pkg.jenkins-ci.org/debian binary/
# deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu utopic main
# deb-src http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu utopic main
尝试修复任何损坏的东西:
bash$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
政策信息:
bash$ apt-cache policy gcc-4.9
gcc-4.9:
Installed: (none)
Candidate: 4.9.1-16ubuntu6
Version table:
4.9.1-16ubuntu6 0
500 http://archive.ubuntu.com/ubuntu/ utopic/main amd64 Packages
尝试安装 gcc-4.9:
bash$ sudo apt-get install gcc-4.9
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:
gcc-4.9 : Depends: cpp-4.9 (= 4.9.1-16ubuntu6) but it is not going to be installed
Depends: gcc-4.9-base (= 4.9.1-16ubuntu6) but 4.9.2-0ubuntu1~12.04 is to be installed
E: Unable to correct problems, you have held broken packages.
尝试安装 gcc-4.9-base=4.9.1-16ubuntu6:
[太长,点击粘贴]
尝试升级 Ubuntu:
bash$ sudo do-release-upgrade
Checking for a new Ubuntu release
No new release found
我没有使用 LTS:
bash$ cat /etc/update-manager/release-upgrades
# Default behavior for the release upgrader.
[DEFAULT]
# Default prompting behavior, valid options:
#
# never - Never check for a new release.
# normal - Check to see if a new release is available. If more than one new
# release is found, the release upgrader will attempt to upgrade to
# the release that immediately succeeds the currently-running
# release.
# lts - Check to see if a new LTS release is available. The upgrader
# will attempt to upgrade to the first LTS release available after
# the currently-running one. Note that this option should not be
# used if the currently-running release is not itself an LTS
# release, since in that case the upgrader won't be able to
# determine if a newer release is available.
Prompt=normal
更新:
bash$ sudo apt-get update
Ign http://archive.ubuntu.com utopic InRelease
Ign http://security.ubuntu.com utopic-security InRelease
Ign http://archive.ubuntu.com utopic-updates InRelease
Get:1 http://security.ubuntu.com utopic-security Release.gpg [933 B]
Hit http://archive.ubuntu.com utopic Release.gpg
Get:2 http://security.ubuntu.com utopic-security Release [62.0 kB]
Get:3 http://archive.ubuntu.com utopic-updates Release.gpg [933 B]
Ign http://pkg.jenkins-ci.org binary/ InRelease
Hit http://archive.ubuntu.com utopic Release
Get:4 http://archive.ubuntu.com utopic-updates Release [62.0 kB]
Get:5 http://security.ubuntu.com utopic-security/main amd64 Packages [110 kB]
Hit http://pkg.jenkins-ci.org binary/ Release.gpg
Get:6 http://security.ubuntu.com utopic-security/universe amd64 Packages [46.6 kB]
Hit http://pkg.jenkins-ci.org binary/ Release
Get:7 http://security.ubuntu.com utopic-security/restricted amd64 Packages [8,496 B]
Hit http://archive.ubuntu.com utopic/main amd64 Packages
Get:8 http://security.ubuntu.com utopic-security/main i386 Packages [109 kB]
Hit http://pkg.jenkins-ci.org binary/ Packages
Hit http://archive.ubuntu.com utopic/universe amd64 Packages
Get:9 http://security.ubuntu.com utopic-security/universe i386 Packages [46.5 kB]
Hit http://archive.ubuntu.com utopic/restricted amd64 Packages
Get:10 http://security.ubuntu.com utopic-security/restricted i386 Packages [8,438 B]
Hit http://archive.ubuntu.com utopic/main i386 Packages
Get:11 http://security.ubuntu.com utopic-security/main Translation-en [52.8 kB]
Hit http://archive.ubuntu.com utopic/universe i386 Packages
Hit http://security.ubuntu.com utopic-security/restricted Translation-en
Hit http://archive.ubuntu.com utopic/restricted i386 Packages
Hit http://archive.ubuntu.com utopic/main Translation-en
Get:12 http://security.ubuntu.com utopic-security/universe Translation-en [25.7 kB]
Hit http://archive.ubuntu.com utopic/main Translation-en_GB
Hit http://archive.ubuntu.com utopic/restricted Translation-en
Hit http://archive.ubuntu.com utopic/restricted Translation-en_GB
Hit http://archive.ubuntu.com utopic/universe Translation-en
Hit http://archive.ubuntu.com utopic/universe Translation-en_GB
Get:13 http://archive.ubuntu.com utopic-updates/main amd64 Packages [162 kB]
Get:14 http://archive.ubuntu.com utopic-updates/universe amd64 Packages [63.3 kB]
Get:15 http://archive.ubuntu.com utopic-updates/restricted amd64 Packages [8,496 B]
Get:16 http://archive.ubuntu.com utopic-updates/main i386 Packages [160 kB]
Ign http://pkg.jenkins-ci.org binary/ Translation-en_US
Ign http://pkg.jenkins-ci.org binary/ Translation-en
Get:17 http://archive.ubuntu.com utopic-updates/universe i386 Packages [63.2 kB]
Ign http://pkg.jenkins-ci.org binary/ Translation-en_GB
Get:18 http://archive.ubuntu.com utopic-updates/restricted i386 Packages [8,438 B]
Get:19 http://archive.ubuntu.com utopic-updates/main Translation-en [74.2 kB]
Hit http://archive.ubuntu.com utopic-updates/restricted Translation-en
Get:20 http://archive.ubuntu.com utopic-updates/universe Translation-en [35.2 kB]
Fetched 1,108 kB in 5s (216 kB/s)
Reading package lists... Done
升级:
bash$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
分布式升级:
bash$ sudo apt-get dist-upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
我偶然发现了一些事情:
bash$ apt list -a gcc-4.9-base
Listing... Done
gcc-4.9-base/now 4.9.2-0ubuntu1~12.04 amd64 [installed,local]
gcc-4.9-base/utopic 4.9.1-16ubuntu6 amd64
答案1
我也遇到了同样的问题。我尝试降级所有 gcc 软件包,但没有成功,因为 apt-get 找不到正确版本的 libgcc1,尽管 apt-cache 告诉我它知道:
$ sudo apt-get install libgcc1=4.9.1-16ubuntu6
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Version '4.9.1-16ubuntu6' for 'libgcc1' was not found
我从网站手动下载libgcc1_4.9.1-16ubuntu6_i386.deb
并 /var/cache/apt/archives/libgcc1_4.9.1-16ubuntu6_amd64.deb
能够使用以下命令降级:
sudo aptitude install gcc-4.9-base=4.9.1-16ubuntu6 gcc-4.9=4.9.1-16ubuntu6 \
libasan1=4.9.1-16ubuntu6 libquadmath0=4.9.1-16ubuntu6 lib32gcc1=4.9.1-16ubuntu6 \
lib32stdc++6=4.9.1-16ubuntu6 libubsan0=4.9.1-16ubuntu6 cpp-4.9=4.9.1-16ubuntu6 \
libgomp1=4.9.1-16ubuntu6 libtsan0=4.9.1-16ubuntu6 libx32asan1=4.9.1-16ubuntu6 \
libcilkrts5=4.9.1-16ubuntu6 lib32ubsan0=4.9.1-16ubuntu6 libx32itm1=4.9.1-16ubuntu6 \
libx32gcc-4.9-dev=4.9.1-16ubuntu6 libgcc1=4.9.1-16ubuntu6 \
lib32gcc-4.9-dev=4.9.1-16ubuntu6 libx32gomp1=4.9.1-16ubuntu6 \
libx32atomic1=4.9.1-16ubuntu6 libobjc4=4.9.1-16ubuntu6 \
libx32cilkrts5=4.9.1-16ubuntu6 libatomic1=4.9.1-16ubuntu6 \
lib32asan1=4.9.1-16ubuntu6 gcc-4.9-multilib=4.9.1-16ubuntu6 \
lib32cilkrts5=4.9.1-16ubuntu6 gcc-4.9=4.9.1-16ubuntu6 \
libx32quadmath0=4.9.1-16ubuntu6 lib32gomp1=4.9.1-16ubuntu6 \
lib32atomic1=4.9.1-16ubuntu6 lib32itm1=4.9.1-16ubuntu6 \
libx32gcc1=4.9.1-16ubuntu6 libgfortran3=4.9.1-16ubuntu6 \
libgcc-4.9-dev=4.9.1-16ubuntu6 liblsan0=4.9.1-16ubuntu6 \
libstdc++6=4.9.1-16ubuntu6 lib32quadmath0=4.9.1-16ubuntu6 \
libitm1=4.9.1-16ubuntu6 gcc-4.9-base=4.9.1-16ubuntu6 \
gcc-4.9-base:i386=4.9.1-16ubuntu6 libx32ubsan0=4.9.1-16ubuntu6 \
libstdc++6:i386=4.9.1-16ubuntu6 \
/path/to/libgcc1_4.9.1-16ubuntu6_amd64.deb \
/path/to/libgcc1_4.9.1-16ubuntu6_i386.deb
您可能需要更少的条目 - 如果 apt 告诉您它将安装“新”软件包,而不是降级现有的软件包,您可能能够删除那些软件包。