File createrepo-0.4.11-hashfix.patch of Package createrepo

Index: dumpMetadata.py
===================================================================
--- dumpMetadata.py.orig
+++ dumpMetadata.py
@@ -22,8 +22,6 @@ import glob
 import os
 import rpm
 import exceptions
-import md5
-import sha
 import types
 import struct
 import re
@@ -124,9 +122,21 @@ def getChecksum(sumtype, file, CHUNK=2**
             fo = open(file, 'rb', CHUNK)
             
         if sumtype == 'md5':
-            sum = md5.new()
+            try:
+                 import hashlib
+                 sum = hashlib.md5()
+            except ImportError:
+                 # for Python < 2.6
+                 import md5
+                 sum = md5.new()
         elif sumtype == 'sha':
-            sum = sha.new()
+            try:
+                 import hashlib
+                 sum = hashlib.sha1()
+            except ImportError:
+                 # for Python < 2.6
+                 import sha
+                 sum = sha.new()
         else:
             raise MDError, 'Error Checksumming file, wrong checksum type %s' % sumtype
         chunk = fo.read
@@ -609,7 +619,13 @@ class RpmMetaData:
         if type(self.hdr[rpm.RPMTAG_SHA1HEADER]) is not types.NoneType:
             t.append("".join(self.hdr[rpm.RPMTAG_SHA1HEADER]))
 
-        key = md5.new("".join(t)).hexdigest()
+        try:
+             import hashlib
+             key = hashlib.md5("".join(t)).hexdigest()
+        except ImportError:
+             # for Python < 2.6
+             import md5
+             key = md5.new("".join(t)).hexdigest()
                                         
         csumtag = '%s-%s-%s-%s' % (os.path.basename(self.relativepath), 
                                    self.hdr[rpm.RPMTAG_SHA1HEADER], 
openSUSE Build Service is sponsored by