summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xbin/repoman5
-rw-r--r--pym/_emerge/Package.py41
-rw-r--r--pym/portage/dbapi/porttree.py4
-rw-r--r--pym/portage/dep/__init__.py35
-rw-r--r--pym/portage/package/ebuild/doebuild.py4
-rw-r--r--pym/portage/tests/dep/test_use_reduce.py45
6 files changed, 58 insertions, 76 deletions
diff --git a/bin/repoman b/bin/repoman
index 2deeb5d78..ff831d570 100755
--- a/bin/repoman
+++ b/bin/repoman
@@ -73,7 +73,7 @@ from portage.output import bold, create_color_func, \
from portage.output import ConsoleStyleFile, StyleWriter
from portage.util import cmp_sort_key, writemsg_level
from portage.package.ebuild.digestgen import digestgen
-from portage.eapi import eapi_has_src_uri_arrows, eapi_has_slot_deps, \
+from portage.eapi import eapi_has_slot_deps, \
eapi_has_use_deps, eapi_has_strong_blocks, eapi_has_iuse_defaults, \
eapi_has_required_use, eapi_has_use_dep_defaults
@@ -1457,8 +1457,7 @@ for x in scanlist:
if not src_uri_error:
# Check that URIs don't reference a server from thirdpartymirrors.
for uri in portage.dep.use_reduce( \
- myaux["SRC_URI"], matchall=True, is_src_uri=True, \
- allow_src_uri_file_renames=eapi_has_src_uri_arrows(eapi), flat=True):
+ myaux["SRC_URI"], matchall=True, is_src_uri=True, eapi=eapi, flat=True):
contains_mirror = False
for mirror in thirdpartymirrors:
if uri.startswith(mirror):
diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py
index d4da2aa54..e361c28be 100644
--- a/pym/_emerge/Package.py
+++ b/pym/_emerge/Package.py
@@ -7,9 +7,7 @@ import portage
from portage.cache.mappings import slot_dict_class
from portage.dep import Atom, check_required_use, isvalidatom, use_reduce, \
paren_enclose, _slot_re
-from portage.eapi import eapi_has_src_uri_arrows, eapi_has_slot_deps, \
- eapi_has_use_deps, eapi_has_strong_blocks, eapi_has_iuse_defaults, \
- eapi_has_required_use, eapi_has_use_dep_defaults
+from portage.eapi import eapi_has_iuse_defaults, eapi_has_required_use
from _emerge.Task import Task
if sys.hexversion >= 0x3000000:
@@ -53,7 +51,7 @@ class Package(Task):
slot = '0'
if (self.iuse.enabled or self.iuse.disabled) and \
not eapi_has_iuse_defaults(self.metadata["EAPI"]):
- self._invalid_metadata('IUSE.invalid',
+ self._invalid_metadata('EAPI.incompatible',
"IUSE contains defaults, but EAPI doesn't allow them")
self.slot_atom = portage.dep.Atom("%s:%s" % (self.cp, slot))
self.category, self.pf = portage.catsplit(self.cpv)
@@ -75,40 +73,10 @@ class Package(Task):
if not v:
continue
try:
- atoms = portage.dep.use_reduce(v, matchall=True, flat=True,
+ use_reduce(v, eapi=eapi,
is_valid_flag=self.iuse.is_valid_flag, token_class=Atom)
except portage.exception.InvalidDependString as e:
self._invalid_metadata(k + ".syntax", "%s: %s" % (k, e))
- else:
- for atom in atoms:
- if not isinstance(atom, Atom):
- continue
-
- if atom.slot and not eapi_has_slot_deps(eapi):
- self._invalid_metadata('EAPI.incompatible',
- ("%s slot dependency" + \
- " not supported with EAPI='%s':" + \
- " '%s'") % (k, eapi, atom))
-
- if atom.use and not eapi_has_use_deps(eapi):
- self._invalid_metadata('EAPI.incompatible',
- ("%s use dependency" + \
- " not supported with EAPI='%s':" + \
- " '%s'") % (k, eapi, atom))
-
- if atom.use and (atom.use.missing_enabled or atom.use.missing_disabled) and \
- not eapi_has_use_dep_defaults(eapi):
- self._invalid_metadata('EAPI.incompatible',
- ("%s use dependency" + \
- " not supported with EAPI='%s':" + \
- " '%s'") % (k, eapi, atom))
-
- if atom.blocker and atom.blocker.overlap.forbid \
- and not eapi_has_strong_blocks(eapi):
- self._invalid_metadata('EAPI.incompatible',
- ("%s new blocker syntax" + \
- " not supported with EAPI='%s':" + \
- " '%s'") % (k, eapi, atom))
k = 'REQUIRED_USE'
v = self.metadata.get(k)
@@ -128,8 +96,7 @@ class Package(Task):
v = self.metadata.get(k)
if v:
try:
- use_reduce(v, matchall=True, flat=True, is_src_uri=True,
- allow_src_uri_file_renames=eapi_has_src_uri_arrows(eapi),
+ use_reduce(v, is_src_uri=True, eapi=eapi, \
is_valid_flag=self.iuse.is_valid_flag)
except portage.exception.InvalidDependString as e:
self._invalid_metadata(k + ".syntax", "%s: %s" % (k, e))
diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py
index dab75b278..ea27883dd 100644
--- a/pym/portage/dbapi/porttree.py
+++ b/pym/portage/dbapi/porttree.py
@@ -22,7 +22,6 @@ from portage.cache.cache_errors import CacheError
from portage.cache.mappings import Mapping
from portage.const import REPO_NAME_LOC
from portage.dbapi import dbapi
-from portage.eapi import eapi_has_src_uri_arrows
from portage.exception import PortageException, \
FileNotFound, InvalidDependString, InvalidPackageName
from portage.localization import _
@@ -1185,8 +1184,7 @@ def _parse_uri_map(cpv, metadata, use=None):
myuris = use_reduce(metadata.get('SRC_URI', ''),
uselist=use, matchall=(use is None),
is_src_uri=True,
- allow_src_uri_file_renames = \
- eapi_has_src_uri_arrows(metadata['EAPI']))
+ eapi=metadata['EAPI'])
uri_map = OrderedDict()
diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
index 6b0f7f78c..c6bd4ea21 100644
--- a/pym/portage/dep/__init__.py
+++ b/pym/portage/dep/__init__.py
@@ -30,10 +30,12 @@ import re, sys
import warnings
from itertools import chain
import portage.exception
+from portage.eapi import eapi_has_slot_deps, eapi_has_src_uri_arrows, \
+ eapi_has_use_deps, eapi_has_strong_blocks, eapi_has_use_dep_defaults
from portage.exception import InvalidData, InvalidAtom
from portage.localization import _
from portage.versions import catpkgsplit, catsplit, \
- pkgcmp, pkgsplit, ververify, _cp, _cpv
+ pkgcmp, ververify, _cp, _cpv
import portage.cache.mappings
if sys.hexversion >= 0x3000000:
@@ -252,7 +254,7 @@ def paren_enclose(mylist):
return " ".join(mystrparts)
def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], is_src_uri=False, \
- allow_src_uri_file_renames=False, opconvert=False, flat=False, is_valid_flag=None, token_class=None):
+ eapi=None, opconvert=False, flat=False, is_valid_flag=None, token_class=None):
"""
Takes a dep string and reduces the use? conditionals out, leaving an array
with subarrays. All redundant brackets are removed.
@@ -269,8 +271,8 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i
@type excludeall: List
@param is_src_uri: Indicates if depstr represents a SRC_URI
@type is_src_uri: Bool
- @param allow_src_uri_file_renames: Indicates if EAPI-2 SRC_URI arrows are allowed when parsing a SRC_URI
- @type allow_src_uri_file_renames: Bool
+ @param eapi: Indicates the EAPI the dep string has to comply to
+ @type eapi: String
@param opconvert: Put every operator as first element into it's argument list
@type opconvert: Bool
@param flat: Create a flat list of all tokens
@@ -452,9 +454,9 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i
if not is_src_uri:
raise portage.exception.InvalidDependString(
_("SRC_URI arrow are only allowed in SRC_URI: '%s', token %s") % (depstr, pos+1))
- if not allow_src_uri_file_renames:
+ if eapi is None or not eapi_has_src_uri_arrows(eapi):
raise portage.exception.InvalidDependString(
- _("SRC_URI arrow not allowed in this EAPI: '%s', token %s") % (depstr, pos+1))
+ _("SRC_URI arrow not allowed in EAPI %s: '%s', token %s") % (eapi, depstr, pos+1))
need_simple_token = True
stack[level].append(token)
else:
@@ -476,7 +478,10 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i
if token_class and not is_src_uri:
#Add a hack for SRC_URI here, to avoid conditional code at the consumer level
try:
- token = token_class(token)
+ token = token_class(token, eapi=eapi)
+ except InvalidAtom as e:
+ raise portage.exception.InvalidDependString(
+ _("Invalid atom (%s) in '%s', token %s") % (e, depstr, pos+1))
except Exception as e:
raise portage.exception.InvalidDependString(
_("Invalid token '%s' in '%s', token %s") % (token, depstr, pos+1))
@@ -949,10 +954,10 @@ class Atom(_atom_base):
def __init__(self, forbid_overlap=False):
self.overlap = self._overlap(forbid=forbid_overlap)
- def __new__(cls, s, unevaluated_atom=None, allow_wildcard=False, _use=None):
+ def __new__(cls, s, unevaluated_atom=None, allow_wildcard=False, _use=None, eapi=None):
return _atom_base.__new__(cls, s)
- def __init__(self, s, unevaluated_atom=None, allow_wildcard=False, _use=None):
+ def __init__(self, s, unevaluated_atom=None, allow_wildcard=False, _use=None, eapi=None):
if isinstance(s, Atom):
# This is an efficiency assertion, to ensure that the Atom
# constructor is not called redundantly.
@@ -1038,6 +1043,18 @@ class Atom(_atom_base):
else:
self.__dict__['unevaluated_atom'] = self
+ if eapi is not None:
+ if self.slot and not eapi_has_slot_deps(eapi):
+ raise InvalidAtom("Slot deps are not allowed in EAPI %s: '%s'" % (eapi, self))
+ if self.use:
+ if not eapi_has_use_deps(eapi):
+ raise InvalidAtom("Use deps are not allowed in EAPI %s: '%s'" % (eapi, self))
+ elif not eapi_has_use_dep_defaults(eapi) and \
+ (self.use.missing_enabled or self.use.missing_disabled):
+ raise InvalidAtom("Use dep defaults are not allowed in EAPI %s: '%s'" % (eapi, self))
+ if self.blocker and self.blocker.overlap.forbid and not eapi_has_strong_blocks(eapi):
+ raise InvalidAtom("Strong blocks are not allowed in EAPI %s: '%s'" % (eapi, self))
+
def __setattr__(self, name, value):
raise AttributeError("Atom instances are immutable",
self.__class__, name, value)
diff --git a/pym/portage/package/ebuild/doebuild.py b/pym/portage/package/ebuild/doebuild.py
index 1e8da8a01..af4ee5ef4 100644
--- a/pym/portage/package/ebuild/doebuild.py
+++ b/pym/portage/package/ebuild/doebuild.py
@@ -39,7 +39,6 @@ from portage.data import portage_gid, portage_uid, secpass, \
from portage.dbapi.virtual import fakedbapi
from portage.dep import Atom, paren_enclose, use_reduce
from portage.eapi import eapi_exports_KV, eapi_exports_replace_vars, \
- eapi_has_src_uri_arrows, \
eapi_has_src_prepare_and_src_configure, eapi_has_pkg_pretend
from portage.elog import elog_process
from portage.elog.messages import eerror, eqawarn
@@ -995,8 +994,7 @@ def _validate_deps(mysettings, myroot, mydo, mydbapi):
eapi = metadata["EAPI"]
for k in misc_keys:
try:
- use_reduce(metadata[k], matchall=True, is_src_uri=(k=="SRC_URI"), \
- allow_src_uri_file_renames=eapi_has_src_uri_arrows(eapi))
+ use_reduce(metadata[k], is_src_uri=(k=="SRC_URI"), eapi=eapi)
except InvalidDependString as e:
msgs.append(" %s: %s\n %s\n" % (
k, metadata[k], str(e)))
diff --git a/pym/portage/tests/dep/test_use_reduce.py b/pym/portage/tests/dep/test_use_reduce.py
index deaae91f2..000ed4b24 100644
--- a/pym/portage/tests/dep/test_use_reduce.py
+++ b/pym/portage/tests/dep/test_use_reduce.py
@@ -8,7 +8,7 @@ from portage.dep import Atom, use_reduce
class UseReduceTestCase(object):
def __init__(self, deparray, uselist=[], masklist=[], \
matchall=0, excludeall=[], is_src_uri=False, \
- allow_src_uri_file_renames=False, opconvert=False, flat=False, expected_result=None, \
+ eapi=None, opconvert=False, flat=False, expected_result=None, \
is_valid_flag=None, token_class=None):
self.deparray = deparray
self.uselist = uselist
@@ -16,7 +16,7 @@ class UseReduceTestCase(object):
self.matchall = matchall
self.excludeall = excludeall
self.is_src_uri = is_src_uri
- self.allow_src_uri_file_renames = allow_src_uri_file_renames
+ self.eapi = eapi
self.opconvert = opconvert
self.flat = flat
self.is_valid_flag = is_valid_flag
@@ -25,7 +25,7 @@ class UseReduceTestCase(object):
def run(self):
return use_reduce(self.deparray, self.uselist, self.masklist, \
- self.matchall, self.excludeall, self.is_src_uri, self.allow_src_uri_file_renames, \
+ self.matchall, self.excludeall, self.is_src_uri, self.eapi, \
self.opconvert, self.flat, self.is_valid_flag, self.token_class)
class UseReduce(TestCase):
@@ -37,7 +37,10 @@ class UseReduce(TestCase):
return False
def testUseReduce(self):
-
+
+ EAPI_WITH_SRC_URI_ARROWS = "2"
+ EAPI_WITHOUT_SRC_URI_ARROWS = "0"
+
test_cases = (
UseReduceTestCase(
"a? ( A ) b? ( B ) !c? ( C ) !d? ( D )",
@@ -228,37 +231,37 @@ class UseReduce(TestCase):
UseReduceTestCase(
"http://foo/bar -> blah.tbz2",
is_src_uri = True,
- allow_src_uri_file_renames = True,
+ eapi = EAPI_WITH_SRC_URI_ARROWS,
expected_result = ["http://foo/bar", "->", "blah.tbz2"]),
UseReduceTestCase(
"foo? ( http://foo/bar -> blah.tbz2 )",
uselist = [],
is_src_uri = True,
- allow_src_uri_file_renames = True,
+ eapi = EAPI_WITH_SRC_URI_ARROWS,
expected_result = []),
UseReduceTestCase(
"foo? ( http://foo/bar -> blah.tbz2 )",
uselist = ["foo"],
is_src_uri = True,
- allow_src_uri_file_renames = True,
+ eapi = EAPI_WITH_SRC_URI_ARROWS,
expected_result = ["http://foo/bar", "->", "blah.tbz2"]),
UseReduceTestCase(
"http://foo/bar -> bar.tbz2 foo? ( ftp://foo/a )",
uselist = [],
is_src_uri = True,
- allow_src_uri_file_renames = True,
+ eapi = EAPI_WITH_SRC_URI_ARROWS,
expected_result = ["http://foo/bar", "->", "bar.tbz2"]),
UseReduceTestCase(
"http://foo/bar -> bar.tbz2 foo? ( ftp://foo/a )",
uselist = ["foo"],
is_src_uri = True,
- allow_src_uri_file_renames = True,
+ eapi = EAPI_WITH_SRC_URI_ARROWS,
expected_result = ["http://foo/bar", "->", "bar.tbz2", "ftp://foo/a"]),
UseReduceTestCase(
"http://foo.com/foo http://foo/bar -> blah.tbz2",
uselist = ["foo"],
is_src_uri = True,
- allow_src_uri_file_renames = True,
+ eapi = EAPI_WITH_SRC_URI_ARROWS,
expected_result = ["http://foo.com/foo", "http://foo/bar", "->", "blah.tbz2"]),
#opconvert tests
@@ -459,18 +462,18 @@ class UseReduce(TestCase):
UseReduceTestCase("foo?"),
#SRC_URI stuff
- UseReduceTestCase("http://foo/bar -> blah.tbz2", is_src_uri = True, allow_src_uri_file_renames = False),
- UseReduceTestCase("|| ( http://foo/bar -> blah.tbz2 )", is_src_uri = True, allow_src_uri_file_renames = True),
- UseReduceTestCase("http://foo/bar -> foo? ( ftp://foo/a )", is_src_uri = True, allow_src_uri_file_renames = True),
- UseReduceTestCase("http://foo/bar blah.tbz2 ->", is_src_uri = True, allow_src_uri_file_renames = True),
- UseReduceTestCase("-> http://foo/bar blah.tbz2 )", is_src_uri = True, allow_src_uri_file_renames = True),
- UseReduceTestCase("http://foo/bar ->", is_src_uri = True, allow_src_uri_file_renames = True),
- UseReduceTestCase("http://foo/bar -> foo? ( http://foo.com/foo )", is_src_uri = True, allow_src_uri_file_renames = True),
- UseReduceTestCase("foo? ( http://foo/bar -> ) blah.tbz2", is_src_uri = True, allow_src_uri_file_renames = True),
- UseReduceTestCase("http://foo/bar -> foo/blah.tbz2", is_src_uri = True, allow_src_uri_file_renames = True),
- UseReduceTestCase("http://foo/bar -> -> bar.tbz2 foo? ( ftp://foo/a )", is_src_uri = True, allow_src_uri_file_renames = True),
+ UseReduceTestCase("http://foo/bar -> blah.tbz2", is_src_uri = True, eapi = EAPI_WITHOUT_SRC_URI_ARROWS),
+ UseReduceTestCase("|| ( http://foo/bar -> blah.tbz2 )", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS),
+ UseReduceTestCase("http://foo/bar -> foo? ( ftp://foo/a )", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS),
+ UseReduceTestCase("http://foo/bar blah.tbz2 ->", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS),
+ UseReduceTestCase("-> http://foo/bar blah.tbz2 )", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS),
+ UseReduceTestCase("http://foo/bar ->", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS),
+ UseReduceTestCase("http://foo/bar -> foo? ( http://foo.com/foo )", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS),
+ UseReduceTestCase("foo? ( http://foo/bar -> ) blah.tbz2", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS),
+ UseReduceTestCase("http://foo/bar -> foo/blah.tbz2", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS),
+ UseReduceTestCase("http://foo/bar -> -> bar.tbz2 foo? ( ftp://foo/a )", is_src_uri = True, eapi = EAPI_WITH_SRC_URI_ARROWS),
- UseReduceTestCase("http://foo/bar -> bar.tbz2 foo? ( ftp://foo/a )", is_src_uri = False, allow_src_uri_file_renames = True),
+ UseReduceTestCase("http://foo/bar -> bar.tbz2 foo? ( ftp://foo/a )", is_src_uri = False, eapi = EAPI_WITH_SRC_URI_ARROWS),
UseReduceTestCase(
"A",