摆脱 ubuntu 上半安装的 Java 安装

摆脱 ubuntu 上半安装的 Java 安装

我通过从 java.com (1.8.0-71) 下载 RPM 文件来安装 java,并使用 alien 生成一个 .deb 文件并安装。安装失败,我无法再删除它。

如果我尝试使用 apt-get ,我总是会收到一条提示,提示我应该重新安装该软件包(如果那么容易的话):

faustdonner@v22015113109829193:~$ sudo dpkg -i jre1.8.0-71_1.8.071-1_amd64.deb
Previously not selected package jre1.8.0-71 is selected.
(Reading database ... 84902 files and directories currently installed.)
Preparation for unpacking jre1.8.0-71_1.8.071-1_amd64.deb ...
Unpacking jre1.8.0-71 (1.8.071-1) through (1.8.071-1) ...
/var/lib/dpkg/info/jre1.8.0-71.postrm: Line 586: /usr/sbin/alternatives:  
 File or directory not found  
dpkg: warning: subprocess old post-removal script returned error exit status 127
dpkg: instead script is trying the new package ...
find: "/usr/java/*": File or directory not found
/var/lib/dpkg/tmp.ci/postrm: Line 586: /usr/sbin/alternatives:
 File or directory not found   
dpkg: error processing the archive jre1.8.0-71_1.8.071-1_amd64.deb (--install):
Subprocess new post-removal script returned error exit status 127
/var/lib/dpkg/tmp.ci/postrm: Line 586: /usr/sbin/alternatives:  
 File or directory not found  
dpkg: error while cleaning up:
 Subprocess new post-removal script returned error exit status 127
Errors were encountered while processing:
 jre1.8.0-71_1.8.071-1_amd64.deb

当我尝试强制清除时:

faustdonner@v22015113109829193:~$ sudo dpkg --force-all --purge jre1.8.0-71  
dpkg: warning: Problem is skipped because --force is specified:
dpkg: warning: Package is in a very bad inconsistent state; you should
reinstall it before attempting to remove it.
(Reading database ... 84902 files and directories currently installed.)
Removing jre1.8.0-71 (1.8.071-1) ...
/var/lib/dpkg/info/jre1.8.0-71.postrm: Line 586: /usr/sbin/alternatives:  
 File or directory not found  
dpkg: error processing the packet jre1.8.0-71 (--purge):
 Subprocess installed post-removal script returned error exit status 127
Errors were encountered while processing:
 jre1.8.0-71_1.8.071-1_amd64.deb

第二行表示它处于非常糟糕的不一致状态。它尝试访问尚未创建的文件夹,因此我尝试的所有方法都失败了。我是否可以删除 dpkg 中的安装条目,这样就好像我从未安装过它一样?如果它非常干净,我不再关心,我只想能够再次使用 apt-get。

答案1

需要重新安装
标记为 reinst-required 的软件包已损坏,需要重新安装。除非使用选项 强制删除,否则无法删除这些软件包--force-remove-reinstreq

打开终端并输入:

sudo dpkg --remove --force-remove-reinstreq jre1.8.0-71  
sudo apt 安装 openjdk-7-jre# 从默认的 Ubuntu 存储库安装 jre

相关内容