Beispiel #1
0
    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':
            (('foo_bar', 'add bar support'), ('foo_baz', 'build using baz'))
        }
        del repo_config
Beispiel #2
0
    def test_raw_use_local_desc(self):
        # nonexistent repo
        repo_config = repo_objs.RepoConfig('nonexistent')
        assert repo_config.raw_use_local_desc == ()
        del repo_config

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

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

                cat/pkg1:foo1 - enable foo1
                cat1/pkg2:foo2 - enable foo2
                cat2/pkg3:bar3 - add bar3 support
                """)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert 3 == len(repo_config.raw_use_local_desc)
        del repo_config
Beispiel #3
0
    def test_raw_known_arches(self):
        # nonexistent repo
        repo_config = repo_objs.RepoConfig('nonexistent')
        assert repo_config.raw_known_arches == frozenset()
        del repo_config

        # empty file
        os.mkdir(self.profiles_base)
        arches_path = os.path.join(self.profiles_base, 'arch.list')
        touch(arches_path)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.raw_known_arches == frozenset()
        del repo_config

        # single entry
        with open(arches_path, 'w') as f:
            f.write('foo')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.raw_known_arches == frozenset(['foo'])
        del repo_config

        # multiple entries with whitespaces and comments
        with open(arches_path, 'w') as f:
            f.write("""
                amd64
                x86

                # prefix
                foo-bar
                """)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.raw_known_arches == frozenset(
            ['amd64', 'x86', 'foo-bar'])
        del repo_config
Beispiel #4
0
    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
Beispiel #5
0
    def test_updates_eapi8(self):
        # empty file
        updates_path = os.path.join(self.profiles_base, 'updates')
        updates_file_path = os.path.join(updates_path, '2021.1')
        os.makedirs(updates_path)
        touch(updates_file_path)
        with open(os.path.join(self.profiles_base, 'eapi'), 'w') as f:
            f.write('8\n')
        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)
        expected_updates = {
            'cat1/pkg1':
            [('move', atom.atom('cat1/pkg1'), atom.atom('cat2/pkg1'))],
        }
        assert repo_config.updates == expected_updates
        del repo_config

        # extraneous file should be ignored
        extra_file_path = os.path.join(updates_path, '.frobnicate')
        with open(extra_file_path, 'w') as f:
            f.write('move cat1/pkg2 cat1/pkg3\n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.updates == expected_updates
        del repo_config
Beispiel #6
0
    def test_raw_use_expand_desc(self):
        # nonexistent repo
        repo_config = repo_objs.RepoConfig('nonexistent')
        assert repo_config.raw_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.raw_use_expand_desc == ()
        del repo_config

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

                foo - enable foo
                bar - add bar support
                baz - build using baz
                """)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert 3 == len(repo_config.raw_use_expand_desc)
        del repo_config
Beispiel #7
0
    def test_arches_desc(self):
        # nonexistent repo
        repo_config = repo_objs.RepoConfig('nonexistent')
        empty = {'stable': set(), 'transitional': set(), 'testing': set()}
        assert repo_config.arches_desc == ImmutableDict(empty)
        del repo_config

        # empty file
        os.mkdir(self.profiles_base)
        arches_desc_path = os.path.join(self.profiles_base, 'arches.desc')
        touch(arches_desc_path)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.arches_desc == ImmutableDict(empty)
        del repo_config

        # regular entries
        with open(os.path.join(self.profiles_base, 'arch.list'), 'w') as f:
            f.write("""
                amd64
                alpha
                foo
                """)
        with open(arches_desc_path, 'w') as f:
            f.write("""
                # arches.desc file

                amd64 stable
                alpha testing
                """)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.arches_desc['stable'] == {'amd64'}
        assert repo_config.arches_desc['testing'] == {'alpha'}
        assert repo_config.arches_desc['transitional'] == set()
        del repo_config
