为什么“apt list –all-versions”显示的包比“dpkg -l”多?
根据man apt
说法,
list (work-in-progress) list is somewhat similar to dpkg-query --list in that it can display a list of packages satisfying certain criteria. It supports glob(7) patterns for matching package names as well as options to list installed (--installed), upgradeable (--upgradeable) or all available (--all-versions) versions.
但是,在至少两种情况下, hunspell
(请参阅https://askubuntu.com/a/1036619/248158输出)和libreoffice
, apt list --all-versions
列表要长得多:
apt list --all-versions | grep -E "^hunspell" apt list --all-versions | grep -E "^libreoffice"
导致的命中率远高于
dpkg -l hunspell* dpkg -l libreoffice*
( dpkg-query --list
提供与dpkg -l
相同的输出。)
dpkg
只能提供有关其知识的信息,这仅限于应用了一些dpkg
操作的软件包和版本。
另一方面, apt
有更多的信息 – 它包括从存储库获取的包列表中的所有内容。 显然,对于大多数可用的软件包和版本, dpkg
操作不太可能已经完成,因此dpkg-query
的输出当然不包括那些,因此是有限的。