Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH 03/10] Empty ||/^^ REQUIRED_USE groups are no longer true in EAPI 7
Date: Mon, 26 Feb 2018 16:01:01
Message-Id: 20180226155942.9148-4-mgorny@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 00/10] EAPI 7, part one by "Michał Górny"
1 Bug: https://bugs.gentoo.org/636596
2 ---
3 pym/portage/dep/__init__.py | 4 ++--
4 pym/portage/eapi.py | 10 ++++++++--
5 pym/portage/tests/dep/testCheckRequiredUse.py | 5 +++--
6 pym/portage/tests/resolver/test_required_use.py | 8 ++++++++
7 4 files changed, 21 insertions(+), 6 deletions(-)
8
9 diff --git a/pym/portage/dep/__init__.py b/pym/portage/dep/__init__.py
10 index 6ff6adcb9..2a081f3d8 100644
11 --- a/pym/portage/dep/__init__.py
12 +++ b/pym/portage/dep/__init__.py
13 @@ -1,5 +1,5 @@
14 # deps.py -- Portage dependency resolution functions
15 -# Copyright 2003-2014 Gentoo Foundation
16 +# Copyright 2003-2018 Gentoo Foundation
17 # Distributed under the terms of the GNU General Public License v2
18
19 from __future__ import unicode_literals
20 @@ -2579,7 +2579,7 @@ def check_required_use(required_use, use, iuse_match, eapi=None):
21 (flag not in use and is_negated)
22
23 def is_satisfied(operator, argument):
24 - if not argument:
25 + if not argument and eapi_attrs.empty_groups_always_true:
26 #|| ( ) -> True
27 return True
28
29 diff --git a/pym/portage/eapi.py b/pym/portage/eapi.py
30 index 170902691..075f7a59c 100644
31 --- a/pym/portage/eapi.py
32 +++ b/pym/portage/eapi.py
33 @@ -1,4 +1,4 @@
34 -# Copyright 2010-2015 Gentoo Foundation
35 +# Copyright 2010-2018 Gentoo Foundation
36 # Distributed under the terms of the GNU General Public License v2
37
38 import collections
39 @@ -99,12 +99,17 @@ def eapi_has_hdepend(eapi):
40 def eapi_has_targetroot(eapi):
41 return eapi in ("5-hdepend",)
42
43 +def eapi_empty_groups_always_true(eapi):
44 + return eapi in ("0", "1", "2", "3", "4", "4-python", "4-slot-abi",
45 + "5", "5-progress", "6")
46 +
47 _eapi_attrs = collections.namedtuple('_eapi_attrs',
48 'dots_in_PN dots_in_use_flags exports_EBUILD_PHASE_FUNC '
49 'feature_flag_test feature_flag_targetroot '
50 'hdepend iuse_defaults iuse_effective posixish_locale '
51 'repo_deps required_use required_use_at_most_one_of slot_operator slot_deps '
52 - 'src_uri_arrows strong_blocks use_deps use_dep_defaults')
53 + 'src_uri_arrows strong_blocks use_deps use_dep_defaults '
54 + 'empty_groups_always_true')
55
56 _eapi_attrs_cache = {}
57
58 @@ -127,6 +132,7 @@ def _get_eapi_attrs(eapi):
59 eapi_attrs = _eapi_attrs(
60 dots_in_PN = (eapi is None or eapi_allows_dots_in_PN(eapi)),
61 dots_in_use_flags = (eapi is None or eapi_allows_dots_in_use_flags(eapi)),
62 + empty_groups_always_true = (eapi is not None and eapi_empty_groups_always_true(eapi)),
63 exports_EBUILD_PHASE_FUNC = (eapi is None or eapi_exports_EBUILD_PHASE_FUNC(eapi)),
64 feature_flag_test = True,
65 feature_flag_targetroot = (eapi is not None and eapi_has_targetroot(eapi)),
66 diff --git a/pym/portage/tests/dep/testCheckRequiredUse.py b/pym/portage/tests/dep/testCheckRequiredUse.py
67 index 63330b5cb..c4128c29a 100644
68 --- a/pym/portage/tests/dep/testCheckRequiredUse.py
69 +++ b/pym/portage/tests/dep/testCheckRequiredUse.py
70 @@ -1,4 +1,4 @@
71 -# Copyright 2010-2012 Gentoo Foundation
72 +# Copyright 2010-2018 Gentoo Foundation
73 # Distributed under the terms of the GNU General Public License v2
74
75 from portage.tests import TestCase
76 @@ -54,7 +54,8 @@ class TestCheckRequiredUse(TestCase):
77
78 ("^^ ( a? ( !b ) !c? ( d ) )", [], ["a", "b", "c", "d"], False),
79 ("^^ ( a? ( !b ) !c? ( d ) )", ["a"], ["a", "b", "c", "d"], True),
80 - ("^^ ( a? ( !b ) !c? ( d ) )", ["c"], ["a", "b", "c", "d"], True),
81 + # note: this one is EAPI-dependent, it used to be True for EAPI <7
82 + ("^^ ( a? ( !b ) !c? ( d ) )", ["c"], ["a", "b", "c", "d"], False),
83 ("^^ ( a? ( !b ) !c? ( d ) )", ["a", "c"], ["a", "b", "c", "d"], True),
84 ("^^ ( a? ( !b ) !c? ( d ) )", ["a", "b", "c"], ["a", "b", "c", "d"], False),
85 ("^^ ( a? ( !b ) !c? ( d ) )", ["a", "b", "d"], ["a", "b", "c", "d"], True),
86 diff --git a/pym/portage/tests/resolver/test_required_use.py b/pym/portage/tests/resolver/test_required_use.py
87 index ac748ca3b..7909f927f 100644
88 --- a/pym/portage/tests/resolver/test_required_use.py
89 +++ b/pym/portage/tests/resolver/test_required_use.py
90 @@ -50,6 +50,10 @@ class RequiredUSETestCase(TestCase):
91 "dev-libs/E-3" : {"EAPI": "5", "IUSE": "+foo bar", "REQUIRED_USE": "?? ( foo bar )"},
92 "dev-libs/E-4" : {"EAPI": "5", "IUSE": "+foo +bar", "REQUIRED_USE": "?? ( foo bar )"},
93 "dev-libs/E-5" : {"EAPI": "5", "IUSE": "+foo +bar", "REQUIRED_USE": "?? ( )"},
94 +
95 + "dev-libs/F-1" : {"EAPI": "7_pre1", "IUSE": "+foo +bar", "REQUIRED_USE": "|| ( )"},
96 + "dev-libs/F-2" : {"EAPI": "7_pre1", "IUSE": "+foo +bar", "REQUIRED_USE": "^^ ( )"},
97 + "dev-libs/F-3" : {"EAPI": "7_pre1", "IUSE": "+foo +bar", "REQUIRED_USE": "?? ( )"},
98 }
99
100 test_cases = (
101 @@ -91,6 +95,10 @@ class RequiredUSETestCase(TestCase):
102 ResolverPlaygroundTestCase(["=dev-libs/E-3"], success = True, mergelist=["dev-libs/E-3"]),
103 ResolverPlaygroundTestCase(["=dev-libs/E-4"], success = False),
104 ResolverPlaygroundTestCase(["=dev-libs/E-5"], success = True, mergelist=["dev-libs/E-5"]),
105 +
106 + ResolverPlaygroundTestCase(["=dev-libs/F-1"], success = False),
107 + ResolverPlaygroundTestCase(["=dev-libs/F-2"], success = False),
108 + ResolverPlaygroundTestCase(["=dev-libs/F-3"], success = True, mergelist=["dev-libs/F-3"]),
109 )
110
111 playground = ResolverPlayground(ebuilds=ebuilds)
112 --
113 2.16.2