Beispiel #8
0
    def test_repo_name(self, caplog):
        # nonexistent file
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.repo_name is None
        del repo_config

        # empty file
        os.mkdir(os.path.dirname(self.metadata_path))
        touch(self.metadata_path)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.repo_name is None
        del repo_config

        # bad data formatting
        with open(self.metadata_path, 'w') as f:
            f.write('repo-name repo')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.repo_name is None
        assert 'bash parse error' in caplog.text
        caplog.clear()
        del repo_config

        # bad data formatting + name
        with open(self.metadata_path, 'w') as f:
            f.write('foo bar\nrepo-name = repo0')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.repo_name == 'repo0'
        assert 'bash parse error' in caplog.text
        caplog.clear()
        del repo_config

        # unset
        with open(self.metadata_path, 'w') as f:
            f.write('repo-name =')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.repo_name == ''
        del repo_config

        # whitespace
        with open(self.metadata_path, 'w') as f:
            f.write('repo-name =  \n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.repo_name == ''
        del repo_config

        # whitespace + name
        with open(self.metadata_path, 'w') as f:
            f.write('repo-name = repo \n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.repo_name == 'repo'
        del repo_config

        # regular name
        with open(self.metadata_path, 'w') as f:
            f.write('repo-name = repo1')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.repo_name == 'repo1'
        del repo_config
Beispiel #9
0
 def test_bad_data_known_eapi(self, caplog):
     os.mkdir(self.profiles_base)
     with open(self.eapi_path, 'w+') as f:
         f.write('4\nfoo\nbar')
     repo_config = repo_objs.RepoConfig(self.repo_path)
     assert str(repo_config.eapi) == '4'
     assert 'multiple lines detected' in caplog.text
Beispiel #10
0
 def test_unknown_eapi(self):
     os.mkdir(self.profiles_base)
     with open(self.eapi_path, 'w+') as f:
         f.write('unknown_eapi')
     with pytest.raises(repo_errors.UnsupportedRepo) as excinfo:
         repo_objs.RepoConfig(self.repo_path)
     assert isinstance(excinfo.value.repo, repo_objs.RepoConfig)
Beispiel #11
0
 def process_check(self, profiles_base, *args, **kwds):
     namespace = argparse.Namespace()
     if profiles_base is None:
         repo_config = repo_objs.RepoConfig(location=self.dir)
     else:
         repo_config = repo_objs.RepoConfig(location=profiles_base,
                                            profiles_base='.')
     namespace.target_repo = repository.UnconfiguredTree(
         repo_config.location, repo_config=repo_config)
     namespace.search_repo = Options()
     namespace.cache = False
     options = ArgparseCheck.process_check(self,
                                           namespace=namespace,
                                           *args,
                                           **kwds)
     return options
Beispiel #12
0
 def test_bad_data_unknown_eapi(self, caplog):
     os.mkdir(self.profiles_base)
     with open(self.eapi_path, 'w+') as f:
         f.write('eapi\nfoo\nbar')
     with pytest.raises(repo_errors.UnsupportedRepo) as excinfo:
         repo_objs.RepoConfig(self.repo_path)
     assert isinstance(excinfo.value.repo, repo_objs.RepoConfig)
     assert 'multiple lines detected' in caplog.text
Beispiel #13
0
    def test_pms_repo_name(self):
        os.mkdir(self.profiles_base)
        repo_name_path = os.path.join(self.profiles_base, 'repo_name')

        # nonexistent file
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.pms_repo_name is None
        del repo_config

        # empty file
        touch(repo_name_path)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.pms_repo_name == ''
        del repo_config

        # whitespace
        with open(repo_name_path, 'w') as f:
            f.write(' \n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.pms_repo_name == ''
        del repo_config

        # whitespace + name
        with open(repo_name_path, 'w') as f:
            f.write(' repo \n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.pms_repo_name == 'repo'
        del repo_config

        # regular name
        with open(repo_name_path, 'w') as f:
            f.write('newrepo')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.pms_repo_name == 'newrepo'
        del repo_config

        # regular name EOLed
        with open(repo_name_path, 'w') as f:
            f.write('newrepo2\n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.pms_repo_name == 'newrepo2'
        del repo_config

        # multi-line
        with open(repo_name_path, 'w') as f:
            f.write('newrepo3\nfoobar')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.pms_repo_name == 'newrepo3'
        del repo_config

        # binary data
        with open(repo_name_path, 'wb') as f:
            f.write(b'\x6e\x65\x77\x72\x65\x70\x6f\x34')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.pms_repo_name == 'newrepo4'
        del repo_config
Beispiel #14
0
 def process_check(self, *args, **kwds):
     namespace = arghparse.Namespace()
     repo_config = repo_objs.RepoConfig(location=self.dir)
     namespace.target_repo = repository.UnconfiguredTree(
         repo_config.location, repo_config=repo_config)
     namespace.search_repo = Options()
     namespace.cache = {'profiles': False}
     options = ArgparseCheck.process_check(self, namespace=namespace, *args, **kwds)
     return options
Beispiel #15
0
 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)
Beispiel #16
0
    def test_profile_formats(self, caplog):
        # empty repo
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.profile_formats == {'pms'}
        del repo_config

        # explicit empty setting
        os.mkdir(os.path.dirname(self.metadata_path))
        with open(self.metadata_path, 'w') as f:
            f.write('profile-formats =\n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.profile_formats == {'pms'}
        assert 'has explicitly unset profile-formats' in caplog.text
        caplog.clear()
        del repo_config

        # unknown formats
        with open(self.metadata_path, 'w') as f:
            f.write('profile-formats = foo bar\n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.profile_formats == {'pms'}
        assert 'has unsupported profile format' in caplog.text
        caplog.clear()
        del repo_config

        # unknown + known
        with open(self.metadata_path, 'w') as f:
            f.write('profile-formats = foo portage-2\n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.profile_formats == {'pms', 'portage-2'}
        assert 'has unsupported profile format' in caplog.text
        caplog.clear()
        del repo_config

        # known formats
        with open(self.metadata_path, 'w') as f:
            f.write('profile-formats = portage-1 portage-2\n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.profile_formats == {'portage-1', 'portage-2'}
        del repo_config
Beispiel #17
0
    def test_manifests(self):
        # nonexistent file
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.manifests == {
            'disabled': False,
            'strict': True,
            'thin': False,
            'signed': True,
            'hashes': repo_objs.RepoConfig.default_hashes,
            'required_hashes': repo_objs.RepoConfig.default_required_hashes,
        }
        del repo_config

        # regular data
        os.mkdir(os.path.dirname(self.metadata_path))
        with open(self.metadata_path, 'w') as f:
            f.write('manifest-hashes = foo\n')
            f.write('manifest-required-hashes = bar\n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.manifests.hashes == ('size', 'foo')
        assert repo_config.manifests.required_hashes == ('size', 'bar')
        del repo_config
Beispiel #18
0
    def test_masters(self, caplog):
        # empty repo
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.masters == ()
        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.masters == ()
        assert "doesn't specify masters in metadata" in caplog.text
        caplog.clear()
        del repo_config

        # explicit empty masters for standalone repo
        os.mkdir(os.path.dirname(self.metadata_path))
        with open(self.metadata_path, 'w') as f:
            f.write('masters =\n')
        repo_config = repo_objs.RepoConfig(self.repo_path, config_name='foo')
        assert repo_config.masters == ()
        assert caplog.text == ''
        caplog.clear()
        del repo_config

        # overlay repo with masters
        with open(self.metadata_path, 'w') as f:
            f.write('masters = foo bar\n')
        repo_config = repo_objs.RepoConfig(self.repo_path, config_name='a')
        assert repo_config.masters == ('foo', 'bar')
        del repo_config

        # overlay repo with duplicate masters
        with open(self.metadata_path, 'w') as f:
            f.write('masters = foo bar foo baz\n')
        repo_config = repo_objs.RepoConfig(self.repo_path, config_name='b')
        assert repo_config.masters == ('foo', 'bar', 'baz')
        del repo_config
Beispiel #19
0
    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
        del repo_config
Beispiel #20
0
    def test_eapi(self, caplog):
        os.mkdir(self.profiles_base)
        eapi_path = os.path.join(self.profiles_base, 'eapi')

        # default EAPI
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert str(repo_config.eapi) == '0'
        del repo_config

        # empty file
        touch(eapi_path)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert str(repo_config.eapi) == '0'
        del repo_config

        # whitespace content
        with open(eapi_path, 'w+') as f:
            f.write('     \n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert str(repo_config.eapi) == '0'
        del repo_config

        # unknown EAPI
        with open(eapi_path, 'w+') as f:
            f.write('unknown_eapi')
        with pytest.raises(repo_errors.UnsupportedRepo) as excinfo:
            repo_objs.RepoConfig(self.repo_path)
        assert isinstance(excinfo.value.repo, repo_objs.RepoConfig)

        # known EAPI
        with open(eapi_path, 'w+') as f:
            f.write('6')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert str(repo_config.eapi) == '6'
        del repo_config

        # bad data, good EAPI
        with open(eapi_path, 'w+') as f:
            f.write('4\nfoo\nbar')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert str(repo_config.eapi) == '4'
        assert 'multiple EAPI lines detected:' in caplog.text
        caplog.clear()
        del repo_config

        # bad data, unknown EAPI
        with open(eapi_path, 'w+') as f:
            f.write('eapi\nfoo\nbar')
        with pytest.raises(repo_errors.UnsupportedRepo) as excinfo:
            repo_objs.RepoConfig(self.repo_path)
        assert isinstance(excinfo.value.repo, repo_objs.RepoConfig)
        assert 'multiple EAPI lines detected:' in caplog.text
        caplog.clear()
Beispiel #21
0
    def _repo_ebuild_v1(self,
                        repo_name,
                        repo_opts,
                        repo_map,
                        defaults,
                        repo_obj=None,
                        repo_dict=None):
        """Create ebuild repo v1 configuration."""
        repo_path = repo_opts['location']

        # XXX: Hack for portage-2 profile format support.
        if repo_obj is None:
            repo_obj = repo_objs.RepoConfig(repo_path, repo_name)
        repo_map[repo_obj.repo_id] = repo_path

        # repo configs
        repo_conf = {
            'class': 'pkgcore.ebuild.repo_objs.RepoConfig',
            'config_name': repo_name,
            'location': repo_path,
            'syncer': 'sync:' + repo_name,
        }
        if repo_dict is not None:
            repo_conf.update(repo_dict)

        # repo trees
        repo = {
            'inherit': ('ebuild-repo-common', ),
            'repo_config': 'conf:' + repo_name,
        }

        # metadata cache
        if repo_obj.cache_format is not None:
            cache_name = 'cache:' + repo_name
            self[cache_name] = self._make_cache(repo_obj.cache_format,
                                                repo_path)
            repo['cache'] = cache_name

        if repo_name == defaults['main-repo']:
            repo_conf['default'] = True
            repo['default'] = True

        self['conf:' + repo_name] = basics.AutoConfigSection(repo_conf)
        return repo
Beispiel #22
0
    def test_cache_format(self, caplog):
        # empty repo
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.cache_format == 'pms'
        del repo_config

        # explicit empty setting
        os.mkdir(os.path.dirname(self.metadata_path))
        with open(self.metadata_path, 'w') as f:
            f.write('cache-formats =\n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.cache_format is None
        del repo_config

        # unknown formats
        with open(self.metadata_path, 'w') as f:
            f.write('cache-formats = foo bar\n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.cache_format == 'pms'
        assert 'unknown cache format:' in caplog.text
        caplog.clear()
        del repo_config

        # known format
        with open(self.metadata_path, 'w') as f:
            f.write('cache-formats = md5-dict\n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.cache_format == 'md5-dict'
        del repo_config

        # multiple formats -- favored format is selected
        with open(self.metadata_path, 'w') as f:
            f.write('cache-formats = pms md5-dict\n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.cache_format == 'md5-dict'
        del repo_config

        # unknown + known
        with open(self.metadata_path, 'w') as f:
            f.write('cache-formats = foo md5-dict\n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.cache_format == 'md5-dict'
        del repo_config
Beispiel #23
0
    def test_repo_id(self, caplog):
        # nonexistent repo
        repo_config = repo_objs.RepoConfig('nonexistent')
        assert repo_config.repo_id == "<unlabeled repo: 'nonexistent'>"
        del repo_config

        # empty repo
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.repo_id == f"<unlabeled repo: {self.repo_path!r}>"
        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 == f"<unlabeled repo: {self.repo_path!r}>"
        assert 'repo lacks a defined name:' in caplog.text
        caplog.clear()
        del repo_config

        # pms repo name exists
        with open(os.path.join(self.profiles_base, 'repo_name'), 'w') as f:
            f.write('pms_name')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.repo_id == 'pms_name'
        del repo_config

        # layout.conf repo name exists
        os.mkdir(os.path.dirname(self.metadata_path))
        with open(self.metadata_path, 'w') as f:
            f.write('repo-name = metadata_name')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.repo_id == 'metadata_name'
        del repo_config

        # config name exists
        repo_config = repo_objs.RepoConfig(self.repo_path,
                                           config_name='config_name')
        assert repo_config.repo_id == 'config_name'
        del repo_config
Beispiel #24
0
 def test_default_eapi(self):
     os.mkdir(self.profiles_base)
     repo_config = repo_objs.RepoConfig(self.repo_path)
     assert str(repo_config.eapi) == '0'
Beispiel #25
0
 def test_empty_file_eapi(self):
     os.mkdir(self.profiles_base)
     touch(self.eapi_path)
     repo_config = repo_objs.RepoConfig(self.repo_path)
     assert str(repo_config.eapi) == '0'
Beispiel #26
0
 def test_known_eapi(self):
     os.mkdir(self.profiles_base)
     with open(self.eapi_path, 'w+') as f:
         f.write('6')
     repo_config = repo_objs.RepoConfig(self.repo_path)
     assert str(repo_config.eapi) == '6'
Beispiel #27
0
 def sync(self):
     """Forcibly create underlying repo object avoiding cache usage."""
     repo_config = repo_objs.RepoConfig(location=self.path, disable_inst_caching=True)
     self._repo = repository.UnconfiguredTree(self.path, repo_config=repo_config)
Beispiel #28
0
    def test_profile_formats(self, caplog):
        os.mkdir(self.profiles_base)
        with open(os.path.join(self.profiles_base, 'repo_name'), 'w') as f:
            f.write('pms_name')

        # empty repo
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.profile_formats == {'pms'}
        del repo_config
        caplog.clear()

        # explicit empty setting
        os.mkdir(os.path.dirname(self.metadata_path))
        with open(self.metadata_path, 'w') as f:
            f.write('masters =\nprofile-formats =\n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.profile_formats == {'pms'}
        assert not caplog.text
        caplog.clear()
        del repo_config
        # message shown at info log level
        caplog.set_level(logging.INFO)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert 'has explicitly unset profile-formats' in caplog.text
        caplog.clear()
        del repo_config

        # unknown formats
        caplog.set_level(logging.WARNING)
        with open(self.metadata_path, 'w') as f:
            f.write('masters =\nprofile-formats = foo bar\n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.profile_formats == {'pms'}
        assert not caplog.text
        caplog.clear()
        del repo_config
        # message shown at info log level
        caplog.set_level(logging.INFO)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert 'has unsupported profile format' in caplog.text
        caplog.clear()
        del repo_config

        # unknown + known
        caplog.set_level(logging.WARNING)
        with open(self.metadata_path, 'w') as f:
            f.write('masters =\nprofile-formats = foo portage-2\n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.profile_formats == {'pms', 'portage-2'}
        assert not caplog.text
        caplog.clear()
        del repo_config
        # message shown at info log level
        caplog.set_level(logging.INFO)
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert 'has unsupported profile format' in caplog.text
        caplog.clear()
        del repo_config

        # known formats
        caplog.set_level(logging.WARNING)
        with open(self.metadata_path, 'w') as f:
            f.write('profile-formats = portage-1 portage-2\n')
        repo_config = repo_objs.RepoConfig(self.repo_path)
        assert repo_config.profile_formats == {'portage-1', 'portage-2'}
        del repo_config
Beispiel #29
0
 def sync(self):
     """Forcibly create underlying repo object avoiding cache usage."""
     # avoid issues loading modules that set signal handlers
     from pkgcore.ebuild import repo_objs, repository
     repo_config = repo_objs.RepoConfig(location=self.path, disable_inst_caching=True)
     self._repo = repository.UnconfiguredTree(self.path, repo_config=repo_config)
Beispiel #30
0
 def test_nonexistent_repo(self):
     # Newly configured, nonexistent repos shouldn't cause issues.
     repo_config = repo_objs.RepoConfig('nonexistent')
     assert repo_config.location == 'nonexistent'