I am working in a method to verify the installed packages for the rpms module.
I checked python api and there isn’t any buildin method I could use, but I checked yum api and I found something interesting,
The output with the external command was:
prelink: /usr/sbin/useradd: at least one of file’s dependencies has changed since prelinking
prelink: /usr/sbin/userdel: at least one of file’s dependencies has changed since prelinking
prelink: /usr/sbin/usermod: at least one of file’s dependencies has changed since prelinking
While the output with the yum api is:
/usr/sbin/userdel – checksum does not match
/usr/sbin/userdel – size does not match
/usr/sbin/groupdel – checksum does not match
/usr/sbin/groupdel – size does not match
/etc/login.defs – mtime does not match
/etc/login.defs – checksum does not match
/etc/login.defs – size does not match
/usr/bin/newgrp – checksum does not match
I intend to work now to allow the verification for only one package each time adding support for rpms.glob(). When its done the plan is to merge the yum module with the rpm module and create a new module called “packages”.
The current code is:
def verify(self, flatten=True):
Returns information of the verification of all installed packages.
ts = rpm.TransactionSet()
mi = ts.dbMatch()
results = 
for hdr in mi:
name = hdr[‘name’]
yb = yum.YumBase()
pkgs = yb.rpmdb.searchNevra(name)
for pkg in pkgs:
errors = pkg.verify()
for fn in errors.keys():
for prob in errors[fn]:
results.append(‘%s %s %s’ % (name, fn, prob.message))
results.append(“%s-%s-%s.%s” % (name, version, release, arch))
Feel free to give me some ideas or comments, thanks.