Skip to content

Instantly share code, notes, and snippets.

@vasi
Last active December 31, 2021 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vasi/7d94f00ed674b307b0d86afeab17298f to your computer and use it in GitHub Desktop.
Save vasi/7d94f00ed674b307b0d86afeab17298f to your computer and use it in GitHub Desktop.
Show installation reason for each dnf package
#!/usr/bin/env python
import dnf
import libdnf
base = dnf.Base()
base.fill_sack()
for pkg in base.sack.query().installed():
reason_enum = base.history.swdb.resolveRPMTransactionItemReason(pkg.name, pkg.arch, 0)
reason = libdnf.transaction.TransactionItemReasonToString(reason_enum)
print(f"{pkg.name} {pkg.arch} {reason}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment