Ejemplo n.º 1
0
 def _sync_metadata(self, dnf_repo):
     try:
         dnf_repo.load()
     except dnf.exceptions.RepoError as e:
         id_ = dnf_repo.id
         if id_ == self.baseRepo:
             raise packaging.MetadataError(str(e))
         log.info('_sync_metadata: addon repo error: %s', e)
         self.disableRepo(id_)
Ejemplo n.º 2
0
    def _add_repo(self, ksrepo):
        """Add a repo to the dnf repo object

           :param ksrepo: Kickstart Repository to add
           :type ksrepo: Kickstart RepoData object.
           :returns: None
        """
        repo = dnf.repo.Repo(ksrepo.name, DNF_CACHE_DIR)
        url = self._replace_vars(ksrepo.baseurl)
        mirrorlist = self._replace_vars(ksrepo.mirrorlist)

        if url and url.startswith("nfs://"):
            (server, path) = url[6:].split(":", 1)
            mountpoint = "%s/%s.nfs" % (constants.MOUNT_DIR, repo.name)
            self._setupNFS(mountpoint, server, path, None)

            url = "file://" + mountpoint

        if url:
            repo.baseurl = [url]
        if mirrorlist:
            repo.mirrorlist = mirrorlist
        repo.sslverify = not (ksrepo.noverifyssl or flags.noverifyssl)
        if ksrepo.proxy:
            try:
                repo.proxy = ProxyString(ksrepo.proxy).url
            except ProxyStringError as e:
                log.error("Failed to parse proxy for _add_repo %s: %s",
                          ksrepo.proxy, e)

        # If this repo is already known, it's one of two things:
        # (1) The user is trying to do "repo --name=updates" in a kickstart file
        #     and we should just know to enable the already existing on-disk
        #     repo config.
        # (2) It's a duplicate, and we need to delete the existing definition
        #     and use this new one.  The highest profile user of this is livecd
        #     kickstarts.
        if repo.id in self._base.repos:
            if not url and not mirrorlist:
                self._base.repos[repo.id].enable()
            else:
                self._base.repos.pop(repo.id)
                self._base.repos.add(repo)
                repo.enable()
        # If the repo's not already known, we've got to add it.
        else:
            self._base.repos.add(repo)
            repo.enable()

        # Load the metadata to verify that the repo is valid
        try:
            self._base.repos[repo.id].load()
        except dnf.exceptions.RepoError as e:
            raise packaging.MetadataError(e)

        log.info("added repo: '%s' - %s", ksrepo.name, url or mirrorlist)
Ejemplo n.º 3
0
 def _sync_metadata(self, dnf_repo):
     try:
         dnf_repo.load()
     except dnf.exceptions.RepoError as e:
         raise packaging.MetadataError(str(e))