Stop adding repo entries for empty tags for local builds

DNF fails on Fedora 31 when there is a repo entry to an empty directory.
This commit is contained in:
mprahl
2019-11-07 11:14:44 -05:00
parent be641dee57
commit 1160d47e7a
2 changed files with 16 additions and 4 deletions

View File

@@ -373,18 +373,22 @@ class MockModuleBuilder(GenericBuilder):
repo_name = tag = source
koji_config = get_koji_config(self.config)
koji_session = koji.ClientSession(koji_config.server, opts=koji_config)
# Check to see if there are any external repos tied to the tag
for ext_repo in koji_session.getTagExternalRepos(tag):
self._add_repo(ext_repo["external_repo_name"], ext_repo["url"])
repo = koji_session.getRepo(repo_name)
if repo:
baseurl = koji.PathInfo(topdir=koji_config.topurl).repo(repo["id"], repo_name)
baseurl = "{0}/{1}/".format(baseurl, self.arch)
else:
repo_dir = os.path.join(self.config.cache_dir, "koji_tags", tag)
create_local_repo_from_koji_tag(
should_add_repo = create_local_repo_from_koji_tag(
self.config, tag, repo_dir, [self.arch, "noarch"])
if not should_add_repo:
continue
baseurl = "file://" + repo_dir
# Check to see if there are any external repos tied to the tag
for ext_repo in koji_session.getTagExternalRepos(repo_name):
self._add_repo(ext_repo["external_repo_name"], ext_repo["url"])
self._add_repo(repo_name, baseurl)
self._write_mock_config()

View File

@@ -72,6 +72,8 @@ def create_local_repo_from_koji_tag(config, tag, repo_dir, archs=None):
Downloads the packages build for one of `archs` (defaults to ['x86_64',
'noarch']) in Koji tag `tag` to `repo_dir` and creates repository in that
directory. Needs config.koji_profile and config.koji_config to be set.
If the there are no builds associated with the tag, False is returned.
"""
# Placed here to avoid py2/py3 conflicts...
@@ -92,6 +94,10 @@ def create_local_repo_from_koji_tag(config, tag, repo_dir, archs=None):
except koji.GenericError:
log.exception("Failed to list rpms in tag %r" % tag)
if not builds:
log.debug("No builds are associated with the tag %r", tag)
return False
# Reformat builds so they are dict with build_id as a key.
builds = {build["build_id"]: build for build in builds}
@@ -162,3 +168,5 @@ def create_local_repo_from_koji_tag(config, tag, repo_dir, archs=None):
log.info("Creating local repository in %s" % repo_dir)
execute_cmd(["/usr/bin/createrepo_c", repo_dir])
return True