aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Harder <radhermit@gmail.com>2015-11-24 00:50:34 -0500
committerTim Harder <radhermit@gmail.com>2016-03-09 02:43:22 -0500
commit605482a9b4b90adc3210823766ab446b74d860c4 (patch)
tree9c5b1eec18bb1a6ce7a54dbe63043049ad99b8ae
parentconfig: move binpkg repo configuration into repos.conf (diff)
downloadpkgcore-605482a9b4b90adc3210823766ab446b74d860c4.tar.gz
pkgcore-605482a9b4b90adc3210823766ab446b74d860c4.tar.bz2
pkgcore-605482a9b4b90adc3210823766ab446b74d860c4.zip
portage_conf: add check for invalid repo-type settings
-rw-r--r--pkgcore/ebuild/portage_conf.py11
-rw-r--r--pkgcore/test/ebuild/test_portage_conf.py10
2 files changed, 18 insertions, 3 deletions
diff --git a/pkgcore/ebuild/portage_conf.py b/pkgcore/ebuild/portage_conf.py
index 9aaf1aca..1aa730e9 100644
--- a/pkgcore/ebuild/portage_conf.py
+++ b/pkgcore/ebuild/portage_conf.py
@@ -318,14 +318,19 @@ def load_repos_conf(path):
# untyped repos default to ebuild
repos[name].setdefault('repo-type', 'ebuild')
+ repo_type = repos[name]['repo-type']
# Ebuild repo priority defaults to zero and binpkg repo priority to
- # -100 if unset. This forces the main repo to be used before binary
+ # -100 if unset. This forces ebuild repos to be used before binary
# repos by default.
- if repos[name]['repo-type'] == 'binpkg':
+ if repo_type == 'ebuild':
+ priority = repos[name].get('priority', 0)
+ elif repo_type == 'binpkg':
priority = repos[name].get('priority', -100)
else:
- priority = repos[name].get('priority', 0)
+ raise errors.ParsingError(
+ "%s: repo '%s' has invalid type: '%s'" %
+ (fp, name, repo_type))
try:
repos[name]['priority'] = int(priority)
diff --git a/pkgcore/test/ebuild/test_portage_conf.py b/pkgcore/test/ebuild/test_portage_conf.py
index a44265bd..c5c1e672 100644
--- a/pkgcore/test/ebuild/test_portage_conf.py
+++ b/pkgcore/test/ebuild/test_portage_conf.py
@@ -113,6 +113,16 @@ class TestPortageConfig(TempDirMixin, TestCase):
self.assertRaises(
errors.ParsingError, load_repos_conf, f.name)
+ # bad repo-type
+ with NamedTemporaryFile() as f:
+ f.write(textwrap.dedent('''\
+ [foo]
+ location = /var/gentoo/repos/foo
+ repo-type = blah''').encode())
+ f.flush()
+ self.assertRaises(
+ errors.ParsingError, load_repos_conf, f.name)
+
# bad priority value
with NamedTemporaryFile() as f:
f.write(textwrap.dedent('''\