Bug #334365 - When depgraph.display_problems() shows the message
authorZac Medico <zmedico@gentoo.org>
Fri, 27 Aug 2010 03:21:02 +0000 (20:21 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 27 Aug 2010 03:21:02 +0000 (20:21 -0700)
about masked installed packages, customize the InvalidDependString
display to show the path of the *DEPEND file that contains the
invalid dependency.

pym/_emerge/FakeVartree.py
pym/_emerge/Package.py

index c74092d55055045c837b3c4e198a800ef665407f..1d6a1aa67b28743e6fc015a401c04b01568c22b9 100644 (file)
@@ -7,12 +7,20 @@ import portage
 from portage import os
 from _emerge.Package import Package
 from _emerge.PackageVirtualDbapi import PackageVirtualDbapi
+from portage.const import VDB_PATH
 from portage.dbapi.vartree import vartree
 from portage.update import grab_updates, parse_updates, update_dbentries
 
 if sys.hexversion >= 0x3000000:
        long = int
 
+class FakeVardbapi(PackageVirtualDbapi):
+       def getpath(self, cpv, filename=None):
+               path = os.path.join(self.settings['EROOT'], VDB_PATH, cpv)
+               if filename is not None:
+                       path =os.path.join(path, filename)
+               return path
+
 class FakeVartree(vartree):
        """This is implements an in-memory copy of a vartree instance that provides
        all the interfaces required for use by the depgraph.  The vardb is locked
@@ -37,7 +45,7 @@ class FakeVartree(vartree):
                        mykeys.append("_mtime_")
                self._db_keys = mykeys
                self._pkg_cache = pkg_cache
-               self.dbapi = PackageVirtualDbapi(real_vartree.settings)
+               self.dbapi = FakeVardbapi(real_vartree.settings)
 
                # Intialize variables needed for lazy cache pulls of the live ebuild
                # metadata.  This ensures that the vardb lock is released ASAP, without
index 03f15b1c155a93302b19457c8f33405c168c7a68..1209c6d9e48a504880183d7972d8470a68282ddb 100644 (file)
@@ -76,18 +76,27 @@ class Package(Task):
                                use_reduce(v, eapi=eapi,
                                        is_valid_flag=self.iuse.is_valid_flag, token_class=Atom)
                        except portage.exception.InvalidDependString as e:
-                               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:
+                               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" % (k, e))
+                                               "%s: %s in '%s'" % (k, e, path))
 
                k = 'REQUIRED_USE'
                v = self.metadata.get(k)