From ce9ac35640b95102028b70cafef13c16ad05bd11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Fri, 5 Oct 2018 11:02:04 +0200 Subject: [PATCH] hybrid: Only include modules that are not in lookaside MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If we want to include the -devel modules, the original modules should be present for the solver. However if we put them in both local and lookaside repos, fus will get confused. Let's not include modules that are in lookaside in the module repo created for the solving job. Even if the modular packages are present in the local repo, they are identical to the ones in lookaside, and so they should not make it into the result anyway. Signed-off-by: Lubomír Sedlář --- pungi/phases/gather/methods/method_hybrid.py | 41 +++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/pungi/phases/gather/methods/method_hybrid.py b/pungi/phases/gather/methods/method_hybrid.py index dcabb80f..e0f86ac5 100644 --- a/pungi/phases/gather/methods/method_hybrid.py +++ b/pungi/phases/gather/methods/method_hybrid.py @@ -18,6 +18,7 @@ import os from kobo.shortcuts import run import kobo.rpmlib from fnmatch import fnmatch +import gzip import pungi.phases.gather.method from pungi import Modulemd, multilib_dnf @@ -283,6 +284,33 @@ class GatherMethodHybrid(pungi.phases.gather.method.GatherMethodBase): return sorted(added) +def get_lookaside_modules(lookasides): + """Get list of NSVC of all modules in all lookaside repos.""" + modules = set() + for repo in lookasides: + repo = fus._prep_path(repo) + repomd = cr.Repomd(os.path.join(repo, "repodata/repomd.xml")) + for rec in repomd.records: + if rec.type != "modules": + continue + with gzip.GzipFile(os.path.join(repo, rec.location_href), "r") as f: + # This can't use _from_stream, since gobject-introspection + # refuses to pass a file object. + mmds = Modulemd.objects_from_string(f.read()) + for mmd in mmds: + if isinstance(mmd, Modulemd.Module): + modules.add( + "%s:%s:%s:%s" + % ( + mmd.peek_name(), + mmd.peek_stream(), + mmd.peek_version(), + mmd.peek_context(), + ) + ) + return modules + + def create_module_repo(compose, variant, arch): """Create repository with module metadata. There are no packages otherwise.""" createrepo_c = compose.conf["createrepo_c"] @@ -299,6 +327,10 @@ def create_module_repo(compose, variant, arch): repo_path = compose.paths.work.module_repo(arch, variant) + lookaside_modules = get_lookaside_modules( + pungi.phases.gather.get_lookaside_repos(compose, arch, variant) + ) + # Add modular metadata to it modules = [] @@ -312,7 +344,14 @@ def create_module_repo(compose, variant, arch): if streams: platforms.update(streams.dup()) - modules.append(repo_mmd) + nsvc = "%s:%s:%s:%s" % ( + repo_mmd.peek_name(), + repo_mmd.peek_stream(), + repo_mmd.peek_version(), + repo_mmd.peek_context(), + ) + if nsvc not in lookaside_modules: + modules.append(repo_mmd) if len(platforms) > 1: raise RuntimeError("There are conflicting requests for platform.")