#1332 MockModuleBuilder.py: Fix for libmodulemd v2
Closed 4 years ago by mprahl. Opened 4 years ago by otaylor.
otaylor/fm-orchestrator mockbuild-libmodulemd-v2  into  master

@@ -32,7 +32,7 @@ 

  import subprocess

  import threading

  

- from module_build_service import conf, log

+ from module_build_service import conf, log, Modulemd

  import module_build_service.scm

  import module_build_service.utils

  import module_build_service.scheduler
@@ -231,7 +231,10 @@ 

          # ...and inject modules.yaml there if asked.

          if include_module_yaml:

              mmd_path = os.path.join(path, "modules.yaml")

-             m1_mmd.dump(mmd_path)

+             mmd_index = Modulemd.ModuleIndex.new()

Could you please reuse module_build_service.utils.general.mmd_to_str?

+             mmd_index.add_module_stream(m1_mmd)

+             with open(mmd_path, "w") as f:

+                 f.write(mmd_index.dump_to_string())

              execute_cmd(["/usr/bin/modifyrepo_c", "--mdtype=modules", mmd_path, repodata_path])

  

      def _add_repo(self, name, baseurl, extra=""):

With v2 of the libmodulemd API, writing a module to a string requires
creating a Modulemd.ModuleIndex object.

@otaylor When I tried the API, I got error

gi.repository.GLib.GError: modulemd-error-quark: The module and stream names are required when adding to ModuleIndex. (5)

at line https://pagure.io/fm-orchestrator/pull-request/1332#_1__16

I'm not familiar with the libmodulemd v2 API, anything I missed?

Could you please reuse module_build_service.utils.general.mmd_to_str?

Since I'd like to get a release out with this fix today, I created a PR with an additional commit based on my comment at #1349.

Pull-Request has been closed by mprahl

4 years ago