Skip to content

Commit

Permalink
DepPriority{Normal,Satisfied}Range: strengthen _ignore_runtime for ru…
Browse files Browse the repository at this point in the history
…ntime 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] #1193 (comment)

Bug: https://bugs.gentoo.org/918683
Thanks-to: Zac Medico <zmedico@gentoo.org>
Signed-off-by: Sam James <sam@gentoo.org>
  • Loading branch information
thesamesam committed Nov 28, 2023
1 parent 2b02d8f commit 2e298ea
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
8 changes: 7 additions & 1 deletion lib/_emerge/DepPriorityNormalRange.py
Expand Up @@ -37,7 +37,13 @@ def _ignore_runtime_post(cls, priority):
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
Expand Down
13 changes: 11 additions & 2 deletions 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
Expand Down Expand Up @@ -89,7 +89,16 @@ def _ignore_satisfied_buildtime_slot_op(cls, priority):
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
Expand Down
9 changes: 4 additions & 5 deletions 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
Expand All @@ -7,8 +7,6 @@
ResolverPlaygroundTestCase,
)

import pytest


class RuntimeCycleMergeOrderTestCase(TestCase):
def testRuntimeCycleMergeOrder(self):
Expand Down Expand Up @@ -77,7 +75,6 @@ def testRuntimeCycleMergeOrder(self):
finally:
playground.cleanup()

@pytest.mark.xfail()
def testBuildtimeRuntimeCycleMergeOrder(self):
installed = {
"dev-util/cmake-3.26.5-r2": {
Expand Down Expand Up @@ -192,10 +189,12 @@ def testBuildtimeRuntimeCycleMergeOrder(self):
"--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",
],
),
)
Expand Down

0 comments on commit 2e298ea

Please sign in to comment.