mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-02-09 16:14:59 +08:00
Merge #841 Use Koji repos if possible during local builds
This commit is contained in:
1
Vagrantfile
vendored
1
Vagrantfile
vendored
@@ -15,6 +15,7 @@ $script = <<SCRIPT
|
||||
koji \
|
||||
krb5-workstation \
|
||||
libffi-devel \
|
||||
mock-scm \
|
||||
openssl-devel \
|
||||
python \
|
||||
python-devel \
|
||||
|
||||
@@ -43,6 +43,7 @@ from utils import (
|
||||
create_local_repo_from_koji_tag,
|
||||
execute_cmd,
|
||||
find_srpm,
|
||||
get_koji_config
|
||||
)
|
||||
from KojiModuleBuilder import KojiModuleBuilder
|
||||
from module_build_service.models import ModuleBuild
|
||||
@@ -308,12 +309,20 @@ class MockModuleBuilder(GenericBuilder):
|
||||
if repo_name.startswith("module-"):
|
||||
repo_name = repo_name[7:]
|
||||
repo_dir = tag
|
||||
baseurl = "file://" + repo_dir
|
||||
else:
|
||||
repo_name = tag
|
||||
repo_dir = os.path.join(self.config.cache_dir, "koji_tags", tag)
|
||||
create_local_repo_from_koji_tag(self.config, tag, repo_dir,
|
||||
[self.arch, "noarch"])
|
||||
baseurl = "file://" + repo_dir
|
||||
koji_config = get_koji_config(self.config)
|
||||
koji_session = koji.ClientSession(koji_config.server, opts=koji_config)
|
||||
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(self.config, tag, repo_dir,
|
||||
[self.arch, "noarch"])
|
||||
baseurl = "file://" + repo_dir
|
||||
self._add_repo(repo_name, baseurl)
|
||||
self._write_mock_config()
|
||||
|
||||
|
||||
@@ -49,6 +49,24 @@ def execute_cmd(args, stdout=None, stderr=None, cwd=None):
|
||||
return out, err
|
||||
|
||||
|
||||
def get_koji_config(mbs_config):
|
||||
"""
|
||||
Get the Koji config needed for MBS
|
||||
:param mbs_config: an MBS config object
|
||||
:return: a Munch object of the Koji config
|
||||
"""
|
||||
# Placed here to avoid py2/py3 conflicts...
|
||||
import koji
|
||||
|
||||
koji_config = munch.Munch(koji.read_config(
|
||||
profile_name=mbs_config.koji_profile,
|
||||
user_config=mbs_config.koji_config,
|
||||
))
|
||||
# Timeout after 10 minutes. The default is 12 hours.
|
||||
koji_config["timeout"] = 60 * 10
|
||||
return koji_config
|
||||
|
||||
|
||||
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',
|
||||
@@ -63,13 +81,7 @@ def create_local_repo_from_koji_tag(config, tag, repo_dir, archs=None):
|
||||
archs = ["x86_64", "noarch"]
|
||||
|
||||
# Load koji config and create Koji session.
|
||||
koji_config = munch.Munch(koji.read_config(
|
||||
profile_name=config.koji_profile,
|
||||
user_config=config.koji_config,
|
||||
))
|
||||
# Timeout after 10 minutes. The default is 12 hours.
|
||||
koji_config["timeout"] = 60 * 10
|
||||
|
||||
koji_config = get_koji_config(config)
|
||||
address = koji_config.server
|
||||
log.info("Connecting to koji %r" % address)
|
||||
session = koji.ClientSession(address, opts=koji_config)
|
||||
|
||||
Reference in New Issue
Block a user