Add a IUSE.missing repoman category for packages that have a USE
authorZac Medico <zmedico@gentoo.org>
Fri, 27 Aug 2010 05:43:31 +0000 (22:43 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 27 Aug 2010 05:43:31 +0000 (22:43 -0700)
conditional which references a flag that is not listed in IUSE.
Also split out a Package._metadata_exception() method to handle
IUSE.missing for *DEPEND and SRC_URI.

bin/repoman
man/repoman.1
pym/_emerge/Package.py
pym/portage/dep/__init__.py
pym/portage/exception.py

index 953a4912fe1ab6f190336853491e71c5713f5ada..bf40d896cb7d1fe8a95e7aacb13537636f9a5966 100755 (executable)
@@ -336,6 +336,7 @@ qahelp={
        "LIVEVCS.stable":"This ebuild is a live checkout from a VCS but has stable keywords.",
        "LIVEVCS.unmasked":"This ebuild is a live checkout from a VCS but has keywords and is not masked in the global package.mask.",
        "IUSE.invalid":"This ebuild has a variable in IUSE that is not in the use.desc or its metadata.xml file",
+       "IUSE.missing":"This ebuild has a USE conditional which references a flag that is not listed in IUSE",
        "IUSE.undefined":"This ebuild does not define IUSE (style guideline says to define IUSE even when empty)",
        "LICENSE.invalid":"This ebuild is listing a license that doesnt exist in portages license/ dir.",
        "KEYWORDS.invalid":"This ebuild contains KEYWORDS that are not listed in profiles/arch.list or for which no valid profile was found",
index 28216d6e8bc4e68410f13fd8dcbff28d0256ef06..a1d2403927a2df9edfa96632cc302f5db43346cf 100644 (file)
@@ -134,6 +134,9 @@ Virtuals that have a non-empty HOMEPAGE variable
 .B IUSE.invalid
 This ebuild has a variable in IUSE that is not in the use.desc or its metadata.xml file
 .TP
+.B IUSE.missing
+This ebuild has a USE conditional which references a flag that is not listed in IUSE
+.TP
 .B IUSE.undefined
 This ebuild does not define IUSE (style guideline says to define IUSE even when empty)
 .TP
index 495686ff4dafe81f589866d84f2542411e3202c9..f9b42f0de83aa693bb666c47475d006f55508234 100644 (file)
@@ -87,27 +87,7 @@ class Package(Task):
                                use_reduce(v, eapi=dep_eapi,
                                        is_valid_flag=dep_valid_flag, token_class=Atom)
                        except portage.exception.InvalidDependString as e:
-                               if not self.installed:
-                                       categorized_error = False
-                                       if e.errors:
-                                               for error in e.errors:
-                                                       if getattr(error, 'category', None) is None:
-                                                               continue
-                                                       categorized_error = True
-                                                       self._invalid_metadata(error.category,
-                                                               "%s: %s" % (k, error))
-
-                                       if not categorized_error:
-                                               self._invalid_metadata(k + ".syntax",
-                                                       "%s: %s" % (k, e))
-                               else:
-                                       # For installed packages, show the path of the file
-                                       # containing the invalid metadata, since the user may
-                                       # want to fix the deps by hand.
-                                       vardb = self.root_config.trees['vartree'].dbapi
-                                       path = vardb.getpath(self.cpv, filename=k)
-                                       self._invalid_metadata(k + ".syntax",
-                                               "%s: %s in '%s'" % (k, e, path))
+                               self._metadata_exception(k, e)
 
                k = 'REQUIRED_USE'
                v = self.metadata.get(k)
@@ -131,7 +111,7 @@ class Package(Task):
                                        is_valid_flag=self.iuse.is_valid_flag)
                        except portage.exception.InvalidDependString as e:
                                if not self.installed:
-                                       self._invalid_metadata(k + ".syntax", "%s: %s" % (k, e))
+                                       self._metadata_exception(k, e)
 
        def copy(self):
                return Package(built=self.built, cpv=self.cpv, depth=self.depth,
@@ -216,6 +196,29 @@ class Package(Task):
 
                return True
 
+       def _metadata_exception(self, k, e):
+               if not self.installed:
+                       categorized_error = False
+                       if e.errors:
+                               for error in e.errors:
+                                       if getattr(error, 'category', None) is None:
+                                               continue
+                                       categorized_error = True
+                                       self._invalid_metadata(error.category,
+                                               "%s: %s" % (k, error))
+
+                       if not categorized_error:
+                               self._invalid_metadata(k + ".syntax",
+                                       "%s: %s" % (k, e))
+               else:
+                       # For installed packages, show the path of the file
+                       # containing the invalid metadata, since the user may
+                       # want to fix the deps by hand.
+                       vardb = self.root_config.trees['vartree'].dbapi
+                       path = vardb.getpath(self.cpv, filename=k)
+                       self._invalid_metadata(k + ".syntax",
+                               "%s: %s in '%s'" % (k, e, path))
+
        def _invalid_metadata(self, msg_type, msg):
                if self.invalid is None:
                        self.invalid = {}
index 499b43fc0312f2fcce6a3b8cbed128b5b800ba21..36b655f7c97ddfaf49948108e84544f82f7ade14 100644 (file)
@@ -307,9 +307,11 @@ def use_reduce(depstr, uselist=[], masklist=[], matchall=False, excludeall=[], i
                
                if is_valid_flag:
                        if not is_valid_flag(flag):
-                               raise portage.exception.InvalidDependString(
-                                       _("use flag '%s' is not referencable in conditional '%s' (flag missing from IUSE?)") \
-                                               % (flag, conditional))
+                               msg = _("USE flag '%s' referenced in " + \
+                                       "conditional '%s' is not in IUSE") \
+                                       % (flag, conditional)
+                               e = InvalidData(msg, category='IUSE.missing')
+                               raise portage.exception.InvalidDependString(msg, errors=(e,))
                else:
                        if _valid_use_re.match(flag) is None:
                                raise portage.exception.InvalidDependString(
index b289b6285dc2a23199d0943452f1e388d3618704..9564af98a1298853ac01dd077e8fd3c4dd8b2391 100644 (file)
@@ -52,6 +52,9 @@ class ParseError(PortageException):
 
 class InvalidData(PortageException):
        """An incorrect formatting was passed instead of the expected one"""
+       def __init__(self, value, category=None):
+               PortageException.__init__(self, value)
+               self.category = category
 
 class InvalidDataType(PortageException):
        """An incorrect type was passed instead of the expected one"""