`dpkg-query` 和虚拟包:如何读取或解释 `${Provides}`?

`dpkg-query` 和虚拟包:如何读取或解释 `${Provides}`?

背景

在定期审核已安装软件包的过程中,我遇到了一个错误。对于此审核,应用程序使用 生成已安装软件包的图表dpkg-query。在此过程中,它会检查 同时,所有依赖关系确实都得到满足,否则这意味着系统出现问题或生成图表的应用程序出现问题。今天发生了这种情况,应用程序因错误而停止,告诉它发现一个对 具有未满足依赖关系的包python:any。但是,依赖包没有问题。我检查的python:any是包 提供的虚拟包python。Synaptic 说python提供python:any,但我的应用程序没有从 收到此信息dpkg-query

以下是您可以从命令行执行的测试,它显示了问题(假设 Ubuntu 14.04):

$ dpkg-query --showformat='${Package}\n${Provides}\n' --show python3
> python3
> python3-profiler
# Note `python3:any` does not appear

关于同一个包,Synaptic 表示它提供了python3:anypython3-profiler。 前者在 返回的信息中缺失dpkg-query

当作为依赖项出现时,这是可以的:

$ dpkg-query --showformat='${Package}\n${Depends}\n' --show apturl-common
# Note the second item in the format is now `Depends`
> apturl-common
> python3:any (>= 3.3.2-2~), python3-apt, python3-update-manager

问题

这是 中的错误dpkg-query吗?还是我错误地期望它会告知所有虚拟包,而我可能应该“自己”推断出这种虚拟包?它们是一些我不知道的关于 中返回的内容的规则吗${Provides}

答案1

python3:any (>= 3.3.2-2~)不是虚拟包,而是由模式创建的替换字符串,并在包构建时调用时${python3:Depends}填充。看一下源包的文件:dh_python3dh_gencontroldebian/controlapturl

Package: apturl-common
Architecture: any
Depends: ${python3:Depends},
 ${shlibs:Depends},
 ${misc:Depends},
 python3-apt,
 python3-update-manager
Replaces: apturl (<< 0.3.6ubuntu2)
Description: install packages using the apt protocol - common data
 AptUrl is a simple graphical application that takes an URL (which follows the
 apt-protocol) as a command line option, parses it and carries out the
 operations that the URL describes (that is, it asks the user if he wants the
 indicated packages to be installed and if the answer is positive does so for
 him).

现在为什么python3:any?让我们引用 Debian 政策:

仅指定 any 表示源包不依赖于任何特定体系结构,并且应可以在任何体系结构上顺利编译。生成的二进制包将特定于当前构建体系结构。

对于二进制包来说,情况确实如此python3

Package: python3
Architecture: any
Multi-Arch: allowed
Pre-Depends: python3-minimal (= ${binary:Version})
Depends: python3.4 (>= 3.4.3-1), libpython3-stdlib (= ${binary:Version}), ${misc:Depends}, dh-python
Suggests: python3-doc (>= ${binary:Version}), python3-tk (>= 3.4.3-1) , python3-venv (>= ${binary:Version})
Replaces: python3-minimal (<< 3.1.2-2)
Provides: python3-profiler
Description: interactive high-level object-oriented language (default python3 version)
 Python, the high-level, interactive object oriented language,
 includes an extensive class library with lots of goodies for
 network programming, system administration, sounds and graphics.
 .
 This package is a dependency package, which depends on Debian's default
 Python 3 version (currently v3.4).

资料来源:

答案2

我认为要猜测一个答案,但仍然可以随意添加您自己的答案。

我了解到有一个/var/lib/dpkg/available数据库,作为原始文本。我检查了python3(继续使用与问题中相同的例子)它说Provides: python3-profiler:没有python3:any

因此答案可能是:返回的要求dpkg-query和返回的包之间并不总是直接匹配dpkg-query,并且 Synaptic 可能推断出一个“假”虚拟包,而python3:any并不是真正的虚拟包(我想说 Synaptic 在这里具有误导性)。

最有可能的是,所提供的软件包没有任何内容,而我错误地将:xyz软件包依赖项的末尾读作软件包名称的一部分,但事实并非如此。

相关内容