diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-06-25 06:06:14 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-06-25 06:06:14 +0000 |
commit | a15bbb69443cf6ffd5b8eee3e8f94066ee5148fe (patch) | |
tree | ad1443e52b51336f790e67c6939801fced1c45e5 | |
parent | cb436788a6e5c6e70b072673159639ccab680a2c (diff) | |
download | portage-a15bbb69443cf6ffd5b8eee3e8f94066ee5148fe.tar.gz portage-a15bbb69443cf6ffd5b8eee3e8f94066ee5148fe.tar.bz2 portage-a15bbb69443cf6ffd5b8eee3e8f94066ee5148fe.zip |
* Add a Package.invalid attribute to store messages about invalid LICENSE,
PROPERTIES, PROVIDE, and RESTRICT metadata. Use it to mask invalid packages
when necessary.
* Evaluate USE conditional values in Package.metadata when the are accessed.
svn path=/main/trunk/; revision=13691
-rw-r--r-- | pym/_emerge/Package.py | 28 | ||||
-rw-r--r-- | pym/_emerge/depgraph.py | 3 | ||||
-rw-r--r-- | pym/_emerge/visible.py | 2 |
3 files changed, 28 insertions, 5 deletions
diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py index 1ccd9254b..88adbf55f 100644 --- a/pym/_emerge/Package.py +++ b/pym/_emerge/Package.py @@ -25,7 +25,7 @@ class Package(Task): "installed", "metadata", "onlydeps", "operation", "root_config", "type_name", "category", "counter", "cp", "cpv_split", - "inherited", "iuse", "mtime", + "inherited", "invalid", "iuse", "mtime", "pf", "pv_split", "root", "slot", "slot_atom",) + \ ("_use",) @@ -52,6 +52,11 @@ class Package(Task): self.cpv_split = portage.catpkgsplit(self.cpv) self.pv_split = self.cpv_split[1:] + def _invalid_metadata(self, msg): + if self.invalid is None: + self.invalid = [] + self.invalid.append(msg) + class _use_class(object): __slots__ = ("__weakref__", "enabled") @@ -156,6 +161,8 @@ class _PackageMetadataWrapper(_PackageMetadataWrapperBase): __slots__ = ("_pkg",) _wrapped_keys = frozenset( ["COUNTER", "INHERITED", "IUSE", "SLOT", "_mtime_"]) + _use_conditional_keys = frozenset( + ['LICENSE', 'PROPERTIES', 'PROVIDE', 'RESTRICT',]) def __init__(self, pkg, metadata): _PackageMetadataWrapperBase.__init__(self) @@ -170,11 +177,17 @@ class _PackageMetadataWrapper(_PackageMetadataWrapperBase): def __getitem__(self, k): v = _PackageMetadataWrapperBase.__getitem__(self, k) - if k in ('PROVIDE', 'LICENSE',): + if k in self._use_conditional_keys: if '?' in v: - v = paren_enclose(paren_normalize(use_reduce( - paren_reduce(v), uselist=self._pkg.use.enabled))) - self[k] = v + try: + v = paren_enclose(paren_normalize(use_reduce( + paren_reduce(v), uselist=self._pkg.use.enabled))) + except portage.exception.InvalidDependString: + # This error should already have been registered via + # self._pkg._invalid_metadata(). + pass + else: + self[k] = v elif k == 'USE' and not self._pkg.built: if not v: @@ -191,6 +204,11 @@ class _PackageMetadataWrapper(_PackageMetadataWrapperBase): _PackageMetadataWrapperBase.__setitem__(self, k, v) if k in self._wrapped_keys: getattr(self, "_set_" + k.lower())(k, v) + elif k in self._use_conditional_keys: + try: + use_reduce(paren_reduce(v), matchall=1) + except portage.exception.InvalidDependString, e: + self._pkg._invalid_metadata("%s: %s" % (k, e)) def _set_inherited(self, k, v): if isinstance(v, basestring): diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 29fada52f..e69a20278 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -4910,6 +4910,9 @@ def get_masking_status(pkg, pkgsettings, root_config): if not pkgsettings._accept_chost(pkg.cpv, pkg.metadata): mreasons.append("CHOST: %s" % \ pkg.metadata["CHOST"]) + if pkg.invalid: + for msg in pkg.invalid: + mreasons.append("invalid: %s" % (msg,)) if not pkg.metadata["SLOT"]: mreasons.append("invalid: SLOT is undefined") diff --git a/pym/_emerge/visible.py b/pym/_emerge/visible.py index 8edcb89ca..6b013b4a4 100644 --- a/pym/_emerge/visible.py +++ b/pym/_emerge/visible.py @@ -21,6 +21,8 @@ def visible(pkgsettings, pkg): if not pkg.metadata["SLOT"]: return False if not pkg.installed: + if pkg.invalid: + return False if not pkgsettings._accept_chost(pkg.cpv, pkg.metadata): return False eapi = pkg.metadata["EAPI"] |