How to use the pkgcore.ebuild.repo_objs.RepoConfig function in pkgcore

To help you get started, we’ve selected a few pkgcore examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pkgcore / pkgcore / tests / module / ebuild / test_repo_objs.py View on Github external
def test_use_expand_desc(self):
        # nonexistent repo
        repo_config = repo_objs.RepoConfig('nonexistent')
        assert repo_config.use_expand_desc == {}
        del repo_config

        # empty file
        use_expand_desc_path = os.path.join(self.profiles_base, 'desc')
        os.makedirs(use_expand_desc_path)
        use_expand_desc_file = os.path.join(use_expand_desc_path, 'foo.desc')
        touch(use_expand_desc_file)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.use_expand_desc == {'foo': ()}
        del repo_config

        # regular entries
        with open(use_expand_desc_file, 'w') as f:
            f.write(
                """
                # copy
                # license

                bar - add bar support
                baz - build using baz
                """)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.use_expand_desc == {
            'foo': (
github pkgcore / pkgcore / tests / module / ebuild / test_repo_objs.py View on Github external
def test_default_eapi(self):
        os.mkdir(self.profiles_base)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert str(repo_config.eapi) == '0'
github pkgcore / pkgcore / tests / module / ebuild / test_repo_objs.py View on Github external
def test_use_desc(self):
        # nonexistent repo
        repo_config = repo_objs.RepoConfig('nonexistent')
        assert repo_config.use_desc == ()
        del repo_config

        # empty file
        os.mkdir(self.profiles_base)
        use_desc_path = os.path.join(self.profiles_base, 'use.desc')
        touch(use_desc_path)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.use_desc == ()
        del repo_config

        # regular entries
        with open(use_desc_path, 'w') as f:
            f.write(
                """
                # copy
                # license

                foo1 - enable foo1
                foo2 - enable foo2
                bar3 - add bar3 support
                """)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert 3 == len(repo_config.use_desc)
github pkgcore / pkgcore / tests / module / ebuild / test_repo_objs.py View on Github external
def test_repo_id(self, caplog):
        # nonexistent repo
        repo_config = repo_objs.RepoConfig('nonexistent')
        assert repo_config.repo_id == 'nonexistent'
        del repo_config

        # empty repo
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.repo_id == self.repo_path
        assert caplog.text == ''
        caplog.clear()
        del repo_config

        # nonempty repo
        os.mkdir(self.profiles_base)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.repo_id == self.repo_path
        assert 'repo lacks a defined name:' in caplog.text
        caplog.clear()
github pkgcore / pkgcore / tests / module / ebuild / test_repo_objs.py View on Github external
def test_use_desc(self):
        # nonexistent repo
        repo_config = repo_objs.RepoConfig('nonexistent')
        assert repo_config.use_desc == ()
        del repo_config

        # empty file
        os.mkdir(self.profiles_base)
        use_desc_path = os.path.join(self.profiles_base, 'use.desc')
        touch(use_desc_path)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.use_desc == ()
        del repo_config

        # regular entries
        with open(use_desc_path, 'w') as f:
            f.write(
                """
                # copy
github pkgcore / pkgcore / tests / module / ebuild / test_repo_objs.py View on Github external
def test_is_empty(self, caplog):
        caplog.set_level(logging.DEBUG)

        # nonexistent repo
        repo_config = repo_objs.RepoConfig('nonexistent')
        assert repo_config.is_empty
        assert caplog.text == ''
        caplog.clear()
        del repo_config

        # empty repo
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.is_empty
        assert 'repo is empty:' in caplog.text
        caplog.clear()
        del repo_config

        # profiles dir exists
        os.mkdir(self.profiles_base)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert not repo_config.is_empty
github pkgcore / pkgcore / tests / module / ebuild / test_repo_objs.py View on Github external
def test_updates(self):
        # nonexistent repo
        repo_config = repo_objs.RepoConfig('nonexistent')
        assert repo_config.updates == {}
        del repo_config

        # empty file
        updates_path = os.path.join(self.profiles_base, 'updates')
        updates_file_path = os.path.join(updates_path, '1Q-2019')
        os.makedirs(updates_path)
        touch(updates_file_path)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.updates == {}
        del repo_config

        # simple pkg move
        # TODO: move pkg_updates content tests to its own module
        with open(updates_file_path, 'w') as f:
            f.write('move cat1/pkg1 cat2/pkg1\n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.updates == {
            'cat1/pkg1':  [('move', atom.atom('cat1/pkg1'), atom.atom('cat2/pkg1'))],
        }
        del repo_config
github pkgcore / pkgcore / tests / module / ebuild / test_repo_objs.py View on Github external
def test_use_expand_desc(self):
        # nonexistent repo
        repo_config = repo_objs.RepoConfig('nonexistent')
        assert repo_config.use_expand_desc == {}
        del repo_config

        # empty file
        use_expand_desc_path = os.path.join(self.profiles_base, 'desc')
        os.makedirs(use_expand_desc_path)
        use_expand_desc_file = os.path.join(use_expand_desc_path, 'foo.desc')
        touch(use_expand_desc_file)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.use_expand_desc == {'foo': ()}
        del repo_config

        # regular entries
        with open(use_expand_desc_file, 'w') as f:
            f.write(
                """
github pkgcore / pkgcore / src / pkgcore / ebuild / profiles.py View on Github external
def _load_repoconfig_from_path(path):
        path = abspath(path)
        # strip '/' so we don't get '/usr/portage' == ('', 'usr', 'portage')
        chunks = path.lstrip('/').split('/')
        try:
            pindex = max(idx for idx, x in enumerate(chunks) if x == 'profiles')
        except ValueError:
            # not in a repo...
            return None
        repo_path = pjoin('/', *chunks[:pindex])
        return repo_objs.RepoConfig(repo_path)
github pkgcore / pkgcore / src / pkgcore / ebuild / domain.py View on Github external
def add_repo(self, path, config, name=None, configure=True):
        """Add an external repo to the domain."""
        path = os.path.abspath(path)
        if name is None:
            # parse repo id from the given path
            name = RepoConfig(path).repo_id
            if name in self.source_repos_raw:
                # fallback to using path for repo id in case of duplicate repos
                name = path
        if name in self.source_repos_raw:
            raise ValueError(f'{name!r} repo already configured')
        repo_config = RepoConfig(path, config_name=name)
        kwargs = {}
        if repo_config.cache_format is not None:
            # default to using md5 cache
            kwargs['cache'] = (md5_cache(path),)
        repo_obj = ebuild_repo.tree(config, repo_config, **kwargs)

        # TODO: reset related jit attrs
        self.source_repos_raw += repo_obj
        if configure:
            return self._wrap_repo(repo_obj)
        return repo_obj