| |
@@ -90,6 +90,7 @@
|
| |
self.tag_name = tag_name
|
| |
self.config = config
|
| |
self.groups = []
|
| |
+ self.enabled_modules = []
|
| |
self.yum_conf = MockModuleBuilder.yum_config_template
|
| |
self.koji_session = None
|
| |
|
| |
@@ -170,8 +171,7 @@
|
| |
pkglist_f = open(pkglist, "w")
|
| |
|
| |
# Generate the mmd the same way as pungi does.
|
| |
- m1 = models.ModuleBuild.query.filter(models.ModuleBuild.name == self.module_str).one()
|
| |
- m1_mmd = m1.mmd()
|
| |
+ m1_mmd = self.module.mmd()
|
| |
artifacts = Modulemd.SimpleSet()
|
| |
|
| |
rpm_files = [f
|
| |
@@ -192,7 +192,7 @@
|
| |
for rpm_file, nevra in zip(rpm_files, nevras):
|
| |
name, epoch, version, release, arch = nevra.split()
|
| |
|
| |
- if m1.last_batch_id() == m1.batch:
|
| |
+ if self.module.last_batch_id() == self.module.batch:
|
| |
# If RPM is filtered-out, do not add it to artifacts list.
|
| |
if name in m1_mmd.get_rpm_filter().get():
|
| |
continue
|
| |
@@ -223,6 +223,14 @@
|
| |
self.yum_conf += extra
|
| |
self.yum_conf += "enabled=1\n\n"
|
| |
|
| |
+ def _add_repo_from_path(self, path):
|
| |
+ """
|
| |
+ Adds repository stored in `path` to Mock config file. Call _write_mock_config() to
|
| |
+ actually write the config file to filesystem.
|
| |
+ """
|
| |
+ with open(path) as fd:
|
| |
+ self.yum_conf += fd.read()
|
| |
+
|
| |
def _load_mock_config(self):
|
| |
"""
|
| |
Loads the variables which are generated only during the first
|
| |
@@ -248,6 +256,7 @@
|
| |
|
| |
self.groups = config_opts["chroot_setup_cmd"].split(" ")[1:]
|
| |
self.yum_conf = config_opts['yum.conf']
|
| |
+ self.enabled_modules = config_opts['module_enable']
|
| |
|
| |
def _write_mock_config(self):
|
| |
"""
|
| |
@@ -261,6 +270,7 @@
|
| |
config = config.replace("$arch", self.arch)
|
| |
config = config.replace("$group", " ".join(self.groups))
|
| |
config = config.replace("$yum_conf", self.yum_conf)
|
| |
+ config = config.replace("$enabled_modules", str(self.enabled_modules))
|
| |
|
| |
# We write the most recent config to "mock.cfg", so thread-related
|
| |
# configs can be later (re-)generated from it using _load_mock_config.
|
| |
@@ -313,17 +323,36 @@
|
| |
|
| |
def buildroot_add_repos(self, dependencies):
|
| |
self._load_mock_config()
|
| |
- for tag in dependencies:
|
| |
- # If tag starts with mock_resultdir, it means it is path to local
|
| |
+ for source, mmds in dependencies.items():
|
| |
+ # If source starts with mock_resultdir, it means it is path to local
|
| |
# module build repository.
|
| |
- if tag.startswith(conf.mock_resultsdir):
|
| |
- repo_name = os.path.basename(tag)
|
| |
+ if source.startswith(conf.mock_resultsdir):
|
| |
+ repo_name = os.path.basename(source)
|
| |
if repo_name.startswith("module-"):
|
| |
repo_name = repo_name[7:]
|
| |
- repo_dir = tag
|
| |
+ repo_dir = source
|
| |
baseurl = "file://" + repo_dir
|
| |
+ # If source starts with "repofile://", it is path to local /etc/yum.repos.d
|
| |
+ # repo file.
|
| |
+ elif source.startswith("repofile://"):
|
| |
+ # For the base module, we want to include all the `conf.base_module_repofiles`.
|
| |
+ if len(mmds) == 1 and mmds[0].get_name() in conf.base_module_names:
|
| |
+ for repofile in conf.base_module_repofiles:
|
| |
+ self._add_repo_from_path(repofile)
|
| |
+ # Also set the platform_id.
|
| |
+ mmd = mmds[0]
|
| |
+ self.yum_conf = self.yum_conf.replace(
|
| |
+ "$module_platform_id", "%s:%s" % (mmd.get_name(), mmd.get_stream()))
|
| |
+ else:
|
| |
+ # Add repositories defined in repofile to mock config.
|
| |
+ repofile = source[len("repofile://"):]
|
| |
+ self._add_repo_from_path(repofile)
|
| |
+ # Enabled all the modular dependencies by default in Mock.
|
| |
+ for mmd in mmds:
|
| |
+ self.enabled_modules.append("%s:%s" % (mmd.get_name(), mmd.get_stream()))
|
| |
+ continue
|
| |
else:
|
| |
- repo_name = tag
|
| |
+ repo_name = tag = source
|
| |
koji_config = get_koji_config(self.config)
|
| |
koji_session = koji.ClientSession(koji_config.server, opts=koji_config)
|
| |
repo = koji_session.getRepo(repo_name)
|
| |
@@ -517,6 +546,25 @@
|
| |
if self.module.state == models.BUILD_STATES["done"]:
|
| |
self._createrepo(include_module_yaml=True)
|
| |
|
| |
+ @classmethod
|
| |
+ def get_built_rpms_in_module_build(cls, mmd):
|
| |
+ """
|
| |
+ :param Modulemd mmd: Modulemd to get the built RPMs from.
|
| |
+ :return: list of NVRs
|
| |
+ """
|
| |
+ with models.make_session(conf) as db_session:
|
| |
+ build = models.ModuleBuild.get_build_from_nsvc(
|
| |
+ db_session, mmd.get_name(), mmd.get_stream(), mmd.get_version(),
|
| |
+ mmd.get_context())
|
| |
+ if build.koji_tag.startswith("repofile://"):
|
| |
+ # Modules from local repository have already the RPMs filled in mmd.
|
| |
+ return list(mmd.get_rpm_artifacts().get())
|
| |
+ else:
|
| |
+ koji_session = KojiModuleBuilder.get_session(conf, login=False)
|
| |
+ rpms = koji_session.listTaggedRPMS(build.koji_tag, latest=True)[0]
|
| |
+ nvrs = set(kobo.rpmlib.make_nvr(rpm, force_epoch=True) for rpm in rpms)
|
| |
+ return list(nvrs)
|
| |
+
|
| |
|
| |
class BaseBuilder(object):
|
| |
def __init__(self, config, resultsdir):
|
| |
@@ -540,9 +588,14 @@
|
| |
def __init__(self, config, resultsdir, source, artifact_name):
|
| |
super(SCMBuilder, self).__init__(config, resultsdir)
|
| |
with open(config, "a") as f:
|
| |
- branch = source.split("?#")[1]
|
| |
+ git_repo, branch = source.split("?#")
|
| |
distgit_cmds = self._get_distgit_commands(source)
|
| |
- distgit_get = distgit_cmds[0].format(artifact_name)
|
| |
+
|
| |
+ if source.startswith("file://"):
|
| |
+ # For local git repositories, pass the full path to repository to git command.
|
| |
+ distgit_get = distgit_cmds[0].format(git_repo)
|
| |
+ else:
|
| |
+ distgit_get = distgit_cmds[0].format(artifact_name)
|
| |
|
| |
# mock-scm cannot checkout particular commit hash, but only branch.
|
| |
# We therefore use a command that combines the distgit-command with
|
| |
@@ -562,10 +615,23 @@
|
| |
artifact_name),
|
| |
"config_opts['scm_opts']['distgit_get'] = {!r}\n".format(
|
| |
distgit_get_branch),
|
| |
- "config_opts['scm_opts']['distgit_src_get'] = '{}'\n".format(
|
| |
- distgit_cmds[1]),
|
| |
])
|
| |
|
| |
+ # Set distgit_src_get only if it's defined.
|
| |
+ if distgit_cmds[1]:
|
| |
+ f.write("config_opts['scm_opts']['distgit_src_get'] = '{}'\n".format(
|
| |
+ distgit_cmds[1]))
|
| |
+
|
| |
+ # The local git repositories cloned by `fedpkg clone` typically do not have
|
| |
+ # the tarballs with sources committed in a git repo. They normally live in lookaside
|
| |
+ # cache on remote server, but we should not try getting them from there for true
|
| |
+ # local builds.
|
| |
+ # Instead, get them from local path with git repository by passing that path to Mock
|
| |
+ # using the `ext_src_dir`.
|
| |
+ if git_repo.startswith("file://"):
|
| |
+ src_dir = git_repo[len("file://"):]
|
| |
+ f.write("config_opts['scm_opts']['ext_src_dir'] = '{}'\n".format(src_dir))
|
| |
+
|
| |
def _make_executable(self, path):
|
| |
mode = os.stat(path).st_mode
|
| |
mode |= (mode & 0o444) >> 2 # copy R bits to X
|
| |
All the commits have been reviewed separately when gated to "offline-builds" branch.
This is just asking for +1 to merge "offline-builds" to "master".