From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id BBC7A138334 for ; Sun, 1 Sep 2019 03:03:30 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 72CDAE0907; Sun, 1 Sep 2019 03:03:28 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 44BA9E0907 for ; Sun, 1 Sep 2019 03:03:28 +0000 (UTC) Received: from localhost.localdomain (unknown [IPv6:2600:8802:603:b800:4835:a21f:de70:f2aa]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: zmedico) by smtp.gentoo.org (Postfix) with ESMTPSA id A43E434A7C4; Sun, 1 Sep 2019 03:03:26 +0000 (UTC) From: Zac Medico To: gentoo-portage-dev@lists.gentoo.org Cc: Zac Medico Subject: [gentoo-portage-dev] [PATCH] _slot_confict_backtrack: consider masking a package matched by all parent atoms (bug 692746) Date: Sat, 31 Aug 2019 20:00:53 -0700 Message-Id: <20190901030053.23722-1-zmedico@gentoo.org> X-Mailer: git-send-email 2.21.0 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Archives-Salt: 958e4617-8495-4efb-b89e-9772052acbd1 X-Archives-Hash: 4d6c9814135359fd47e28240ac2b73b6 When a slot conflict occurs involving a package that is matched by all involved parent atoms, consider masking the package in order to avoid a possible missed update. The included unit test demonstrates the case fixed by this patch. There are 2 previously existing unit tests that require larger backtracking values in order to succeed with this patch, since more possible solutions are now considered. Bug: https://bugs.gentoo.org/692746 Signed-off-by: Zac Medico --- lib/_emerge/depgraph.py | 5 ++ lib/_emerge/resolver/backtracking.py | 9 +++ .../test_slot_conflict_update_virt.py | 79 +++++++++++++++++++ .../test_slot_operator_complete_graph.py | 2 +- .../test_slot_operator_runtime_pkg_mask.py | 2 +- 5 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 lib/portage/tests/resolver/test_slot_conflict_update_virt.py diff --git a/lib/_emerge/depgraph.py b/lib/_emerge/depgraph.py index 08240af67..6be1b3ec7 100644 --- a/lib/_emerge/depgraph.py +++ b/lib/_emerge/depgraph.py @@ -1768,6 +1768,11 @@ class depgraph(object): debug = "--debug" in self._frozen_config.myopts existing_node = next(self._dynamic_config._package_tracker.match( root, slot_atom, installed=False)) + if existing_node not in conflict_pkgs: + # Even though all parent atoms match existing_node, + # consider masking it in order to avoid a missed update + # as in bug 692746. + conflict_pkgs.append(existing_node) # In order to avoid a missed update, first mask lower versions # that conflict with higher versions (the backtracker visits # these in reverse order). diff --git a/lib/_emerge/resolver/backtracking.py b/lib/_emerge/resolver/backtracking.py index c29b9d42a..99e4565c8 100644 --- a/lib/_emerge/resolver/backtracking.py +++ b/lib/_emerge/resolver/backtracking.py @@ -135,11 +135,20 @@ class Backtracker(object): continue entry_is_valid = False + any_conflict_parents = False for ppkg, patom in runtime_pkg_mask[pkg].get("slot conflict", set()): + any_conflict_parents = True if ppkg not in runtime_pkg_mask: entry_is_valid = True break + else: + if not any_conflict_parents: + # Even though pkg was involved in a slot conflict + # where it was matched by all involved parent atoms, + # consider masking it in order to avoid a missed + # update as in bug 692746. + entry_is_valid = True if not entry_is_valid: return False diff --git a/lib/portage/tests/resolver/test_slot_conflict_update_virt.py b/lib/portage/tests/resolver/test_slot_conflict_update_virt.py new file mode 100644 index 000000000..ce89925ba --- /dev/null +++ b/lib/portage/tests/resolver/test_slot_conflict_update_virt.py @@ -0,0 +1,79 @@ +# Copyright 2019 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +from portage.tests import TestCase +from portage.tests.resolver.ResolverPlayground import (ResolverPlayground, + ResolverPlaygroundTestCase) + +class SlotConflictUpdateVirtTestCase(TestCase): + + def testSlotConflictUpdateVirt(self): + + ebuilds = { + "dev-db/mysql-connector-c-6.1.11-r2" : { + "EAPI": "7", + "SLOT" : "0/18" + }, + + "dev-db/mysql-connector-c-8.0.17-r3" : { + "EAPI": "7", + "SLOT" : "0/21" + }, + + "virtual/libmysqlclient-18-r1" : { + "EAPI": "7", + "SLOT" : "0/18", + "RDEPEND": "dev-db/mysql-connector-c:0/18", + }, + + "virtual/libmysqlclient-21" : { + "EAPI": "7", + "SLOT" : "0/21", + "RDEPEND": "dev-db/mysql-connector-c:0/21", + }, + + "dev-perl/DBD-mysql-4.44.0" : { + "EAPI": "7", + "RDEPEND": "virtual/libmysqlclient:=", + }, + } + + installed = { + "dev-db/mysql-connector-c-6.1.11-r2" : { + "EAPI": "7", + "SLOT" : "0/18" + }, + + "virtual/libmysqlclient-18-r1" : { + "EAPI": "7", + "SLOT" : "0/18", + "RDEPEND": "dev-db/mysql-connector-c:0/18", + }, + + "dev-perl/DBD-mysql-4.44.0" : { + "EAPI": "7", + "RDEPEND": "virtual/libmysqlclient:0/18=", + }, + } + + world = ["dev-db/mysql-connector-c", "dev-perl/DBD-mysql"] + + test_cases = ( + # In order to avoid missed updates for bug 692746, create a + # backtrack node for a downgrade matched by all parent atoms. + ResolverPlaygroundTestCase( + ['@world'], + options = {"--update": True, "--deep": True}, + success = True, + mergelist = ['dev-db/mysql-connector-c-8.0.17-r3', 'virtual/libmysqlclient-21', 'dev-perl/DBD-mysql-4.44.0']), + ) + + playground = ResolverPlayground(ebuilds=ebuilds, + installed=installed, world=world, debug=False) + 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.debug = False + playground.cleanup() diff --git a/lib/portage/tests/resolver/test_slot_operator_complete_graph.py b/lib/portage/tests/resolver/test_slot_operator_complete_graph.py index 1d59bcef1..4dcae71ca 100644 --- a/lib/portage/tests/resolver/test_slot_operator_complete_graph.py +++ b/lib/portage/tests/resolver/test_slot_operator_complete_graph.py @@ -115,7 +115,7 @@ class SlotOperatorCompleteGraphTestCase(TestCase): ResolverPlaygroundTestCase( ["=app-misc/meta-pkg-2", "app-misc/C"], options = { - "--backtrack": 5, + "--backtrack": 9, }, success = True, ambiguous_merge_order = True, diff --git a/lib/portage/tests/resolver/test_slot_operator_runtime_pkg_mask.py b/lib/portage/tests/resolver/test_slot_operator_runtime_pkg_mask.py index 0a5a7fa78..f8b53e2b5 100644 --- a/lib/portage/tests/resolver/test_slot_operator_runtime_pkg_mask.py +++ b/lib/portage/tests/resolver/test_slot_operator_runtime_pkg_mask.py @@ -110,7 +110,7 @@ class SlotOperatorRuntimePkgMaskTestCase(TestCase): ResolverPlaygroundTestCase( ["=app-misc/meta-pkg-2"], options = { - "--backtrack": 5, + "--backtrack": 12, }, success = True, ambiguous_merge_order = True, -- 2.21.0