为什么带有通配符的 dpkg-query -l 没有列出所有可能的软件包?

为什么带有通配符的 dpkg-query -l 没有列出所有可能的软件包?

根据dpkg-query手册页:

例如,这将列出以“libc6”开头的所有包名称:

            dpkg-query -l 'libc6*'

当我在 Debian 10.5 上尝试时:

$ dpkg-query -l 'libc6*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  libc6:amd64    2.28-10      amd64        GNU C Library: Shared libraries
un  libc6-amd64    <none>       <none>       (no description available)
un  libc6.1        <none>       <none>       (no description available)

虽然apt显示更多包:

$ apt list 'libc6*'
Listing... Виконано
libc6-amd64-cross/stable 2.28-7cross1 all
libc6-amd64-i386-cross/stable 2.28-7cross1 all
libc6-amd64-x32-cross/stable 2.28-7cross1 all
libc6-arm64-cross/stable 2.28-7cross1 all
libc6-armel-cross/stable 2.28-7cross1 all
libc6-armhf-cross/stable 2.28-7cross1 all
libc6-dbg/stable 2.28-10 amd64
libc6-dev-amd64-cross/stable 2.28-7cross1 all
libc6-dev-amd64-i386-cross/stable 2.28-7cross1 all
libc6-dev-amd64-x32-cross/stable 2.28-7cross1 all
libc6-dev-arm64-cross/stable 2.28-7cross1 all
libc6-dev-armel-cross/stable 2.28-7cross1 all
libc6-dev-armhf-cross/stable 2.28-7cross1 all
libc6-dev-hppa-cross/stable 2.28-7cross1 all
libc6-dev-i386-amd64-cross/stable 2.28-7cross1 all
libc6-dev-i386-cross/stable 2.28-7cross1 all
libc6-dev-i386-x32-cross/stable 2.28-7cross1 all
libc6-dev-i386/stable 2.28-10 amd64
libc6-dev-m68k-cross/stable 2.28-7cross1 all
libc6-dev-mips-cross/stable 2.28-7cross1 all
libc6-dev-mips32-mips64-cross/stable 2.28-7cross2 all
libc6-dev-mips32-mips64el-cross/stable 2.28-7cross1 all
libc6-dev-mips32-mips64r6-cross/stable 2.28-7cross2 all
libc6-dev-mips32-mips64r6el-cross/stable 2.28-7cross2 all
libc6-dev-mips32-mipsn32-cross/stable 2.28-7cross2 all
libc6-dev-mips32-mipsn32el-cross/stable 2.28-7cross2 all
libc6-dev-mips32-mipsn32r6-cross/stable 2.28-7cross2 all
libc6-dev-mips32-mipsn32r6el-cross/stable 2.28-7cross2 all
libc6-dev-mips64-cross/stable 2.28-7cross2 all
libc6-dev-mips64-mips-cross/stable 2.28-7cross1 all
libc6-dev-mips64-mipsel-cross/stable 2.28-7cross1 all
libc6-dev-mips64-mipsn32-cross/stable 2.28-7cross2 all
libc6-dev-mips64-mipsn32el-cross/stable 2.28-7cross2 all
libc6-dev-mips64-mipsn32r6-cross/stable 2.28-7cross2 all
libc6-dev-mips64-mipsn32r6el-cross/stable 2.28-7cross2 all
libc6-dev-mips64-mipsr6-cross/stable 2.28-7cross2 all
libc6-dev-mips64-mipsr6el-cross/stable 2.28-7cross2 all
libc6-dev-mips64el-cross/stable 2.28-7cross1 all
libc6-dev-mips64r6-cross/stable 2.28-7cross2 all
libc6-dev-mips64r6el-cross/stable 2.28-7cross2 all
libc6-dev-mipsel-cross/stable 2.28-7cross1 all
libc6-dev-mipsn32-cross/stable 2.28-7cross2 all
libc6-dev-mipsn32-mips-cross/stable 2.28-7cross1 all
libc6-dev-mipsn32-mips64-cross/stable 2.28-7cross2 all
libc6-dev-mipsn32-mips64el-cross/stable 2.28-7cross1 all
libc6-dev-mipsn32-mips64r6-cross/stable 2.28-7cross2 all
libc6-dev-mipsn32-mips64r6el-cross/stable 2.28-7cross2 all
libc6-dev-mipsn32-mipsel-cross/stable 2.28-7cross1 all
libc6-dev-mipsn32-mipsr6-cross/stable 2.28-7cross2 all
libc6-dev-mipsn32-mipsr6el-cross/stable 2.28-7cross2 all
libc6-dev-mipsn32el-cross/stable 2.28-7cross2 all
libc6-dev-mipsn32r6-cross/stable 2.28-7cross2 all
libc6-dev-mipsn32r6el-cross/stable 2.28-7cross2 all
libc6-dev-mipsr6-cross/stable 2.28-7cross2 all
libc6-dev-mipsr6el-cross/stable 2.28-7cross2 all
libc6-dev-powerpc-cross/stable 2.28-7cross1 all
libc6-dev-powerpc-ppc64-cross/stable 2.28-7cross1 all
libc6-dev-powerpcspe-cross/stable 2.28-7cross1 all
libc6-dev-ppc64-cross/stable 2.28-7cross1 all
libc6-dev-ppc64-powerpc-cross/stable 2.28-7cross1 all
libc6-dev-ppc64el-cross/stable 2.28-7cross1 all
libc6-dev-riscv64-cross/stable 2.28-7cross1 all
libc6-dev-s390-s390x-cross/stable 2.28-7cross1 all
libc6-dev-s390x-cross/stable 2.28-7cross1 all
libc6-dev-sh4-cross/stable 2.28-7cross1 all
libc6-dev-sparc-sparc64-cross/stable 2.28-7cross1 all
libc6-dev-sparc64-cross/stable 2.28-7cross1 all
libc6-dev-x32-amd64-cross/stable 2.28-7cross1 all
libc6-dev-x32-cross/stable 2.28-7cross1 all
libc6-dev-x32-i386-cross/stable 2.28-7cross1 all
libc6-dev-x32/stable 2.28-10 amd64
libc6-dev/stable 2.28-10 amd64
libc6-hppa-cross/stable 2.28-7cross1 all
libc6-i386-amd64-cross/stable 2.28-7cross1 all
libc6-i386-cross/stable 2.28-7cross1 all
libc6-i386-x32-cross/stable 2.28-7cross1 all
libc6-i386/stable 2.28-10 amd64
libc6-m68k-cross/stable 2.28-7cross1 all
libc6-mips-cross/stable 2.28-7cross1 all
libc6-mips32-mips64-cross/stable 2.28-7cross2 all
libc6-mips32-mips64el-cross/stable 2.28-7cross1 all
libc6-mips32-mips64r6-cross/stable 2.28-7cross2 all
libc6-mips32-mips64r6el-cross/stable 2.28-7cross2 all
libc6-mips32-mipsn32-cross/stable 2.28-7cross2 all
libc6-mips32-mipsn32el-cross/stable 2.28-7cross2 all
libc6-mips32-mipsn32r6-cross/stable 2.28-7cross2 all
libc6-mips32-mipsn32r6el-cross/stable 2.28-7cross2 all
libc6-mips64-cross/stable 2.28-7cross2 all
libc6-mips64-mips-cross/stable 2.28-7cross1 all
libc6-mips64-mipsel-cross/stable 2.28-7cross1 all
libc6-mips64-mipsn32-cross/stable 2.28-7cross2 all
libc6-mips64-mipsn32el-cross/stable 2.28-7cross2 all
libc6-mips64-mipsn32r6-cross/stable 2.28-7cross2 all
libc6-mips64-mipsn32r6el-cross/stable 2.28-7cross2 all
libc6-mips64-mipsr6-cross/stable 2.28-7cross2 all
libc6-mips64-mipsr6el-cross/stable 2.28-7cross2 all
libc6-mips64el-cross/stable 2.28-7cross1 all
libc6-mips64r6-cross/stable 2.28-7cross2 all
libc6-mips64r6el-cross/stable 2.28-7cross2 all
libc6-mipsel-cross/stable 2.28-7cross1 all
libc6-mipsn32-cross/stable 2.28-7cross2 all
libc6-mipsn32-mips-cross/stable 2.28-7cross1 all
libc6-mipsn32-mips64-cross/stable 2.28-7cross2 all
libc6-mipsn32-mips64el-cross/stable 2.28-7cross1 all
libc6-mipsn32-mips64r6-cross/stable 2.28-7cross2 all
libc6-mipsn32-mips64r6el-cross/stable 2.28-7cross2 all
libc6-mipsn32-mipsel-cross/stable 2.28-7cross1 all
libc6-mipsn32-mipsr6-cross/stable 2.28-7cross2 all
libc6-mipsn32-mipsr6el-cross/stable 2.28-7cross2 all
libc6-mipsn32el-cross/stable 2.28-7cross2 all
libc6-mipsn32r6-cross/stable 2.28-7cross2 all
libc6-mipsn32r6el-cross/stable 2.28-7cross2 all
libc6-mipsr6-cross/stable 2.28-7cross2 all
libc6-mipsr6el-cross/stable 2.28-7cross2 all
libc6-pic/stable 2.28-10 amd64
libc6-powerpc-cross/stable 2.28-7cross1 all
libc6-powerpc-ppc64-cross/stable 2.28-7cross1 all
libc6-powerpcspe-cross/stable 2.28-7cross1 all
libc6-ppc64-cross/stable 2.28-7cross1 all
libc6-ppc64-powerpc-cross/stable 2.28-7cross1 all
libc6-ppc64el-cross/stable 2.28-7cross1 all
libc6-riscv64-cross/stable 2.28-7cross1 all
libc6-s390-s390x-cross/stable 2.28-7cross1 all
libc6-s390x-cross/stable 2.28-7cross1 all
libc6-sh4-cross/stable 2.28-7cross1 all
libc6-sparc-sparc64-cross/stable 2.28-7cross1 all
libc6-sparc64-cross/stable 2.28-7cross1 all
libc6-x32-amd64-cross/stable 2.28-7cross1 all
libc6-x32-cross/stable 2.28-7cross1 all
libc6-x32-i386-cross/stable 2.28-7cross1 all
libc6-x32/stable 2.28-10 amd64
libc6.1-alpha-cross/stable 2.28-7cross1 all
libc6.1-dev-alpha-cross/stable 2.28-7cross1 all
libc6/stable,now 2.28-10 amd64 [installed]

如何让dpkg-query显示所有匹配项?为什么它只显示一个选择?

答案1

dpkg-query仅默认查看/var/lib/dpkg/status,并且仅包含有关当前安装或过去安装的软件包的信息。

要查看所有可用的软件包,您可以添加以下--load-avail选项:

dpkg-query --load-avail -l 'libc6*'

但这依赖于/var/lib/dpkg/available与时俱进。apt不触及该文件,它使用自己的数据库,因此您需要自己处理:

for file in /var/lib/apt/lists/*_Packages; do sudo dpkg --merge-avail $file; done

(请注意,这不考虑翻译的描述,因此dpkg-query无法显示它们。)

最好用于apt此类查询。dpkg具有包的本地视图,apt具有基于存储库的视图;因此基于存储库的查询最好由apt.

相关内容