Skip to content

Instantly share code, notes, and snippets.

@elleryq
Last active August 29, 2015 14:03
Show Gist options
  • Save elleryq/99993cf7f09deaf70e9a to your computer and use it in GitHub Desktop.
Save elleryq/99993cf7f09deaf70e9a to your computer and use it in GitHub Desktop.
rpmqa.py from Fedora RPM guide.
#!/usr/bin/python
# https://docs.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch-rpm-programming-python.html
# Acts like rpm -qa and lists the names of all the installed packages.
# Usage:
# python rpmqa.py
import rpm
ts = rpm.TransactionSet()
mi = ts.dbMatch()
#for p in mi:
# print "%s-%s-%s" % (p['name'], p['version'], p['release']).
for p in sorted([h['name'] for h in mi]):
print(p)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment