apt-get install 与 rpm 混合安装后如何修复?

apt-get install 与 rpm 混合安装后如何修复?

我正在运行 Ubuntu 16.04.1 LTS 桌面,但我按照 rpm 包管理器安装 Oracle Java Runtime 的说明进行操作。

https://docs.oracle.com/javase/8/docs/technotes/guides/install/linux_jre.html#CFHBHAGI

rpm -ivh jre-8uversion-linux-x64.rpm

安装失败,我放弃了。但是现在使用时却sudo apt-get upgrade出现大量错误。

$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
0 to upgrade, 0 to newly install, 0 to remove and 0 not to upgrade.
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 jre1.8.0-101 (1.8.0101-1) ...
Unpacking JAR files...
        plugin.jar...
Error: Could not open input file: /usr/java/jre1.8.0_101/lib/plugin.pack
        javaws.jar...
Error: Could not open input file: /usr/java/jre1.8.0_101/lib/javaws.pack
        deploy.jar...
Error: Could not open input file: /usr/java/jre1.8.0_101/lib/deploy.pack
        rt.jar...
Error: Could not open input file: /usr/java/jre1.8.0_101/lib/rt.pack
        jsse.jar...
Error: Could not open input file: /usr/java/jre1.8.0_101/lib/jsse.pack
        charsets.jar...
Error: Could not open input file: /usr/java/jre1.8.0_101/lib/charsets.pack
        localedata.jar...
Error: Could not open input file: /usr/java/jre1.8.0_101/lib/ext/localedata.pack
/var/lib/dpkg/info/jre1.8.0-101.postinst: line 641: /usr/sbin/alternatives: No such file or directory
dpkg: error processing package jre1.8.0-101 (--configure):
 subprocess installed post-installation script returned error exit status 127
Errors were encountered while processing:
 jre1.8.0-101
E: Sub-process /usr/bin/dpkg returned an error code (1)
$

我该如何撤销此过程并修复 apt-get 系统?任何关于为什么不将 rpm 与 apt-get 混合使用的解释都十分受欢迎。

答案1

尝试运行

   $ sudo apt-get clean
   $ sudo apt-get update
   $ sudo apt-get -y upgrade

运行这些命令后,重新启动系统。如果在更新或升级时遇到错误,请尝试修复 /etc/apt/sources.list 中的 source.list 文件,如下所示:您可以使用这个技巧。打开终端(按 Ctrl+Alt+T )并执行以下操作

> Remove the corrupted one

  $ sudo rm /etc/apt/sources.list

> Open software-properties-gtk

  $ sudo software-properties-gtk

这将打开 software-properties-gtk 并自动创建一个新的 sources.list。

Then change the server to US or to any other server of your choice. You must enable repositories from the new dialog in order to create new sources.list.

答案2

我将回答我自己的问题,因为我发现显然可以解决这个问题。

我创建了一个虚拟/usr/sbin/alternatives文件:

#!/bin/bash
echo "Do nothing"

然后sudo chmod +x /usr/sbin/alternatives

接下来,我/usr/java/使用 将一些内容放入目录中sudo touch /usr/java/something.txt

当我运行时,sudo apt-get purge jre1.8.0-101它完成了,没有错误或警告。此时我重新启动了。重新启动后,我删除了上面的两个文件。

现在我的系统似乎恢复到了安装 rpm 之前的状态。

相关内容