无法使用 apt-get 安装任何东西

无法使用 apt-get 安装任何东西

我浏览了一些帖子,但没有找到解决方案,如果有重复的话,请原谅。

在搞乱了某些软件包的安装(见下文)之后,尝试安装任何东西都会产生以下结果:

$ sudo apt-get install sl Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
 linux-headers-4.2.0-34 linux-headers-4.2.0-34-generic linux-image-4.2.0-34-generic linux-image-extra-4.2.0-34-generic
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
 jdk1.8.0-77
The following NEW packages will be installed:
 sl
0 upgraded, 1 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/26.7 kB of archives.
After this operation, 269 MB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 240329 files and directories currently installed.)
Removing jdk1.8.0-77 (1.8.077-fcs-1) ...
find: `/usr/java/*': No such file or directory
/var/lib/dpkg/info/jdk1.8.0-77.postrm: line 586: /usr/sbin/alternatives: No such file or directory
/var/lib/dpkg/info/jdk1.8.0-77.postrm: line 598: /usr/sbin/alternatives: No such file or directory
dpkg: error processing package jdk1.8.0-77 (--remove):
subprocess installed post-removal script returned error exit status 127
Errors were encountered while processing:
jdk1.8.0-77
E: Sub-process /usr/bin/dpkg returned an error code (1)

什么破坏了一切:我尝试在 Ubuntu Gnome 机器上安装 jdk8。我做了以下操作:

  1. 从以下位置下载相关的 .rpmOracle 的网站,用于alien --scripts将其转换为 .deb,然后使用进行安装dpkg -i。这不起作用(它花了一些时间进行安装,然后抱怨一些安装脚本。不完全确定确切的消息是什么)。
  2. 已关注本指南。当到达该apt-get install部分时,安装最终失败。

我试过了apt-get autoremoveapt-get autoclean,还有dpkg -P jdk1.8.0-77

值得一提的是,在安装完其中一个后,会在与 .rpm 相同的文件夹中创建一个名为 jdk1.8.0-77/ 的文件夹,该文件夹带有锁图标(在文件浏览器中)。我删除了该文件夹,因为我以为我下载了它。

编辑:apt-get install -f收益

$ sudo apt-get install -f
Reading package lists... Done 
Building dependency tree        
Reading state information... Done 
The following packages were automatically installed and are no longer required:
   linux-headers-4.2.0-34 linux-headers-4.2.0-34-generic linux-image-4.2.0-34-generic linux-image-extra-4.2.0-34-generic 
Use 'apt-get autoremove' to remove them. 

The following packages will be REMOVED:
   jdk1.8.0-77 
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. 1 not fully installed or removed. After this operation, 269 MB disk space will be freed. Do you want to continue? [Y/n] Y 
(Reading database ... 240329 files and directories currently installed.) 
Removing jdk1.8.0-77 (1.8.077-fcs-1) ... 
find: `/usr/java/*': No such file or directory 
/var/lib/dpkg/info/jdk1.8.0-77.postrm: line 586: /usr/sbin/alternatives: No such file or directory /var/lib/dpkg/info/jdk1.8.0-77.postrm: line 598: /usr/sbin/alternatives: No such file or directory 
dpkg: error processing package jdk1.8.0-77 (--remove):  
subprocess installed post-removal script returned error exit status 127 Errors were encountered while processing:  jdk1.8.0-77

编辑2:帖子似乎非常相关。我尝试按照那里给出的建议操作(touch/usr/sbin/alternatives脚本现在在调用时失败find

编辑 3:重新启动(以及伪随机组合apt-get autoremovedpkg -P加上对脚本的一些干预似乎已经解决了这个问题。

相关内容