Update koji tagging for scratch modules.

Signed-off-by: Merlin Mathesius <mmathesi@redhat.com>
This commit is contained in:
Merlin Mathesius
2019-02-07 14:13:28 -06:00
parent 7794950802
commit dd950857ec
7 changed files with 26 additions and 13 deletions

View File

@@ -31,7 +31,7 @@ class BaseConfiguration(object):
ARCHES = ['i686', 'armv7hl', 'x86_64']
ALLOW_ARCH_OVERRIDE = False
KOJI_REPOSITORY_URL = 'https://kojipkgs.fedoraproject.org/repos'
KOJI_TAG_PREFIXES = ['module']
KOJI_TAG_PREFIXES = ['module', 'scrmod']
KOJI_ENABLE_CONTENT_GENERATOR = True
CHECK_FOR_EOL = False
PDC_URL = 'https://pdc.fedoraproject.org/rest_api/v1'

View File

@@ -1201,9 +1201,10 @@ chmod 644 %buildroot/etc/rpm/macros.zz-modules
return list(nvrs)
def finalize(self):
# Only import to koji CG if the module is "build".
if self.config.koji_enable_content_generator and \
self.module.state == models.BUILD_STATES['build']:
# Only import to koji CG if the module is "build" and not scratch.
if (not self.module.scratch and
self.config.koji_enable_content_generator and
self.module.state == models.BUILD_STATES['build']):
cg = KojiContentGenerator(self.module, self.config)
cg.koji_import()
if conf.koji_cg_devel_module:
@@ -1227,7 +1228,7 @@ chmod 644 %buildroot/etc/rpm/macros.zz-modules
tags = []
koji_tags = session.listTags(rpm_md["build_id"])
for t in koji_tags:
if not t["name"].endswith("-build") and t["name"].startswith("module-"):
if not t["name"].endswith("-build") and t["name"].startswith(("module-", "scrmod-")):
tags.append(t["name"])
return tags

View File

@@ -318,6 +318,7 @@ class MockModuleBuilder(GenericBuilder):
# module build repository.
if tag.startswith(conf.mock_resultsdir):
repo_name = os.path.basename(tag)
# TODO scrmod: is a check also needed for scratch module tag prefix?
if repo_name.startswith("module-"):
repo_name = repo_name[7:]
repo_dir = tag

View File

@@ -197,7 +197,7 @@ class Config(object):
'desc': 'Target to build "module-build-macros" RPM in.'},
'koji_tag_prefixes': {
'type': list,
'default': ['module'],
'default': ['module', 'scrmod'],
'desc': 'List of allowed koji tag prefixes.'},
'koji_target_delete_time': {
'type': int,

View File

@@ -183,7 +183,8 @@ def generate_module_build_koji_tag(build):
"""
log.info('Getting tag for %s:%s:%s', build.name, build.stream, build.version)
if conf.system in ['koji', 'test']:
return generate_koji_tag(build.name, build.stream, build.version, build.context)
return generate_koji_tag(build.name, build.stream, build.version, build.context,
scratch=build.scratch)
else:
return '-'.join(['module', build.name, build.stream, build.version])
@@ -295,7 +296,10 @@ def wait(config, session, msg):
log.debug("Assigning koji tag=%s to module build" % tag)
build.koji_tag = tag
if conf.koji_cg_tag_build:
if build.scratch:
log.debug('Assigning Content Generator build koji tag is skipped for'
' scratch module build.')
elif conf.koji_cg_tag_build:
cg_build_koji_tag = get_content_generator_build_koji_tag(build_deps)
log.debug("Assigning Content Generator build koji tag=%s to module build",
cg_build_koji_tag)

View File

@@ -105,7 +105,7 @@ def module_build_state_from_msg(msg):
return state
def generate_koji_tag(name, stream, version, context, max_length=256):
def generate_koji_tag(name, stream, version, context, max_length=256, scratch=False):
"""Generate a koji tag for a module
Generally, a module's koji tag is in format ``module-N-S-V-C``. However, if
@@ -115,19 +115,23 @@ def generate_koji_tag(name, stream, version, context, max_length=256):
:param str stream: a module's stream
:param str version: a module's version
:param str context: a module's context
:kwarg int max_length: the maximum length the Koji tag can be before
:param int max_length: the maximum length the Koji tag can be before
falling back to the old format of "module-<hash>". Default is 256
characters, which is the maximum length of a tag Koji accepts.
:param bool scratch: a flag indicating if the generated tag will be for
a scratch module build
:return: a Koji tag
:rtype: str
"""
prefix = ('scrmod' if scratch else 'module')
# TODO scrmod: is a unique _suffix_ needed here, too?
nsvc_list = [name, stream, str(version), context]
nsvc_tag = 'module-' + '-'.join(nsvc_list)
nsvc_tag = '-'.join([prefix] + nsvc_list)
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).encode('utf-8')).hexdigest()[:16]
return 'module-' + nsvc_hash
return prefix + '-' + nsvc_hash
return nsvc_tag
@@ -207,6 +211,9 @@ def validate_koji_tag(tag_arg_names, pre='', post='-', dict_key='name'):
return validation_decorator
# TODO scrmod: scratch module build components need a unique dist tag prefix/suffix
# to distinguish them and make it possible to build the same NSVC multiple times,
# but what should it be? Is this the place to set that?
def get_rpm_release(module_build):
"""
Generates the dist tag for the specified module

View File

@@ -127,7 +127,7 @@ objects:
RESOLVER = 'db'
# This is a whitelist of prefixes of koji tags we're allowed to manipulate
KOJI_TAG_PREFIXES = ["module"]
KOJI_TAG_PREFIXES = ["module", "scrmod"]
DEFAULT_DIST_TAG_PREFIX = 'module'