From 23926b159418c22f053f74b217e1a6378816739c Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 26 Aug 2010 20:21:02 -0700 Subject: [PATCH] Bug #334365 - When depgraph.display_problems() shows the message 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 | 10 +++++++++- pym/_emerge/Package.py | 31 ++++++++++++++++++++----------- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/pym/_emerge/FakeVartree.py b/pym/_emerge/FakeVartree.py index c74092d55..1d6a1aa67 100644 --- a/pym/_emerge/FakeVartree.py +++ b/pym/_emerge/FakeVartree.py @@ -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 diff --git a/pym/_emerge/Package.py b/pym/_emerge/Package.py index 03f15b1c1..1209c6d9e 100644 --- a/pym/_emerge/Package.py +++ b/pym/_emerge/Package.py @@ -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) -- 2.26.2