Milton Paiva Neto wrote:
I create a method to be added in the rpms module, I am sending the
modified rpms.py file as an attachment.
A unified diff against git head is usually easier for me to deal
with, or a url to a git repo with the changes
and a copy of the diff in the email is even better. Just makes reviewing
things a little easier, and makes
merging even easier.
comments inline
----------------------
def verify(self, flatten=True):
I would add support for specifying a package name, or even better, a
package glob. See the rpms.glob()
method as an example.
"""
Returns information of the verification of all installed
packages. """
import subprocess
ts = rpm.TransactionSet()
mi = ts.dbMatch()
results = []
for hdr in mi:
name = hdr['name']
if flatten:
results.append("%s" % (name))
proc = subprocess.Popen(['/bin/rpm -V '+ name],
shell=True, stdout=subprocess.PIPE)
In this particular implementation, there isn't really any difference
between the code above and just
shelling out to `rpm -Va`. That said, if you add the glob support, your
approach is better.
stdout_value = proc.communicate()[0]
results.append("%s\n" % (stdout_value))
else:
results.append([name])
Not sure yet, but I think you may be losing data here in cases where
multiple versions of the same package
is installed (say, a kernel, or just about any package on a x86_64
machine with i386 packages installed).
May be better to key the dict on something more unique
(name-version-release.arch, for example)
I'd also check to see if the rpm python api supports package
verification directly now. I know it didn't
for a long time, but it may now. Though, it may not be very backwards
compatible.
Adrian
_______________________________________________
Func-list mailing list
Func-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/func-list