commit: 2e298ea7ba36801a1cfba6e4cbfc16a7c05ee73d
Author: Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 28 06:22:44 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Nov 28 22:07:46 2023 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=2e298ea7
DepPriority{Normal,Satisfied}Range: strengthen _ignore_runtime for runtime slot
operators
In the reported bug, net-misc/curl gets merged (binary), then dev-util/cmake
gets
bulit (from source) which fails because one of the built curl's dependencies
(net-libs/nghttp2) is missing:
```
[binary R ] net-misc/curl-8.4.0::test_repo USE="http2%*" 0 KiB
[ebuild U ] dev-util/cmake-3.27.8::test_repo [3.26.5-r2::test_repo] 0 KiB
[ebuild N ] net-libs/nghttp2-1.57.0::test_repo 0 KiB
```
Zac had the idea [0] of strengthening _ignore_runtime to consider runtime slot
deps
as well, so we now get:
```
[ebuild U ] dev-util/cmake-3.27.8::test_repo [3.26.5-r2::test_repo] 0 KiB
[ebuild N ] net-libs/nghttp2-1.57.0::test_repo 0 KiB
[binary R ] net-misc/curl-8.4.0::test_repo USE="http2%*" 0 KiB
```
For DepPrioritySatisfiedRange, we now allow ignoring the dep if:
* it's either a satisfied runtime slot dep, or it's not a runtime slot dep at
all, and
* the dep is satisfied or it's optional/not a build time dep.
(i.e. we now prevent ignoring the slot dep unless it's satisfied.)
For DepPriorityNormalRange, we now allow ignoring the dep if:
* it's not a runtime slot dep, and
* it's optional, or
* it's not a buildtime dep.
(i.e. we now prevent ignoring the slot dep.)
We then realise we can't ignore curl's dep on nghttp2 and come up with a better
order.
[0] https://github.com/gentoo/portage/pull/1193#issuecomment-1829178126
Bug: https://bugs.gentoo.org/918683
Thanks-to: Zac Medico <zmedico <AT> gentoo.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>
lib/_emerge/DepPriorityNormalRange.py | 8 +++++++-
lib/_emerge/DepPrioritySatisfiedRange.py | 13 +++++++++++--
.../tests/resolver/test_runtime_cycle_merge_order.py | 9 ++++-----
3 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/lib/_emerge/DepPriorityNormalRange.py
b/lib/_emerge/DepPriorityNormalRange.py
index a85e1b9c14..d7e4381b47 100644
--- a/lib/_emerge/DepPriorityNormalRange.py
+++ b/lib/_emerge/DepPriorityNormalRange.py
@@ -37,7 +37,13 @@ class DepPriorityNormalRange:
def _ignore_runtime(cls, priority):
if priority.__class__ is not DepPriority:
return False
- return bool(priority.optional or not priority.buildtime)
+ # If we ever allow "optional" runtime_slot_op, we'll need
+ # to adjust this appropriately. But only build time dependencies
+ # are optional right now, so it's not an issue as-is.
+ return bool(
+ not priority.runtime_slot_op
+ and (priority.optional or not priority.buildtime)
+ )
ignore_medium = _ignore_runtime
ignore_medium_soft = _ignore_runtime_post
diff --git a/lib/_emerge/DepPrioritySatisfiedRange.py
b/lib/_emerge/DepPrioritySatisfiedRange.py
index 0633a5e1c2..0d42e7613d 100644
--- a/lib/_emerge/DepPrioritySatisfiedRange.py
+++ b/lib/_emerge/DepPrioritySatisfiedRange.py
@@ -1,4 +1,4 @@
-# Copyright 1999-2013 Gentoo Foundation
+# Copyright 1999-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
from _emerge.DepPriority import DepPriority
@@ -89,7 +89,16 @@ class DepPrioritySatisfiedRange:
def _ignore_runtime(cls, priority):
if priority.__class__ is not DepPriority:
return False
- return bool(priority.satisfied or priority.optional or not
priority.buildtime)
+ # We could split this up into 2 variants (ignoring satisfied
+ # runtime_slot_op, and not) if we need more granularity for
ignore_priority
+ # in future.
+ return bool(
+ (
+ (not priority.runtime_slot_op)
+ or (priority.satisfied and priority.runtime_slot_op)
+ )
+ and (priority.satisfied or priority.optional or not
priority.buildtime)
+ )
ignore_medium = _ignore_runtime
ignore_medium_soft = _ignore_satisfied_buildtime_slot_op
diff --git a/lib/portage/tests/resolver/test_runtime_cycle_merge_order.py
b/lib/portage/tests/resolver/test_runtime_cycle_merge_order.py
index 26850ccad2..ed329aa097 100644
--- a/lib/portage/tests/resolver/test_runtime_cycle_merge_order.py
+++ b/lib/portage/tests/resolver/test_runtime_cycle_merge_order.py
@@ -1,4 +1,4 @@
-# Copyright 2016 Gentoo Foundation
+# Copyright 2016-2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
from portage.tests import TestCase
@@ -7,8 +7,6 @@ from portage.tests.resolver.ResolverPlayground import (
ResolverPlaygroundTestCase,
)
-import pytest
-
class RuntimeCycleMergeOrderTestCase(TestCase):
def testRuntimeCycleMergeOrder(self):
@@ -77,7 +75,6 @@ class RuntimeCycleMergeOrderTestCase(TestCase):
finally:
playground.cleanup()
- @pytest.mark.xfail()
def testBuildtimeRuntimeCycleMergeOrder(self):
installed = {
"dev-util/cmake-3.26.5-r2": {
@@ -192,10 +189,12 @@ class RuntimeCycleMergeOrderTestCase(TestCase):
"--usepkg": True,
},
success=True,
+ # It would also work to punt the dev-util/cmake upgrade
+ # until the end, given it's already installed.
mergelist=[
+ "dev-util/cmake-3.27.8",
"net-libs/nghttp2-1.57.0",
"[binary]net-misc/curl-8.4.0",
- "dev-util/cmake-3.27.8",
],
),
)