reposyntax: Print cpv from all repos for "masked by" messages
authorSebastian Luther <SebastianLuther@gmx.de>
Wed, 22 Sep 2010 07:45:27 +0000 (09:45 +0200)
committerZac Medico <zmedico@gentoo.org>
Mon, 27 Sep 2010 06:50:14 +0000 (23:50 -0700)
pym/_emerge/PackageVirtualDbapi.py
pym/_emerge/depgraph.py
pym/portage/dbapi/bintree.py
pym/portage/dbapi/porttree.py
pym/portage/dbapi/vartree.py
pym/portage/tests/resolver/test_multirepo.py

index 129a516150e0a37172eac142b88b2001dfc2ffe1..3728f2ae3b3d4be9e65877bfdc3387266d81fe52 100644 (file)
@@ -83,7 +83,7 @@ class PackageVirtualDbapi(dbapi):
                self._match_cache[origdep] = result
                return result[:]
 
-       def cpv_exists(self, cpv):
+       def cpv_exists(self, cpv, myrepo=None):
                return cpv in self._cpv_map
 
        def cp_list(self, mycp, use_cache=1):
index 966a9c5efc913214694f4bf5f034f5b868a300dc..eb4819bcd099254d906b237827aaab4470db48c5 100644 (file)
@@ -15,7 +15,7 @@ from portage import os
 from portage import _unicode_decode
 from portage.const import PORTAGE_PACKAGE_ATOM
 from portage.dbapi import dbapi
-from portage.dep import Atom, extract_affecting_use, check_required_use, human_readable_required_use
+from portage.dep import Atom, extract_affecting_use, check_required_use, human_readable_required_use, _repo_separator
 from portage.eapi import eapi_has_strong_blocks, eapi_has_required_use
 from portage.exception import InvalidAtom
 from portage.output import colorize, create_color_func, \
@@ -2141,52 +2141,62 @@ class depgraph(object):
                                cpv_list = db.xmatch("match-all", atom.without_use)
                        else:
                                cpv_list = db.match(atom.without_use)
+
+                       if atom.repo is None and hasattr(db, "getRepositories"):
+                               repo_list = db.getRepositories()
+                       else:
+                               repo_list = [atom.repo]
+
                        # descending order
                        cpv_list.reverse()
                        for cpv in cpv_list:
