commit: d77d933b4a9cb2b830e661806a2a8689ffbac0ef
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 1 04:53:45 2020 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sat Feb 1 20:54:11 2020 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=d77d933b
depclean: do not eliminate upgrades (bug 707108)
For depclean actions, prefer choices where all packages have been
pulled into the graph, except for choices that eliminate upgrades.
This solves the test case for bug 707108, where depclean eliminated
a new slot of python that had been pulled in by a world update.
This should also prevent non-deterministic elimination of the
latest vala slot that was reported in bug 693790.
NOTE: There's a common perception (expressed in bug 705700) that
emerge is pulling in an "unecessary" python slot in cases when that
python slot is not enabled in PYTHON_TARGETS. However, the so-called
"unnecessary" slot is practically indistinguishable from a desirable
upgrade such as the missed llvm slot upgrade that was reported in
bug 706278. Therefore, be advised that emerge must pull in the
highest visible slot (regardless of PYTHON_TARGETS) in order to
ensure that a desirable upgrade is not missed.
Fixes: f7d83d75c6b0 ("dep_zapdeps: adjust || preference for slot upgrades (bug
706278)")
Bug: https://bugs.gentoo.org/707108
Bug: https://bugs.gentoo.org/706278
Bug: https://bugs.gentoo.org/705700
Bug: https://bugs.gentoo.org/693790
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>
lib/portage/dep/dep_check.py | 23 +++++++++++++----------
lib/portage/tests/resolver/test_or_choices.py | 4 ++--
2 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/lib/portage/dep/dep_check.py b/lib/portage/dep/dep_check.py
index a7ae2cfa4..8adb92da2 100644
--- a/lib/portage/dep/dep_check.py
+++ b/lib/portage/dep/dep_check.py
@@ -690,17 +690,12 @@ def dep_zapdeps(unreduced, reduced, myroot,
use_binaries=0, trees=None,
# choice_1 will not be promoted, so
move on
break
if (
- # For removal actions, prefer choices
where all packages
- # have been pulled into the graph.
- (graph_interface and
graph_interface.removal_action and
- choice_1.all_in_graph and not
choice_2.all_in_graph)
-
# Prefer choices where
all_installed_slots is True, except
# in cases where we want to upgrade to
a new slot as in
# bug 706278. Don't compare
new_slot_count here since that
# would aggressively override the
preference order defined
# in the ebuild, breaking the test case
for bug 645002.
- or (choice_1.all_installed_slots and
+ (choice_1.all_installed_slots and
not choice_2.all_installed_slots and
not choice_2.want_update)
):
@@ -711,8 +706,6 @@ def dep_zapdeps(unreduced, reduced, myroot, use_binaries=0,
trees=None,
break
intersecting_cps =
cps.intersection(choice_2.cp_map)
- if not intersecting_cps:
- continue
has_upgrade = False
has_downgrade = False
for cp in intersecting_cps:
@@ -724,8 +717,18 @@ def dep_zapdeps(unreduced, reduced, myroot,
use_binaries=0, trees=None,
has_upgrade = True
else:
has_downgrade = True
- break
- if has_upgrade and not has_downgrade:
+
+ if (
+ # Prefer upgrades.
+ (has_upgrade and not has_downgrade)
+
+ # For removal actions, prefer choices
where all packages
+ # have been pulled into the graph,
except for choices that
+ # eliminate upgrades.
+ or (graph_interface and
graph_interface.removal_action and
+ choice_1.all_in_graph and not
choice_2.all_in_graph and
+ not (has_downgrade and not has_upgrade))
+ ):
# promote choice_1 in front of choice_2
choices.remove(choice_1)
index_2 = choices.index(choice_2)
diff --git a/lib/portage/tests/resolver/test_or_choices.py
b/lib/portage/tests/resolver/test_or_choices.py
index 78946ccec..10c613e39 100644
--- a/lib/portage/tests/resolver/test_or_choices.py
+++ b/lib/portage/tests/resolver/test_or_choices.py
@@ -387,13 +387,13 @@ class OrChoicesTestCase(TestCase):
}
test_cases = (
- # Demonstrate bug 707108, where a new python slot is
erroneosly
+ # Test for bug 707108, where a new python slot was
erroneously
# removed by emerge --depclean.
ResolverPlaygroundTestCase(
[],
options={"--depclean": True},
success=True,
- cleanlist=['dev-lang/python-3.8'],
+ cleanlist=[],
),
)