--- dumpMetadata.py~ 2006-03-04 01:30:50.000000000 -0500
+++ dumpMetadata.py 2009-08-10 16:55:10.000000000 -0400
@@ -559,14 +559,32 @@
"""return a checksum for a package:
- check if the checksum cache is enabled
if not - return the checksum
- if so - check to see if it has a cache file
+ if so - search for a usable key in the header
+ - check to see if it has a cache file
if so, open it and return the first line's contents
if not, grab the checksum and write it to a file for this pkg
"""
if not self.options['cache']:
return getChecksum(self.options['sumtype'], fo)
+
+ # first try the easy ones
+ key = None
+ for h in (rpm.RPMTAG_SHA1HEADER, rpm.RPMTAG_RSAHEADER, rpm.RPMTAG_DSAHEADER):
+ key = self.hdr[h]
+ if key:
+ break
+
+ # now the not so easy ones
+ if not key:
+ for h in (rpm.RPMTAG_SIGPGP, rpm.RPMTAG_SIGMD5, rpm.RPMTAG_SIGGPG):
+ key = self.hdr[h]
+ if key:
+ # generate hexdigest from signature
+ key = "".join([hex(ord(x))[2:].zfill(2)
+ for x in tuple(self.hdr[h])])
+ break
- csumtag = '%s-%s' % (self.hdr['name'] , self.hdr[rpm.RPMTAG_SHA1HEADER])
+ csumtag = '%s-%s' % (self.hdr['name'], key)
csumfile = '%s/%s' % (self.options['cachedir'], csumtag)
if os.path.exists(csumfile) and self.mtime <= os.stat(csumfile)[8]:
csumo = open(csumfile, 'r')