def _get_flatpak_labels(self, module): module_name, module_stream, _ = utils.split_module_spec(module) return { utils.Labels.LABEL_TYPE_NAME: module_name, utils.Labels.LABEL_TYPE_COMPONENT: module_name, utils.Labels.LABEL_TYPE_VERSION: module_stream }, self.build_conf.get_flatpak_base_image()
def handler(self, src, target, opts=None): if not opts: opts = {} self.opts = opts data = {} self.event_id = self.session.getLastEvent()['id'] target_info = self.session.getBuildTarget(target, event=self.event_id) build_tag = target_info['build_tag'] archlist = self.getArchList(build_tag) flatpak = opts.get('flatpak', False) if flatpak: if not osbs_flatpak_support: raise koji.BuildError( "osbs-client on koji builder doesn't have Flatpak support") module = opts.get('module', None) if not module: raise koji.BuildError( "Module must be specified for a Flatpak build") module_name, module_stream, module_version = split_module_spec( module) data = { 'name': module_name, 'version': module_stream, } if module_version is not None: data['release'] = module_version release_overwrite = None else: label_overwrites = {} release_overwrite = opts.get('release') if release_overwrite: label_overwrites = { LABEL_DATA_MAP['RELEASE']: release_overwrite } data, expected_nvr = self.checkLabels( src, label_overwrites=label_overwrites, build_tag=build_tag) admin_opts = self._get_admin_opts(opts) data.update(admin_opts) # scratch builds do not get imported, and consequently not tagged if not self.opts.get('scratch'): self.check_whitelist(data[LABEL_DATA_MAP['COMPONENT']], target_info) try: # Flatpak builds append .<N> to the release generated from module version if flatpak: auto_release = True else: auto_release = (data[LABEL_DATA_MAP['RELEASE']] == LABEL_DEFAULT_VALUES['RELEASE']) if auto_release: # Do not expose default release value del data[LABEL_DATA_MAP['RELEASE']] self.extra_information = { "src": src, "data": data, "target": target } if not SCM.is_scm_url(src): raise koji.BuildError('Invalid source specification: %s' % src) # Scratch and auto release builds shouldn't be checked for nvr if not self.opts.get('scratch') and not auto_release: try: build_id = self.session.getBuild(expected_nvr)['id'] except: self.logger.info("No build for %s found", expected_nvr, exc_info=True) else: raise koji.BuildError( "Build for %s already exists, id %s" % (expected_nvr, build_id)) results = self.runBuilds( src, target_info, archlist, scratch=opts.get('scratch', False), isolated=opts.get('isolated', False), yum_repourls=opts.get('yum_repourls', None), branch=opts.get('git_branch', None), push_url=opts.get('push_url', None), koji_parent_build=opts.get('koji_parent_build'), release=release_overwrite, flatpak=flatpak, module=opts.get('module', None), compose_ids=opts.get('compose_ids', None), signing_intent=opts.get('signing_intent', None), ) all_repositories = [] all_koji_builds = [] for result in results: try: repository = result.get('repositories') all_repositories.extend(repository) except Exception, error: self.logger.error( "Failed to merge list of repositories " "%r. Reason (%s): %s", repository, type(error), error) koji_build_id = result.get('koji_build_id') if koji_build_id: all_koji_builds.append(koji_build_id) except (SystemExit, ServerExit, KeyboardInterrupt): # we do not trap these raise except: # reraise the exception raise return { 'repositories': all_repositories, 'koji_builds': all_koji_builds, }
def test_split_module_spec(module, should_raise, expected): if should_raise: with pytest.raises(OsbsValidationException): split_module_spec(module) else: assert split_module_spec(module) == expected
def handler(self, src, target, opts=None): if not opts: opts = {} self.opts = opts data = {} self.event_id = self.session.getLastEvent()['id'] target_info = self.session.getBuildTarget(target, event=self.event_id) build_tag = target_info['build_tag'] archlist = self.getArchList(build_tag) flatpak = opts.get('flatpak', False) if flatpak: if not osbs_flatpak_support: raise koji.BuildError("osbs-client on koji builder doesn't have Flatpak support") module = opts.get('module', None) if not module: raise koji.BuildError("Module must be specified for a Flatpak build") module_name, module_stream, module_version = split_module_spec(module) data = { 'name': module_name, 'version': module_stream, } if module_version is not None: data['release'] = module_version release_overwrite = None else: label_overwrites = {} release_overwrite = opts.get('release') if release_overwrite: label_overwrites = {LABEL_DATA_MAP['RELEASE']: release_overwrite} data, expected_nvr = self.checkLabels(src, label_overwrites=label_overwrites, build_tag=build_tag) admin_opts = self._get_admin_opts(opts) data.update(admin_opts) # scratch builds do not get imported, and consequently not tagged if not self.opts.get('scratch'): self.check_whitelist(data[LABEL_DATA_MAP['COMPONENT']], target_info) try: # Flatpak builds append .<N> to the release generated from module version if flatpak: auto_release = True else: auto_release = (data[LABEL_DATA_MAP['RELEASE']] == LABEL_DEFAULT_VALUES['RELEASE']) if auto_release: # Do not expose default release value del data[LABEL_DATA_MAP['RELEASE']] self.extra_information = {"src": src, "data": data, "target": target} if not SCM.is_scm_url(src): raise koji.BuildError('Invalid source specification: %s' % src) # Scratch and auto release builds shouldn't be checked for nvr if not self.opts.get('scratch') and not auto_release: try: build_id = self.session.getBuild(expected_nvr)['id'] except: self.logger.info("No build for %s found", expected_nvr, exc_info=True) else: raise koji.BuildError( "Build for %s already exists, id %s" % (expected_nvr, build_id)) results = self.runBuilds(src, target_info, archlist, scratch=opts.get('scratch', False), isolated=opts.get('isolated', False), yum_repourls=opts.get('yum_repourls', None), branch=opts.get('git_branch', None), push_url=opts.get('push_url', None), koji_parent_build=opts.get('koji_parent_build'), release=release_overwrite, flatpak=flatpak, module=opts.get('module', None), compose_ids=opts.get('compose_ids', None), signing_intent=opts.get('signing_intent', None), ) all_repositories = [] all_koji_builds = [] for result in results: try: repository = result.get('repositories') all_repositories.extend(repository) except Exception, error: self.logger.error("Failed to merge list of repositories " "%r. Reason (%s): %s", repository, type(error), error) koji_build_id = result.get('koji_build_id') if koji_build_id: all_koji_builds.append(koji_build_id) except (SystemExit, ServerExit, KeyboardInterrupt): # we do not trap these raise except: # reraise the exception raise return { 'repositories': all_repositories, 'koji_builds': all_koji_builds, }