On 11/29/22 07:05, Andrei Nikonov wrote:
Dear maintainers,
I am writing to you asking for help or advice.
I have to get a list of installed packages from /var/lib/rpm/Packages
database file directly, without using such commands as 'rpm -qa' or 'yum
list' or something else, because I might have no access to those
commands and rpm at all. Actually, my case is to get the list of
installed packages from the docker container with rpm-based OS, while
the host OS can be different.
I am using Python and all I have reached for the moment is an opened
Berkeley DB file with output of tuples of binary data. But I have no
idea how to decode this binary output to get human readable information.
Berkeley DB is one of the possible rpmdb formats, but that's no longer
even supported upstream, the current formats are sqlite and an
rpm-specific format.
Maybe I am using the wrong approach from the beginning - please refer me
the right way. Maybe there is a python library that I could use?
Unfortunately I did not find any similar questions, so decided to write
here.
The rpmdb main data is nothing but a pile of rpm headers keyed by a
number, and the format is considered private to rpm. To make sense of
it, you need to extract and parse the headers, and for that you'll want
the rpm python bindings. As in, the only supported means doing this all
is through librpm.
Of course it's *possible* to do this in pure python, look for "pyrpm"
for an example. I don't know how up to date or complete that work is,
probably neither. The basic rpm header format is documented in LSB,
though outdated it's enough to get an idea.
- Panu -
Thank you in advance.
--
With regards,
Andrey Nikonov.
_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list
_______________________________________________
Rpm-list mailing list
Rpm-list@xxxxxxxxxxxxx
http://lists.rpm.org/mailman/listinfo/rpm-list