def _resolve_modules(self, compose_source): koji_session = get_koji_session(self.workflow, fallback=NO_FALLBACK) resolved_modules = {} for module in compose_source.strip().split(): module_spec = ModuleSpec.from_str(module) build, rpm_list = get_koji_module_build(koji_session, module_spec) # The returned RPM list contains source RPMs and RPMs for all # architectures. rpms = ['{name}-{epochnum}:{version}-{release}.{arch}.rpm' .format(epochnum=rpm['epoch'] or 0, **rpm) for rpm in rpm_list] objects = Modulemd.objects_from_string( build['extra']['typeinfo']['module']['modulemd_str']) assert len(objects) == 1 mmd = objects[0] assert isinstance(mmd, Modulemd.Module) # Make sure we have a version 2 modulemd file mmd.upgrade() resolved_modules[module_spec.name] = ModuleInfo(module_spec.name, module_spec.stream, module_spec.version, mmd, rpms) return resolved_modules
def setup_flatpak_source_info(workflow, config=APP_CONFIG): compose = setup_flatpak_compose_info(workflow, config) flatpak_yaml = yaml.safe_load(config['container_yaml'])['flatpak'] module_spec = ModuleSpec.from_str(compose.source_spec) source = FlatpakSourceInfo(flatpak_yaml, compose.modules, compose.base_module, module_spec.profile) set_flatpak_source_info(workflow, source) return source
def _load_source(self): flatpak_yaml = self.workflow.source.config.flatpak compose_info = get_compose_info(self.workflow) if compose_info is None: raise RuntimeError( "resolve_module_compose must be run before flatpak_create_dockerfile") module_spec = ModuleSpec.from_str(compose_info.source_spec) return FlatpakSourceInfo(flatpak_yaml, compose_info.modules, compose_info.base_module, module_spec.profile)
def _resolve_compose(self): odcs_config = get_config(self.workflow).get_odcs_config() odcs_client = get_odcs_session(self.workflow, self.odcs_fallback) self.read_configs_general() modules = self.data.get('modules', []) if not modules: raise RuntimeError('"compose" config has no modules, a module is required for Flatpaks') source_spec = modules[0] if len(modules) > 1: self.log.info("compose config contains multiple modules," "using first module %s", source_spec) module = ModuleSpec.from_str(source_spec) self.log.info("Resolving module compose for name=%s, stream=%s, version=%s", module.name, module.stream, module.version) noprofile_spec = module.to_str(include_profile=False) if self.compose_ids: if len(self.compose_ids) > 1: self.log.info("Multiple compose_ids, using first compose %d", self.compose_ids[0]) self.compose_id = self.compose_ids[0] if self.signing_intent_name is not None: signing_intent_name = self.signing_intent_name else: signing_intent_name = self.data.get('signing_intent', odcs_config.default_signing_intent) signing_intent = odcs_config.get_signing_intent_by_name(signing_intent_name) if self.compose_id is None: arches = sorted(get_platforms(self.workflow)) self.compose_id = odcs_client.start_compose(source_type='module', source=noprofile_spec, sigkeys=signing_intent['keys'], arches=arches)['id'] compose_info = odcs_client.wait_for_compose(self.compose_id) if compose_info['state_name'] != "done": raise RuntimeError("Compose cannot be retrieved, state='%s'" % compose_info['state_name']) compose_source = compose_info['source'] self.log.info("Resolved list of modules: %s", compose_source) resolved_modules = self._resolve_modules(compose_source) base_module = resolved_modules[module.name] assert base_module.stream == module.stream if module.version is not None: assert base_module.version == module.version return ComposeInfo(source_spec=source_spec, compose_id=self.compose_id, base_module=base_module, modules=resolved_modules, repo_url=compose_info['result_repo'] + '/$basearch/os/', signing_intent=signing_intent_name, signing_intent_overridden=self.signing_intent_name is not None)
def test_module_spec_to_str(self, as_str, as_str_no_profile): spec = ModuleSpec.from_str(as_str) assert spec.to_str() == as_str assert spec.to_str(include_profile=False) == as_str_no_profile