為什麼有通配符的 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.

相關內容