#1837 A few fixes for kojikamid
Merged 4 years ago by tkopecek. Opened 4 years ago by mikeb.
mikeb/koji kojikamid-fixes  into  master

file modified
+7
@@ -127,6 +127,7 @@ 

          '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 @@ 

      update = _notImplemented

      setdefault = _notImplemented

  

+ ## END kojikamid dup

+ 

  API_VERSION = 1

  

  TASK_STATES = Enum((
@@ -262,12 +265,16 @@ 

      'MANUAL',

  ))

  

+ ## BEGIN kojikamid dup

+ 

  CHECKSUM_TYPES = Enum((

      'md5',

      'sha1',

      'sha256',

  ))

  

+ ## END kojikamid dup

+ 

  #PARAMETERS

  BASEDIR = '/mnt/koji'

  # default task priority

file modified
+17 -13
@@ -34,9 +34,9 @@ 

  import sys

  import tempfile

  import time

- # urlparse is required by the SCM class which is substituted into this file

+ # urllib is required by the SCM class which is substituted into this file

  # do not remove the import below

- import urlparse

+ from six.moves import urllib

  import six.moves.xmlrpc_client

  import base64

  import hashlib
@@ -316,15 +316,16 @@ 

          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 %f' % (

-                         fileinfo['checksum_type'],

+                 raise BuildError('Unknown checksum type %s for %s' % (

+                         checksum_type,

                          os.path.basename(fileinfo['localpath'])))

          with open(destpath, 'w') as destfile:

              offset = 0
@@ -338,12 +339,15 @@ 

                  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"""

kojikamid (the daemon that runs in VMs) needs a few updates to be consistent with changes to the the Koji data model, and Python 3 compatibility.

Created #1842 issue, will check later.

Commit e4b7dce fixes this pull-request

Pull-Request has been merged by tkopecek

4 years ago