安装虚拟依赖的正确方法

安装虚拟依赖的正确方法

我正在创建.deb基于 Java 的应用程序包(请参阅这个超级用户问题)。我现在使用以下依赖项信息:

Depends: java-runtime-headless (>= 1.6)
Recommends: openjdk-7-jre-headless, ...

现在我正在尝试安装它:

$ sudo dpkg -i MYAPP.deb 
Selecting previously unselected package MYAPP.
(Reading database ... 140874 files and directories currently installed.)
Unpacking MYAPP (from MYAPP.deb) ...
dpkg: dependency problems prevent configuration of MYAPP:
 MYAPP depends on java-runtime-headless (>= 1.6); however:
  Package java-runtime-headless is not installed.
dpkg: error processing MYAPP (--install):
 dependency problems - leaving unconfigured
Processing triggers for desktop-file-utils ...
Processing triggers for bamfdaemon ...
Rebuilding /usr/share/applications/bamf.index...
Processing triggers for gnome-menus ...
Errors were encountered while processing:
 MYAPP
$

好的,我正在尝试安装依赖项:

$ sudo apt-get install java-runtime-headless
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package java-runtime-headless is a virtual package provided by:
  openjdk-7-jre-headless 7u25-2.3.10-1ubuntu0.12.04.2
  openjdk-6-jre-headless 6b27-1.12.6-1ubuntu0.12.04.2
  gcj-jre-headless 4:4.6.3-1ubuntu5
  gcj-4.6-jre-headless 4.6.3-1ubuntu2
  default-jre-headless 1:1.6-43ubuntu2
You should explicitly select one to install.

E: Package 'java-runtime-headless' has no installation candidate

好的,我选择了其中一个包:

$ sudo apt-get install openjdk-7-jre-headless
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 openjdk-7-jre-headless : Depends: openjdk-7-jre-lib (= 7u25-2.3.10-1ubuntu0.12.04.2) but it is not going to be installed
                          Depends: ca-certificates-java but it is not going to be installed
                          Depends: tzdata-java (>= 2012e-0ubuntu0.12.04.1) but it is not going to be installed
                          Depends: java-common (>= 0.28) but it is not going to be installed
                          Depends: libnss3-1d (>= 3.12.9+ckbi-1.82-0ubuntu4) but it is not going to be installed
                          Recommends: icedtea-7-jre-jamvm (= 7u25-2.3.10-1ubuntu0.12.04.2) but it is not going to be installed
 MYAPP : Depends: java-runtime-headless (>= 1.6)
         Recommends: mercurial but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

现在它只建议我删除我的应用程序:

$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages will be REMOVED:
  MYAPP
0 upgraded, 0 newly installed, 1 to remove and 3 not upgraded.
1 not fully installed or removed.
After this operation, 41.0 MB disk space will be freed.
Do you want to continue [Y/n]? n
Abort.
$ 

看起来我第一的需要安装依赖项(openjdk-7-jre-headless),然后安装我的应用程序。普通用户应该如何理解?或者有更好的安装方法吗MYAPP.deb

答案1

我会从你的“java-runtime-headless”依赖项中删除该版本。

虚拟包存在一些令人不安的限制,其中最主要的是没有版本号。

http://debian-handbook.info/browse/stable/sect.package-meta-information.html

如果您想要指定一组真实包中的哪一个应该作为默认包来满足对虚拟包的特定依赖关系,则应该将真实包列为虚拟包之前的替代方案。

http://sdn.vlsm.org/share/Debian-Doc/debian-policy/ch-relationships.html

答案2

那么,为什么中止了 的执行sudo apt-get -f install。再次运行它并且不要中止它。

运行这些命令后:

sudo apt-get clean
sudo apt-get autoclean
sudo dpkg --configure -a

然后再次运行:

sudo apt-get -f install

如果输出类似于:

0 upgraded, 0 newly installed, 0 to remove and 1 not upgraded

然后运行:

sudo apt-get -u dist-upgrade

添加 PPA 后如何解决未满足的依赖关系?了解更多信息。

现在java-runtime-headless使用以下命令进行安装:

sudo apt-get install openjdk-7-jre-headless

最后,安装你的应用程序:

sudo dpkg -i MYAPP.deb 

答案3

作为尼日尔河建议我将依赖项更改为

Depends: openjdk-7-jre-headless | java-runtime-headless, ...
Recommends: ...

现在我可以用它安装

$ sudo dpkg -i MYAPP.deb

并使用以下方式安装缺少的依赖项

$ sudo apt-get -f install

相关内容