From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1R2qsE-0002iS-VQ for garchives@archives.gentoo.org; Sun, 11 Sep 2011 20:43:31 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E9B1921C0C6; Sun, 11 Sep 2011 20:43:23 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 9F56721C0C6 for ; Sun, 11 Sep 2011 20:43:23 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id F209E1B4009 for ; Sun, 11 Sep 2011 20:43:22 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 2EAA080042 for ; Sun, 11 Sep 2011 20:43:22 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/tests/resolver/, pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/depgraph.py pym/portage/tests/resolver/test_virtual_slot.py X-VCS-Directories: pym/portage/tests/resolver/ pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: b95cbb6b78ad6d9b8e2d3edc5fafff122c3ce7c5 Date: Sun, 11 Sep 2011 20:43:22 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: e89de6e2f0856a40a5de432f965658d7 commit: b95cbb6b78ad6d9b8e2d3edc5fafff122c3ce7c5 Author: Zac Medico gentoo org> AuthorDate: Sun Sep 11 20:43:10 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Sun Sep 11 20:43:10 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Db95cbb6b depgraph: pull in new virtual slots with --update This re-implements the fix from commit 21330075f07248765016e104b3ba8216903f1ecb, without introducing the unwanted behavior reported in bug 382557. This involves checking the direct dependencies of virtual slot updates to make sure they are all visible, before pulling them in. --- pym/_emerge/depgraph.py | 69 +++++++++++++++++= ++---- pym/portage/tests/resolver/test_virtual_slot.py | 47 +++++++++++++++ 2 files changed, 105 insertions(+), 11 deletions(-) diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 6a04a79..1e311e8 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -2500,24 +2500,36 @@ class depgraph(object): # account for masking and USE settings. _autounmask_backup =3D self._dynamic_config._autounmask self._dynamic_config._autounmask =3D False - mytrees["pkg_use_enabled"] =3D self._pkg_use_enabled + # backup state for restoration, in case of recursive + # calls to this method + backup_state =3D mytrees.copy() try: + # clear state from previous call, in case this + # call is recursive (we have a backup, that we + # will use to restore it later) + mytrees.pop("pkg_use_enabled", None) + mytrees.pop("parent", None) + mytrees.pop("atom_graph", None) + mytrees.pop("priority", None) + + mytrees["pkg_use_enabled"] =3D self._pkg_use_enabled if parent is not None: - trees[root]["parent"] =3D parent - trees[root]["atom_graph"] =3D atom_graph + mytrees["parent"] =3D parent + mytrees["atom_graph"] =3D atom_graph if priority is not None: - trees[root]["priority"] =3D priority + mytrees["priority"] =3D priority + mycheck =3D portage.dep_check(depstring, None, pkgsettings, myuse=3Dmyuse, myroot=3Droot, trees=3Dtrees) finally: + # restore state self._dynamic_config._autounmask =3D _autounmask_backup - del mytrees["pkg_use_enabled"] - if parent is not None: - trees[root].pop("parent") - trees[root].pop("atom_graph") - if priority is not None: - trees[root].pop("priority") + mytrees.pop("pkg_use_enabled", None) + mytrees.pop("parent", None) + mytrees.pop("atom_graph", None) + mytrees.pop("priority", None) + mytrees.update(backup_state) if not mycheck[0]: raise portage.exception.InvalidDependString(mycheck[1]) if parent is None: @@ -2611,6 +2623,38 @@ class depgraph(object): continue yield atom =20 + def _virt_deps_visible(self, pkg, ignore_use=3DFalse): + """ + Assumes pkg is a virtual package. Traverses virtual deps recursively + and returns True if all deps are visible, False otherwise. This is + useful for checking if it will be necessary to expand virtual slots, + for cases like bug #382557. + """ + try: + rdepend =3D self._select_atoms( + pkg.root, pkg.metadata.get("RDEPEND", ""), + myuse=3Dself._pkg_use_enabled(pkg), + parent=3Dpkg, priority=3Dself._priority(runtime=3DTrue)) + except InvalidDependString as e: + if not pkg.installed: + raise + writemsg_level("!!! Invalid RDEPEND in " + \ + "'%svar/db/pkg/%s/RDEPEND': %s\n" % \ + (pkg.root, pkg.cpv, e), + noiselevel=3D-1, level=3Dlogging.ERROR) + return False + + for atoms in rdepend.values(): + for atom in atoms: + if ignore_use: + atom =3D atom.without_use + pkg, existing =3D self._select_package( + pkg.root, atom) + if pkg is None or not self._pkg_visibility_check(pkg): + return False + + return True + def _get_dep_chain(self, start_node, target_atom=3DNone, unsatisfied_dependency=3DFalse): """ @@ -6540,7 +6584,10 @@ class _dep_check_composite_db(dbapi): =20 if pkg is not None and \ atom.slot is None and \ - pkg.cp.startswith("virtual/"): + pkg.cp.startswith("virtual/") and \ + ("--update" not in self._depgraph._frozen_config.myopts or + not ret or + not self._depgraph._virt_deps_visible(pkg, ignore_use=3DTrue)): # For new-style virtual lookahead that occurs inside dep_check() # for bug #141118, examine all slots. This is needed so that newer # slots will not unnecessarily be pulled in when a satisfying lower diff --git a/pym/portage/tests/resolver/test_virtual_slot.py b/pym/portag= e/tests/resolver/test_virtual_slot.py index 40ed73b..fb24201 100644 --- a/pym/portage/tests/resolver/test_virtual_slot.py +++ b/pym/portage/tests/resolver/test_virtual_slot.py @@ -44,3 +44,50 @@ class VirtualSlotResolverTestCase(TestCase): self.assertEqual(test_case.test_success, True, test_case.fail_msg) finally: playground.cleanup() + + def testVirtualSlotUpdate(self): + + ebuilds =3D { + "dev-java/oracle-jdk-bin-1.7.0" : {"SLOT": "1.7", "LICENSE": "TEST"}, + "dev-java/sun-jdk-1.6.0" : {"SLOT": "1.6", "LICENSE": "TEST"}, + "dev-java/icedtea-6.1.10.3" : {"SLOT": "6"}, + "dev-java/icedtea-7" : {"SLOT": "7"}, + "app-misc/java-app-1": {"RDEPEND": ">=3Dvirtual/jdk-1.6.0"}, + "virtual/jdk-1.6.0": {"SLOT": "1.6", "RDEPEND": "|| ( =3Ddev-java/ice= dtea-6* =3Ddev-java/sun-jdk-1.6.0* )"}, + "virtual/jdk-1.7.0": {"SLOT": "1.7", "RDEPEND": "|| ( =3Ddev-java/ice= dtea-7* =3Ddev-java/oracle-jdk-bin-1.7.0* )"}, + } + + installed =3D { + "app-misc/java-app-1": {"RDEPEND": ">=3Dvirtual/jdk-1.6.0"}, + "dev-java/icedtea-6.1.10.3" : {"SLOT": "6"}, + "virtual/jdk-1.6.0": {"SLOT" : "1.6", "RDEPEND": "|| ( =3Ddev-java/ic= edtea-6* =3Ddev-java/sun-jdk-1.6.0* )"}, + } + + world =3D ("app-misc/java-app",) + + test_cases =3D ( + # Pull in the virtual/jdk-1.7.0 slot update since its dependencies + # can only be satisfied by an unmasked package. + ResolverPlaygroundTestCase( + ["@world"], + options =3D {"--update" : True, "--deep" : True}, + success =3D True, + mergelist =3D ["dev-java/icedtea-7", "virtual/jdk-1.7.0"]), + + # Bug #275945 - Don't pull in the virtual/jdk-1.7.0 slot update + # unless --update is enabled. + ResolverPlaygroundTestCase( + ["@world"], + options =3D {"--selective" : True, "--deep" : True}, + success =3D True, + mergelist =3D []), + ) + + playground =3D ResolverPlayground( + ebuilds=3Debuilds, installed=3Dinstalled, world=3Dworld) + try: + for test_case in test_cases: + playground.run_TestCase(test_case) + self.assertEqual(test_case.test_success, True, test_case.fail_msg) + finally: + playground.cleanup()