diff --git a/koji/__init__.py b/koji/__init__.py index a7925d38..6acd1bbe 100644 --- a/koji/__init__.py +++ b/koji/__init__.py @@ -127,6 +127,7 @@ for h in ( 'RECOMMENDNAME', 'RECOMMENDVERSION', 'RECOMMENDFLAGS'): SUPPORTED_OPT_DEP_HDRS[h] = hasattr(rpm, 'RPMTAG_%s' % h) +## BEGIN kojikamid dup class Enum(dict): """A simple class to track our enumerated constants @@ -174,6 +175,8 @@ class Enum(dict): update = _notImplemented setdefault = _notImplemented +## END kojikamid dup + API_VERSION = 1 TASK_STATES = Enum(( @@ -262,12 +265,16 @@ TAG_UPDATE_TYPES = Enum(( 'MANUAL', )) +## BEGIN kojikamid dup + CHECKSUM_TYPES = Enum(( 'md5', 'sha1', 'sha256', )) +## END kojikamid dup + #PARAMETERS BASEDIR = '/mnt/koji' # default task priority diff --git a/vm/kojikamid.py b/vm/kojikamid.py index 4f63ab9f..ed101014 100755 --- a/vm/kojikamid.py +++ b/vm/kojikamid.py @@ -316,15 +316,16 @@ class WindowsBuild(object): destpath = os.path.join(basedir, fileinfo['localpath']) ensuredir(os.path.dirname(destpath)) if 'checksum_type' in fileinfo: - if fileinfo['checksum_type'] == 'sha1': + checksum_type = CHECKSUM_TYPES[fileinfo['checksum_type']] + if checksum_type == 'sha1': checksum = hashlib.sha1() - elif fileinfo['checksum_type'] == 'sha256': + elif checksum_type == 'sha256': checksum = hashlib.sha256() - elif fileinfo['checksum_type'] == 'md5': + elif checksum_type == 'md5': checksum = hashlib.md5() else: raise BuildError('Unknown checksum type %s for %s' % ( - fileinfo['checksum_type'], + checksum_type, os.path.basename(fileinfo['localpath']))) with open(destpath, 'w') as destfile: offset = 0 @@ -338,12 +339,15 @@ class WindowsBuild(object): offset += len(data) if 'checksum_type' in fileinfo: checksum.update(data) - # rpms don't have a md5sum in the fileinfo, but check it for everything else - digest = checksum.hexdigest() - if 'checksum' in fileinfo and fileinfo['checksum'] != digest: - raise BuildError('checksum validation failed for %s, %s (computed) != %s (provided)' % \ - (destpath, digest, fileinfo['checksum'])) - self.logger.info('Retrieved %s (%s bytes, md5: %s)', destpath, offset, digest) + # rpms don't have a checksum in the fileinfo, but check it for everything else + if 'checksum_type' in fileinfo: + digest = checksum.hexdigest() + if fileinfo['checksum'] != digest: + raise BuildError('checksum validation failed for %s, %s (computed) != %s (provided)' % \ + (destpath, digest, fileinfo['checksum'])) + self.logger.info('Retrieved %s (%s bytes, %s: %s)', destpath, offset, checksum_type, digest) + else: + self.logger.info('Retrieved %s (%s bytes)', destpath, offset) def fetchBuildReqs(self): """Retrieve buildrequires listed in the spec file"""