-                               metadata, mreasons  = get_mask_info(root_config, cpv, pkgsettings, db, pkg_type, \
-                                       built, installed, db_keys, myrepo=atom.repo, _pkg_use_enabled=self._pkg_use_enabled)
-
-                               if metadata is not None:
-                                       pkg = self._pkg(cpv, pkg_type, root_config,
-                                               installed=installed, myrepo = atom.repo)
-                                       # pkg.metadata contains calculated USE for ebuilds,
-                                       # required later for getMissingLicenses.
-                                       metadata = pkg.metadata
-                                       if pkg.cp != atom.cp:
-                                               # A cpv can be returned from dbapi.match() as an
-                                               # old-style virtual match even in cases when the
-                                               # package does not actually PROVIDE the virtual.
-                                               # Filter out any such false matches here.
-                                               if not atom_set.findAtomForPackage(pkg, modified_use=self._pkg_use_enabled(pkg)):
-                                                       continue
-                                       if pkg in self._dynamic_config._runtime_pkg_mask:
-                                               backtrack_reasons = \
-                                                       self._dynamic_config._runtime_pkg_mask[pkg]
-                                               mreasons.append('backtracking: %s' % \
-                                                       ', '.join(sorted(backtrack_reasons)))
-                                               backtrack_mask = True
-                                       if not mreasons and self._frozen_config.excluded_pkgs.findAtomForPackage(pkg, \
-                                               modified_use=self._pkg_use_enabled(pkg)):
-                                               mreasons = ["exclude option"]
-                                       if mreasons:
-                                               masked_pkg_instances.add(pkg)
-                                       if atom.unevaluated_atom.use:
-                                               try:
-                                                       if not pkg.iuse.is_valid_flag(atom.unevaluated_atom.use.required) \
-                                                               or atom.violated_conditionals(self._pkg_use_enabled(pkg), pkg.iuse.is_valid_flag).use:
-                                                               missing_use.append(pkg)
-                                                               if not mreasons:
-                                                                       continue
-                                               except InvalidAtom:
-                                                       writemsg("violated_conditionals raised " + \
-                                                               "InvalidAtom: '%s' parent: %s" % \
-                                                               (atom, myparent), noiselevel=-1)
-                                                       raise
-                                       if pkg.built and not mreasons:
-                                               mreasons = ["use flag configuration mismatch"]
-                               masked_packages.append(
-                                       (root_config, pkgsettings, cpv, metadata, mreasons))
+                               for repo in repo_list:
+                                       if not db.cpv_exists(cpv, myrepo=repo):
+                                               continue
+
+                                       metadata, mreasons  = get_mask_info(root_config, cpv, pkgsettings, db, pkg_type, \
+                                               built, installed, db_keys, myrepo=repo, _pkg_use_enabled=self._pkg_use_enabled)
+
+                                       if metadata is not None:
+                                               pkg = self._pkg(cpv, pkg_type, root_config,
+                                                       installed=installed, myrepo=repo)
+                                               # pkg.metadata contains calculated USE for ebuilds,
+                                               # required later for getMissingLicenses.
+                                               metadata = pkg.metadata
+                                               if pkg.cp != atom.cp:
+                                                       # A cpv can be returned from dbapi.match() as an
+                                                       # old-style virtual match even in cases when the
+                                                       # package does not actually PROVIDE the virtual.
+                                                       # Filter out any such false matches here.
+                                                       if not atom_set.findAtomForPackage(pkg, modified_use=self._pkg_use_enabled(pkg)):
+                                                               continue
+                                               if pkg in self._dynamic_config._runtime_pkg_mask:
+                                                       backtrack_reasons = \
+                                                               self._dynamic_config._runtime_pkg_mask[pkg]
+                                                       mreasons.append('backtracking: %s' % \
+                                                               ', '.join(sorted(backtrack_reasons)))
+                                                       backtrack_mask = True
+                                               if not mreasons and self._frozen_config.excluded_pkgs.findAtomForPackage(pkg, \
+                                                       modified_use=self._pkg_use_enabled(pkg)):
+                                                       mreasons = ["exclude option"]
+                                               if mreasons:
+                                                       masked_pkg_instances.add(pkg)
+                                               if atom.unevaluated_atom.use:
+                                                       try:
+                                                               if not pkg.iuse.is_valid_flag(atom.unevaluated_atom.use.required) \
+                                                                       or atom.violated_conditionals(self._pkg_use_enabled(pkg), pkg.iuse.is_valid_flag).use:
+                                                                       missing_use.append(pkg)
+                                                                       if not mreasons:
+                                                                               continue
+                                                       except InvalidAtom:
+                                                               writemsg("violated_conditionals raised " + \
+                                                                       "InvalidAtom: '%s' parent: %s" % \
+                                                                       (atom, myparent), noiselevel=-1)
+                                                               raise
+                                               if pkg.built and not mreasons:
+                                                       mreasons = ["use flag configuration mismatch"]
+                                       masked_packages.append(
+                                               (root_config, pkgsettings, cpv, repo, metadata, mreasons))
 
                if check_backtrack:
                        if backtrack_mask:
@@ -2472,6 +2482,9 @@ class depgraph(object):
                        cpv_list.reverse()
                        for cpv in cpv_list:
                                for repo in repo_list:
+                                       if not db.cpv_exists(cpv, myrepo=repo):
+                                               continue
+
                                        try:
                                                pkg = self._pkg(cpv, pkg_type, root_config,
                                                        installed=installed, onlydeps=onlydeps, myrepo=repo)
