Can I query the version of a specific (layered) dnf package in rpm-ostree?

I’ve reported a bug with a dnf package on Fedora Silverblue and the ticket says it’s fixed in a specific version.

Now, on Silverblue I don’t have dnf on the host system, and rpm-ostree status only shows the general version. And which packages are layered (which the one I choose is pat of)
But I see no way to query the exact version of that layered package that is (apparently) installed on my system.

Is this somehow possible?

Well, while dnf is not available on Silverblue, rpm is there. So you can use it in order to get info about a layered package.
(If I’m not totally wrong :sweat_smile:)

To add to this:

You basically want either rpm -q the-package to show the full package name (including version), or, if you need just the version, rpm -q --queryformat '%{VERSION}' the-package.

A big advantage here is also that this will run faster than dnf. In addition, it also works on base image packages, not just layered packages.

If you want to know how it’s stored internally, IIRC rpm-ostreed’s D-Bus APIs let you get the versions of all layered packages.

2 Likes

This might be possible by trying each … “--installroot” :

for installroot in $(ls /sysroot/ostree/deploy/fedora/deploy/*/); do
     echo "# layer: ${installroot}"
     /usr/bin/python -m dnf.cli.main --installroot="${installroot}" repoquery --installed
done

Not quite, because it can’t write to /var/tmp for what should be a read-only query:

Config error: [Errno 30] Read-only file system: '/sysroot/ostree/deploy/fedora/deploy/[...].0/var/tmp': '/sysroot/ostree/deploy/fedora/deploy/[...].0/var/tmp'