From e92bdc4e4b955a93409f64bcc5aac5b6333234de Mon Sep 17 00:00:00 2001 From: Sebastian Luther Date: Wed, 22 Sep 2010 09:45:27 +0200 Subject: reposyntax: Print cpv from all repos for "masked by" messages --- pym/_emerge/PackageVirtualDbapi.py | 2 +- pym/_emerge/depgraph.py | 114 +++++++++++++++------------ pym/portage/dbapi/bintree.py | 2 +- pym/portage/dbapi/porttree.py | 4 +- pym/portage/dbapi/vartree.py | 2 +- pym/portage/tests/resolver/test_multirepo.py | 8 +- 6 files changed, 76 insertions(+), 56 deletions(-) diff --git a/pym/_emerge/PackageVirtualDbapi.py b/pym/_emerge/PackageVirtualDbapi.py index 129a51615..3728f2ae3 100644 --- a/pym/_emerge/PackageVirtualDbapi.py +++ b/pym/_emerge/PackageVirtualDbapi.py @@ -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): diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 966a9c5ef..eb4819bcd 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -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", diff --git a/pym/portage/dbapi/bintree.py b/pym/portage/dbapi/bintree.py index a5a916b8e..03cfdb178 100644 --- a/pym/portage/dbapi/bintree.py +++ b/pym/portage/dbapi/bintree.py @@ -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) diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index d84c459d0..d5fb0a18c 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -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 diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 239b0d761..b76b66955 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -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)) diff --git a/pym/portage/tests/resolver/test_multirepo.py b/pym/portage/tests/resolver/test_multirepo.py index dfa9b0c19..14ca0ff00 100644 --- a/pym/portage/tests/resolver/test_multirepo.py +++ b/pym/portage/tests/resolver/test_multirepo.py @@ -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) -- cgit v1.2.3-1-g7c22