| |
@@ -185,6 +185,43 @@
|
| |
# This seems to only affect createrepo_c though.
|
| |
repo_dir_arch = None
|
| |
|
| |
+ # inject modulemd if needed
|
| |
+ metadata = []
|
| |
+ if pkg_type == "rpm" and arch in variant.arch_mmds and Modulemd is not None:
|
| |
+ mod_index = Modulemd.ModuleIndex()
|
| |
+
|
| |
+ for module_id, mmd in variant.arch_mmds.get(arch, {}).items():
|
| |
+ if modules_metadata:
|
| |
+ module_rpms = mmd.get_rpm_artifacts()
|
| |
+ metadata.append((module_id, module_rpms))
|
| |
+ mod_index.add_module_stream(mmd)
|
| |
+
|
| |
+ module_names = set(mod_index.get_module_names())
|
| |
+ defaults_dir = compose.paths.work.module_defaults_dir()
|
| |
+ overrides_dir = compose.conf.get("module_defaults_override_dir")
|
| |
+ collect_module_defaults(
|
| |
+ defaults_dir, module_names, mod_index, overrides_dir=overrides_dir
|
| |
+ )
|
| |
+
|
| |
+ # Add extra modulemd files
|
| |
+ if variant.uid in compose.conf.get("createrepo_extra_modulemd", {}):
|
| |
+ compose.log_debug("Adding extra modulemd for %s.%s", variant.uid, arch)
|
| |
+ dirname = compose.paths.work.tmp_dir(variant=variant, create_dir=False)
|
| |
+ for filepath in glob.glob(os.path.join(dirname, arch) + "/*.yaml"):
|
| |
+ module_stream = Modulemd.ModuleStream.read_file(filepath, strict=True)
|
| |
+ if not mod_index.add_module_stream(module_stream):
|
| |
+ raise RuntimeError(
|
| |
+ "Failed parsing modulemd data from %s" % filepath
|
| |
+ )
|
| |
+ # Add the module to metadata with dummy tag. We can't leave the
|
| |
+ # value empty, but we don't know what the correct tag is.
|
| |
+ nsvc = module_stream.get_nsvc()
|
| |
+ variant.module_uid_to_koji_tag[nsvc] = "DUMMY"
|
| |
+ metadata.append((nsvc, []))
|
| |
+
|
| |
+ log_file = compose.paths.log.log_file(arch, "modifyrepo-modules-%s" % variant)
|
| |
+ add_modular_metadata(repo_dir, mod_index)
|
| |
+
|
| |
comps_path = None
|
| |
if compose.has_comps and pkg_type == "rpm":
|
| |
comps_path = compose.paths.work.comps(arch=arch, variant=variant)
|
| |
@@ -204,11 +241,29 @@
|
| |
use_xz=compose.conf["createrepo_use_xz"],
|
| |
extra_args=compose.conf["createrepo_extra_args"],
|
| |
)
|
| |
+
|
| |
+ print cmd
|
| |
+
|
| |
log_file = compose.paths.log.log_file(
|
| |
arch, "createrepo-%s.%s" % (variant, pkg_type)
|
| |
)
|
| |
run(cmd, logfile=log_file, show_cmd=True)
|
| |
|
| |
+ for module_id, module_rpms in metadata:
|
| |
+ modulemd_path = os.path.join(
|
| |
+ types[pkg_type][1](relative=True),
|
| |
+ find_file_in_repodata(repo_dir, "modules"),
|
| |
+ )
|
| |
+ modules_metadata.prepare_module_metadata(
|
| |
+ variant,
|
| |
+ arch,
|
| |
+ module_id,
|
| |
+ modulemd_path,
|
| |
+ types[pkg_type][0],
|
| |
+ list(module_rpms),
|
| |
+ )
|
| |
+
|
| |
+
|
| |
# call modifyrepo to inject productid
|
| |
product_id = compose.conf.get("product_id")
|
| |
if product_id and pkg_type == "rpm":
|
| |
@@ -227,78 +282,18 @@
|
| |
product_id_path, os.path.join(repo_dir, "repodata", "productid")
|
| |
)
|
| |
|
| |
- # call modifyrepo to inject modulemd if needed
|
| |
- if pkg_type == "rpm" and arch in variant.arch_mmds and Modulemd is not None:
|
| |
- mod_index = Modulemd.ModuleIndex()
|
| |
- metadata = []
|
| |
-
|
| |
- for module_id, mmd in variant.arch_mmds.get(arch, {}).items():
|
| |
- if modules_metadata:
|
| |
- module_rpms = mmd.get_rpm_artifacts()
|
| |
- metadata.append((module_id, module_rpms))
|
| |
- mod_index.add_module_stream(mmd)
|
| |
-
|
| |
- module_names = set(mod_index.get_module_names())
|
| |
- defaults_dir = compose.paths.work.module_defaults_dir()
|
| |
- overrides_dir = compose.conf.get("module_defaults_override_dir")
|
| |
- collect_module_defaults(
|
| |
- defaults_dir, module_names, mod_index, overrides_dir=overrides_dir
|
| |
- )
|
| |
-
|
| |
- # Add extra modulemd files
|
| |
- if variant.uid in compose.conf.get("createrepo_extra_modulemd", {}):
|
| |
- compose.log_debug("Adding extra modulemd for %s.%s", variant.uid, arch)
|
| |
- dirname = compose.paths.work.tmp_dir(variant=variant, create_dir=False)
|
| |
- for filepath in glob.glob(os.path.join(dirname, arch) + "/*.yaml"):
|
| |
- module_stream = Modulemd.ModuleStream.read_file(filepath, strict=True)
|
| |
- if not mod_index.add_module_stream(module_stream):
|
| |
- raise RuntimeError(
|
| |
- "Failed parsing modulemd data from %s" % filepath
|
| |
- )
|
| |
- # Add the module to metadata with dummy tag. We can't leave the
|
| |
- # value empty, but we don't know what the correct tag is.
|
| |
- nsvc = module_stream.get_nsvc()
|
| |
- variant.module_uid_to_koji_tag[nsvc] = "DUMMY"
|
| |
- metadata.append((nsvc, []))
|
| |
-
|
| |
- log_file = compose.paths.log.log_file(arch, "modifyrepo-modules-%s" % variant)
|
| |
- add_modular_metadata(repo, repo_dir, mod_index, log_file)
|
| |
-
|
| |
- for module_id, module_rpms in metadata:
|
| |
- modulemd_path = os.path.join(
|
| |
- types[pkg_type][1](relative=True),
|
| |
- find_file_in_repodata(repo_dir, "modules"),
|
| |
- )
|
| |
- modules_metadata.prepare_module_metadata(
|
| |
- variant,
|
| |
- arch,
|
| |
- module_id,
|
| |
- modulemd_path,
|
| |
- types[pkg_type][0],
|
| |
- list(module_rpms),
|
| |
- )
|
| |
-
|
| |
compose.log_info("[DONE ] %s" % msg)
|
| |
|
| |
|
| |
- def add_modular_metadata(repo, repo_path, mod_index, log_file):
|
| |
+ def add_modular_metadata(repo_path, mod_index):
|
| |
"""Add modular metadata into a repository."""
|
| |
# Dumping empty index fails, we need to check for that.
|
| |
if not mod_index.get_module_names():
|
| |
return
|
| |
|
| |
- with temp_dir() as tmp_dir:
|
| |
- modules_path = os.path.join(tmp_dir, "modules.yaml")
|
| |
- with open(modules_path, "w") as f:
|
| |
- f.write(mod_index.dump_to_string())
|
| |
-
|
| |
- cmd = repo.get_modifyrepo_cmd(
|
| |
- os.path.join(repo_path, "repodata"),
|
| |
- modules_path,
|
| |
- mdtype="modules",
|
| |
- compress_type="gz",
|
| |
- )
|
| |
- run(cmd, logfile=log_file, show_cmd=True)
|
| |
+ modules_path = os.path.join(repo_path, "modules.yaml")
|
| |
+ with open(modules_path, "w") as f:
|
| |
+ f.write(mod_index.dump_to_string())
|
| |
|
| |
|
| |
def find_file_in_repodata(repo_path, type_):
|
| |
Createrepo_c now has support for libmodulemd. It can create a repo with modular metadata in one invocation. Modify createrepo phase in Pungi so that we don't need a separate modifyrepo_c call to include the metadata.