def run(self): """ run the plugin """ if (self.workflow.builder.dockerfile_images.base_from_scratch and not self.workflow.builder.dockerfile_images): self.log.info("Skipping add yum repo by url: unsupported for FROM-scratch images") return if self.repourls and not is_scratch_build(self.workflow): self.validate_yum_repo_files_url() for repourl in self.repourls: yumrepo = YumRepo(repourl) self.log.info("fetching yum repo from '%s'", yumrepo.repourl) try: yumrepo.fetch() except Exception as e: msg = "Failed to fetch yum repo {repo}: {exc}".format( repo=yumrepo.repourl, exc=e) raise RuntimeError(msg) from e else: self.log.info("fetched yum repo from '%s'", yumrepo.repourl) if self.inject_proxy: if yumrepo.is_valid(): yumrepo.set_proxy_for_all_repos(self.inject_proxy) self.workflow.files[yumrepo.dst_filename] = yumrepo.content.decode() self.log.debug("saving yum repo '%s', length %d", yumrepo.dst_filename, len(yumrepo.content))
def run(self): """ run the plugin """ if not self.workflow.data.dockerfile_images: self.log.info( "Skipping plugin, from scratch stage(s) can't add repos") return if self.include_koji_repo: self.add_koji_repo() else: self.log.info( "'include_koji_repo parameter is set to '%s', not including koji repo", self.include_koji_repo) if self.repourls and not is_scratch_build(self.workflow): self.validate_yum_repo_files_url() fetched_yum_repos = {} for platform in self.platforms: for repourl in self.repourls.get(platform, []): if repourl in fetched_yum_repos: yum_repo = fetched_yum_repos[repourl] self.yum_repos[platform].append(yum_repo) continue yum_repo = YumRepo(repourl) self.log.info("fetching yum repo from '%s'", yum_repo.repourl) try: yum_repo.fetch() except Exception as e: msg = "Failed to fetch yum repo {repo}: {exc}".format( repo=yum_repo.repourl, exc=e) raise RuntimeError(msg) from e else: self.log.info("fetched yum repo from '%s'", yum_repo.repourl) if self.inject_proxy: if yum_repo.is_valid(): yum_repo.set_proxy_for_all_repos(self.inject_proxy) self.log.debug("saving yum repo '%s', length %d", yum_repo.dst_filename, len(yum_repo.content)) self.yum_repos[platform].append(yum_repo) fetched_yum_repos[repourl] = yum_repo if not self.yum_repos: return self._builder_ca_bundle = self.workflow.conf.builder_ca_bundle if self._builder_ca_bundle: self._ca_bundle_pem = os.path.basename(self._builder_ca_bundle) self.workflow.build_dir.for_each_platform(self._inject_into_repo_files) self.workflow.build_dir.for_each_platform(self._inject_into_dockerfile) for platform in self.platforms: for repo in self.yum_repos[platform]: self.log.info("injected yum repo: %s for '%s' platform", repo.dst_filename, platform)
def extract_base_url(self, repo_url): yum_repo = YumRepo(repo_url) yum_repo.fetch() if not yum_repo.is_valid(): return [] repo = yum_repo.config return [repo.get(section, 'baseurl') for section in repo.sections() if repo.has_option(section, 'baseurl')]