Last active
July 14, 2017 08:50
-
-
Save maurorappa/25892d26cfd3f3782c76565f75dc7afb to your computer and use it in GitHub Desktop.
Query RPM database in Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# Acts like rpm -qa and lists the names of all the installed packages. | |
# Usage: | |
# python rpmqa.py | |
# This toool was used to debug RedHat Bugzilla BZ#1253608 for RHEL6 (not public) | |
# the relative errata is: https://rhn.redhat.com/errata/RHBA-2015-1809.html | |
import rpm | |
import datetime | |
ts = rpm.TransactionSet() | |
mi = ts.dbMatch() | |
mi.pattern('name', rpm.RPMMIRE_GLOB, 'kernel*' ) | |
for h in mi: | |
install_time = h['INSTALLTID'] | |
date = datetime.datetime.fromtimestamp(install_time) | |
print "%s-%s-%s installed %s" % (h['name'], h['version'], h['release'],date.strftime('%Y-%m-%d %H:%M:%S')) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment