Ubuntu – Does “apt list –all-versions” show more packages than “dpkg -l”

aptdpkg

According to 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.

But, in at least two cases, hunspell (see https://askubuntu.com/a/1036619/248158 for the output) and libreoffice, the apt list --all-versions list is far longer:

apt list --all-versions | grep -E "^hunspell"
apt list --all-versions | grep -E "^libreoffice"

result in far more hits than

dpkg -l hunspell*
dpkg -l libreoffice*

(dpkg-query --list gives the same output as dpkg -l.)

Best Answer

dpkg can only provide information about what it knows, which is limited to packages and versions that had some dpkg operation applied to them.

apt, on the other hand, has far more information - it includes everything in the package lists it gets from repositories. Obviously it's unlikely that dpkg operations have been done for most available packages and versions, and so of course the output of dpkg-query does not include those and is, hence, limited.

Related Question