rpm-software-management / dnf

Package manager based on libdnf and libsolv. Replaces YUM.
GNU General Public License v2.0
1.23k stars 409 forks source link

Best way to get explicitly user installed packages? #2073

Closed InnocentZero closed 6 months ago

InnocentZero commented 6 months ago

Greetings everyone, I am a contributor to pacdef and wanted to introduce support for rpm based distributions that use dnf. A slight issue that I am facing at the moment is that dnf history userinstalled also has timestamps of when the package was installed along with and trying to regex the package name out of it looks like a big hack to me.

So what is the best way to interface with dnf to get the explicitly user-installed packages/groups? A command output from dnf or an API in libdnf works, but as I understand libdnf is undergoing changes atm.

m-blaha commented 6 months ago

You can use dnf repoquery --userinstalled from the command line interface. This allows you to fine-tune the output using --queryformat option (see man dnf for details). This should work with both current dnf4 and upcoming dnf5. Or are you interested in an API way? Btw - I do not see any timestamps in the dnf history userinstalled output. What's the version you use?

InnocentZero commented 6 months ago

You can use dnf repoquery --userinstalled from the command line interface. This allows you to fine-tune the output using --queryformat option (see man dnf for details). This should work with both current dnf4 and upcoming dnf5. Or are you interested in an API way?

API would be preferable but this should work.

Btw - I do not see any timestamps in the dnf history userinstalled output. What's the version you use?

I'm sorry for confusing you by saying timestamps. I should have said package versions. Though it seems dnf repoquery --userinstalled has an easy method to remove the package version from the package name. Thanks for your help!