* Add a Package.invalid attribute to store messages about invalid LICENSE,
authorZac Medico <zmedico@gentoo.org>
Thu, 25 Jun 2009 06:06:14 +0000 (06:06 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 25 Jun 2009 06:06:14 +0000 (06:06 -0000)
  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

pym/_emerge/Package.py
pym/_emerge/depgraph.py
pym/_emerge/visible.py

index 1ccd9254b94755bbbaddd66c7d709c840ecaa6e6..88adbf55fff79f496b6efc00f381ce630d26b5e9 100644 (file)
@@ -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):
index 29fada52fa93b090925cad1d61b45d8870653b00..e69a2027859f72d803f80ff4b69e4420319a3557 100644 (file)
@@ -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")
index 8edcb89caf8729bb8738d655903b1b6e2212f6ad..6b013b4a48fa3838aefdc2f679554fdab0f29aa7 100644 (file)
@@ -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"]