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:
S.?….. /usr/sbin/groupmod
prelink: /usr/sbin/useradd: at least one of file’s dependencies has changed since prelinking
S.?….. /usr/sbin/useradd
prelink: /usr/sbin/userdel: at least one of file’s dependencies has changed since prelinking
S.?….. /usr/sbin/userdel
prelink: /usr/sbin/usermod: at least one of file’s dependencies has changed since prelinking
S.?….. /usr/sbin/usermod
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:
http://func.pastebin.com/m523b93ac
def verify(self, flatten=True):
“””
Returns information of the verification of all installed packages.
“””
import yum
ts = rpm.TransactionSet()
mi = ts.dbMatch()
results = []
for hdr in mi:
name = hdr[‘name’]
if flatten:
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))
else:
results.append(“%s-%s-%s.%s” % (name, version, release, arch))
return results
Feel free to give me some ideas or comments, thanks.