无法使用 apt 安装任何东西

无法使用 apt 安装任何东西

出于兼容性原因,我尝试安装早期的 gcc 和 g++ (4.6.3),但现在 apt 似乎已损坏。似乎 apt-get install 对所有东西都如此,而不仅仅是 dpkg:

>> sudo apt-get install dpkg 
Reading package lists..
Done 
Building dependency tree
Reading state information... 
Done 
dpkg is already the newest version. 0 upgraded, 0 newly installed, 0 to   
remove and 0 not upgraded. 1 not fully installed or removed. After this
operation, 0 B of additional disk space will be used. Do you want to
continue? [Y/n]

选择“Y”总是会导致以下结果:

Setting up gcc (4:4.8.2-1ubuntu6) ...
update-alternatives: error: alternative path /usr/bin/gcc doesn't exist
dpkg: error processing package gcc (--configure):
subprocess installed post-installation script returned error exit status 2
E: Sub-process /usr/bin/dpkg returned an error code (1)

我在尝试安装 gcc 4.6.3 时确实运行了配置脚本,并且我可能为 --target 选项给出了错误的值。我尝试了以下各种组合但没有成功:

apt-get update && apt-get upgrade
apt-get install -f
sudo dpkg --configure -a
apt-get remove/purge/autoremove gcc

此外,Synaptic 声称没有损坏的包装。

感谢您的建议。

编辑:回应评论

>> sudo apt-get purge gcc
[sudo] password for user: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  gcc*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 42.0 kB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 278757 files and directories currently installed.)
Removing gcc (4:4.8.2-1ubuntu6) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...

>> sudo dpkg -C
The following packages are only half configured, probably due to problems
configuring them the first time.  The configuration should be retried using
dpkg --configure <package> or the configure menu option in dselect:
 gcc                  GNU C compiler

尝试删除其中任何一个都会失败,并抱怨依赖项:

>> sudo dpkg --get-selections | grep gcc
gcc                     install
gcc-4.6                     install
gcc-4.6-base:amd64              install
gcc-4.8                     install
gcc-4.8-base:amd64              install
gcc-4.9-base:amd64              install
libgcc-4.8-dev:amd64                install
libgcc1:amd64                   install

>> sudo dpkg --configure -a
Setting up gcc (4:4.8.2-1ubuntu6) ...
update-alternatives: error: alternative path /usr/bin/gcc doesn't exist
dpkg: error processing package gcc (--configure):
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
 gcc

>> sudo dpkg -P gcc-4.9-base gcc-4.8-base gcc-4.8 1> command.out
dpkg: dependency problems prevent removal of gcc-4.9-base:amd64:
 libgcc1:amd64 depends on gcc-4.9-base (= 4.9.1-0ubuntu1).

dpkg: error processing package gcc-4.9-base:amd64 (--purge):
 dependency problems - not removing
dpkg: dependency problems prevent removal of gcc-4.8-base:amd64:
 libitm1:amd64 depends on gcc-4.8-base (= 4.8.2-19ubuntu1).
 libgomp1:amd64 depends on gcc-4.8-base (= 4.8.2-19ubuntu1).
 libstdc++6:amd64 depends on gcc-4.8-base (= 4.8.2-19ubuntu1).
 libgfortran3:amd64 depends on gcc-4.8-base (= 4.8.2-19ubuntu1).
 libasan0:amd64 depends on gcc-4.8-base (= 4.8.2-19ubuntu1).
 libgcc-4.8-dev:amd64 depends on gcc-4.8-base (= 4.8.2-19ubuntu1).
 libtsan0:amd64 depends on gcc-4.8-base (= 4.8.2-19ubuntu1).
 libquadmath0:amd64 depends on gcc-4.8-base (= 4.8.2-19ubuntu1).
 libstdc++-4.8-dev:amd64 depends on gcc-4.8-base (= 4.8.2-19ubuntu1).
 cpp-4.8 depends on gcc-4.8-base (= 4.8.2-19ubuntu1).
 libatomic1:amd64 depends on gcc-4.8-base (= 4.8.2-19ubuntu1).

dpkg: error processing package gcc-4.8-base:amd64 (--purge):
 dependency problems - not removing
dpkg: warning: ignoring request to remove gcc-4.8 which isn't installed
Errors were encountered while processing:
 gcc-4.9-base:amd64
 gcc-4.8-base:amd64

>> sudo dpkg -P gcc-4.6 gcc-4.6-base
dpkg: dependency problems prevent removal of gcc-4.6:
 g++-4.6 depends on gcc-4.6 (= 4.6.4-6ubuntu2).

dpkg: error processing package gcc-4.6 (--purge):
 dependency problems - not removing
dpkg: dependency problems prevent removal of gcc-4.6-base:amd64:
 gcc-4.6 depends on gcc-4.6-base (= 4.6.4-6ubuntu2).
 libstdc++6-4.6-dev depends on gcc-4.6-base (= 4.6.4-6ubuntu2).
 g++-4.6 depends on gcc-4.6-base (= 4.6.4-6ubuntu2).
 cpp-4.6 depends on gcc-4.6-base (= 4.6.4-6ubuntu2).

dpkg: error processing package gcc-4.6-base:amd64 (--purge):
 dependency problems - not removing
Errors were encountered while processing:
 gcc-4.6
 gcc-4.6-base:amd64

相关内容