[PATCH] _slot_confict_backtrack: consider masking a package matched by all parent atoms (bug 692746)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] _slot_confict_backtrack: consider masking a package matched by all parent atoms (bug 692746)

Zac Medico-2
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 <[hidden email]>
---
 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