mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-04-05 03:38:12 +08:00
Fallback to the old Koji tag format for the target when the tag name is too long
This commit is contained in:
@@ -418,10 +418,15 @@ chmod 644 %buildroot/%_sysconfdir/rpm/macros.zz-modules
|
||||
)
|
||||
add_groups()
|
||||
|
||||
# Koji targets can only be 50 characters long, but the generate_koji_tag function
|
||||
# checks the length with '-build' at the end, but we know we will never append '-build',
|
||||
# so we can safely have the name check be more characters
|
||||
target_length = 50 + len('-build')
|
||||
target = module_build_service.utils.generate_koji_tag(
|
||||
self.module.name, self.module.stream, self.module.version, self.module.context,
|
||||
target_length)
|
||||
# Add main build target.
|
||||
self.module_target = self._koji_add_target(self.tag_name,
|
||||
self.module_build_tag,
|
||||
self.module_tag)
|
||||
self.module_target = self._koji_add_target(target, self.module_build_tag, self.module_tag)
|
||||
|
||||
self.__prep = True
|
||||
log.info("%r buildroot sucessfully connected." % self)
|
||||
|
||||
@@ -93,7 +93,7 @@ def module_build_state_from_msg(msg):
|
||||
return state
|
||||
|
||||
|
||||
def generate_koji_tag(name, stream, version, context):
|
||||
def generate_koji_tag(name, stream, version, context, max_length=256):
|
||||
"""
|
||||
Generate a koji tag from name, stream, version and context.
|
||||
|
||||
@@ -101,14 +101,15 @@ def generate_koji_tag(name, stream, version, context):
|
||||
:param stream: a module's stream
|
||||
:param version: a module's version
|
||||
:param context: a module's context
|
||||
:kwarg max_length: the maximum length the Koji tag can be before falling back to
|
||||
the old format of "module-<hash>"
|
||||
:return: a Koji tag
|
||||
"""
|
||||
nsvc_list = [name, stream, str(version), context]
|
||||
nsvc_tag = 'module-' + '-'.join(nsvc_list)
|
||||
if len(nsvc_tag) + len('-build') > 256:
|
||||
# Koji supports tag names with a max length of 256, fallback
|
||||
# to the old way of 'module-<hash>' if the generated koji tag
|
||||
# name is too long
|
||||
if len(nsvc_tag) + len('-build') > max_length:
|
||||
# Fallback to the old format of 'module-<hash>' if the generated koji tag
|
||||
# name is longer than max_length
|
||||
nsvc_hash = hashlib.sha1('.'.join(nsvc_list)).hexdigest()[:16]
|
||||
return 'module-' + nsvc_hash
|
||||
return nsvc_tag
|
||||
|
||||
@@ -69,7 +69,10 @@ class FakeKojiModuleBuilder(KojiModuleBuilder):
|
||||
koji_session.createTag = _createTag
|
||||
|
||||
def _getBuildTarget(name):
|
||||
return {"build_tag_name": name + "-build", "dest_tag_name": name}
|
||||
return {
|
||||
"build_tag_name": self.module_build_tag['name'],
|
||||
"dest_tag_name": self.module_tag['name']
|
||||
}
|
||||
koji_session.getBuildTarget = _getBuildTarget
|
||||
|
||||
def _getAllPerms(*args, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user