@@ -4833,7 +4846,7 @@ class depgraph(object):
                        pkgsettings = self._frozen_config.pkgsettings[pkg.root]
                        mreasons = get_masking_status(pkg, pkgsettings, root_config, use=self._pkg_use_enabled(pkg))
                        masked_packages.append((root_config, pkgsettings,
-                               pkg.cpv, pkg.metadata, mreasons))
+                               pkg.cpv, pkg.repo, pkg.metadata, mreasons))
                if masked_packages:
                        writemsg("\n" + colorize("BAD", "!!!") + \
                                " The following updates are masked by LICENSE changes:\n",
@@ -4848,7 +4861,7 @@ class depgraph(object):
                        pkgsettings = self._frozen_config.pkgsettings[pkg.root]
                        mreasons = get_masking_status(pkg, pkgsettings, root_config, use=self._pkg_use_enabled)
                        masked_packages.append((root_config, pkgsettings,
-                               pkg.cpv, pkg.metadata, mreasons))
+                               pkg.cpv, "installed", pkg.metadata, mreasons))
                if masked_packages:
                        writemsg("\n" + colorize("BAD", "!!!") + \
                                " The following installed packages are masked:\n",
@@ -5544,11 +5557,12 @@ def show_masked_packages(masked_packages):
        # show one of them to avoid redundant appearance.
        shown_cpvs = set()
        have_eapi_mask = False
-       for (root_config, pkgsettings, cpv,
+       for (root_config, pkgsettings, cpv, repo,
                metadata, mreasons) in masked_packages:
-               if cpv in shown_cpvs:
+               output_cpv = cpv + _repo_separator + repo
+               if output_cpv in shown_cpvs:
                        continue
-               shown_cpvs.add(cpv)
+               shown_cpvs.add(output_cpv)
                comment, filename = None, None
                if "package.mask" in mreasons:
                        comment, filename = \
@@ -5570,7 +5584,7 @@ def show_masked_packages(masked_packages):
                                # above via mreasons.
                                pass
 
-               writemsg_stdout("- "+cpv+" (masked by: "+", ".join(mreasons)+")\n", noiselevel=-1)
+               writemsg_stdout("- "+output_cpv+" (masked by: "+", ".join(mreasons)+")\n", noiselevel=-1)
 
                if comment and comment not in shown_comments:
                        writemsg_stdout(filename + ":\n" + comment + "\n",
index a5a916b8e61c8d7c02e43f6c9c8e67ba3311babc..03cfdb1788ffed047b9b4b6eab4aaa24b07148df 100644 (file)
@@ -75,7 +75,7 @@ class bindbapi(fakedbapi):
                        self.bintree.populate()
                return fakedbapi.match(self, *pargs, **kwargs)
 
-       def cpv_exists(self, cpv):
+       def cpv_exists(self, cpv, myrepo=None):
                if self.bintree and not self.bintree.populated:
                        self.bintree.populate()
                return fakedbapi.cpv_exists(self, cpv)
index d84c459d0e73aef082ca93f8632c08a7ff0672d1..d5fb0a18c4cad90ee737ee7fb2f4c85cd2f2649f 100644 (file)
@@ -764,14 +764,14 @@ class portdbapi(dbapi):
                        return False
                return True
 
-       def cpv_exists(self, mykey):
+       def cpv_exists(self, mykey, myrepo=None):
                "Tells us whether an actual ebuild exists on disk (no masking)"
                cps2 = mykey.split("/")
                cps = catpkgsplit(mykey, silent=0)
                if not cps:
                        #invalid cat/pkg-v
                        return 0
-               if self.findname(cps[0] + "/" + cps2[1]):
+               if self.findname(cps[0] + "/" + cps2[1], myrepo=myrepo):
                        return 1
                else:
                        return 0
index 239b0d761f5bd258fb80d18d9b456a6609a090f1..b76b669552fe819318d7aa7802d8f9a02f0c5b36 100644 (file)
@@ -184,7 +184,7 @@ class vardbapi(dbapi):
                except OSError:
                        ensure_dirs(catdir)
 
-       def cpv_exists(self, mykey):
+       def cpv_exists(self, mykey, myrepo=None):
                "Tells us whether an actual ebuild exists on disk (no masking)"
                return os.path.exists(self.getpath(mykey))
 
index dfa9b0c1904e12bcaeb384a552ca324b9e21ae9c..14ca0ff00e23115b4fbf41968cfdb0d3482a3f3b 100644 (file)
@@ -145,6 +145,8 @@ class MultirepoTestCase(TestCase):
                        #package.mask
                        "dev-libs/E-1": { },
                        "dev-libs/E-1::repo1": { },
+                       "dev-libs/H-1": { },
+                       "dev-libs/H-1::repo1": { },
 
                        #package.properties
                        "dev-libs/F-1": { "PROPERTIES": "bar"},
@@ -171,6 +173,7 @@ class MultirepoTestCase(TestCase):
                        "package.mask":
                                (
                                        "dev-libs/E::repo1",
+                                       "dev-libs/H",
                                        #needed for package.unmask test
                                        "dev-libs/G",
                                ),
@@ -236,9 +239,12 @@ class MultirepoTestCase(TestCase):
                                success = True,
                                check_repo_names = True,
                                mergelist = ["dev-libs/G-1"]),
+                       ResolverPlaygroundTestCase(
+                               ["dev-libs/H"],
+                               success = False),
                        )
 
-               playground = ResolverPlayground(ebuilds=ebuilds, user_config=user_config)
+               playground = ResolverPlayground(ebuilds=ebuilds, user_config=user_config, debug=True)
                try:
                        for test_case in test_cases:
                                playground.run_TestCase(test_case)