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
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):
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:
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)
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)
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))
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 _
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()
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:
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.
@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
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:
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))
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.
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)
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
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)))
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
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
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):
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 )",
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
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",