#1029586 apt: "apt-cache rdepends --installed" false positives

Package:
apt
Source:
apt
Description:
commandline package manager
Submitter:
Vincent Lefevre
Date:
2023-06-16 13:12:03 UTC
Severity:
normal
Tags:
#1029586#5
Date:
2023-01-25 02:06:03 UTC
From:
To:
"apt-cache rdepends --installed" outputs false positives.
For instance:

zira:~> apt-cache rdepends --installed libpcre3:amd64
libpcre3
Reverse Depends:
[...]
  grep
[...]

But according to "dpkg -s grep":

Depends: dpkg (>= 1.15.4) | install-info
Pre-Depends: libc6 (>= 2.34), libpcre2-8-0 (>= 10.32)

there is no libpcre3!

I'm wondering whether apt is confused by old grep versions
(which depend on libpcre3, but they are not the currently
installed version).

#1029586#10
Date:
2023-01-25 09:45:53 UTC
From:
To:
Control: tag -1 wontfix

You want to use `apt list '?any-version(?installed?depends(?exact-name(libpcre3)))'`
instead (with apt >= 2.5.4). In earlier versions you may use:
apt list '?any-version(?archive(now)?depends(?exact-name(libpcre3)))'

The behavior of patterns is better defined than that of the legacy
(r)depends tools. The behavior of rdepends here is not necessarily
useful, but it is the way it is. These commands are provided as-is
and will not receive drastic changes in behavior.

The --installed flag here behaves exactly as it is documented. It
filters the output list by packages that are installed; it doesn't
say anything about restricting matching to installed versions only
- matching always happens on all versions effectively.

The same behavior you can get with patterns by using

`apt list '?installed?depends(?exact-name(libpcre3))'`

For a machine readable output, pass the pattern to apt-cache show.

#1029586#17
Date:
2023-01-25 11:05:06 UTC
From:
To:
Note that this is not documented. The apt(8) man page just says

  list
    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 the glob(7) man page is just about globbing pathnames. And
the dpkg-query(1) man page doesn't mention anything about the
above syntax (in case it would be accepted).

The documentation in apt-cache(8) is confusing, because "package"
could either refer to a package name or to a particular version.
However, the dependency relation makes sense only with a particular
version.

And the (r)depends entries in apt-cache(8) should suggest to use
patterns instead. Moreover, it should be clear for the user how to
find the documentation.

Apparently with the "?any-version" as mentioned above, otherwise the
output is incorrect (and is even more confusing, because for instance,
bti 034-6+b1 is output while this is actually only the older version
bti 034-5+b1 that depends on libpcre3). But this is not documented in
the man pages ("man -K any-version" finds no man pages).

#1029586#22
Date:
2023-01-25 11:52:45 UTC
From:
To:
Documentation for apt patterns only lives in apt-patterns(7) and
not referenced elsewhere. Patterns work in apt-cache show, apt show,
apt list, and apt install-like commands (including in apt-get).

Well the apt-get manual page states that install supports it in
a confusing way:

Other manual pages are not really touched. The entire documentation
is unorganized and barely readable, mangling all commands to apt-get
or apt-cache in a single manual page each, which is useless, hence
it needs to be rewritten entirely to have individual pages so you
can do man apt install and it gives you a description of install
and all options it accepts.

We can do this a step at a time, but it really needs to happen,
but that's all post-bookworm talk, for now I say keeping stuff
in this horrid state is better than ending with english manual
pages on non-English systems (I do not have the time anyhow).

It's documented in apt-patterns(7). And yes of course with any-version
the whole point is that without any-version it acts like rdepends
--installed.

#1029586#27
Date:
2023-06-14 15:56:53 UTC
From:
To:
Perhaps this should be documented more clearly. My reading of the option
was just as wrong as Vincent's.

#1029586#32
Date:
2023-06-16 13:08:12 UTC
From:
To:
On this point, I was not aware of this man page. Indeed, it is not
referenced at all by the apt(8) man page. It should be at least in
the "SEE ALSO" section. Ditto for the other concerned man pages.