Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/_sets/
Date: Wed, 28 Sep 2022 23:56:21
Message-Id: 1664409368.bb09a2d4db4cd0f85f8ae8ceaddc05ae2585aba3.sam@gentoo
1 commit: bb09a2d4db4cd0f85f8ae8ceaddc05ae2585aba3
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Sat Sep 10 06:22:39 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Wed Sep 28 23:56:08 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=bb09a2d4
7
8 portage: sets: VariableSet: parse *DEPEND in includes/excludes
9
10 VariableSet takes a metadata variable and checks
11 its contents based on 'includes' or 'excludes'
12 from the set definition.
13
14 Unfortunately, until now, it didn't parse/expand the chosen variable
15 and would only match it literally (it'd also not check effective
16 metadata, just what's listed in the ebuild -- no *DEPEND
17 from an eclass, for example).
18
19 If variable is *DEPEND, actually parse includes/excludes
20 so we can effecitvely match say, includes="dev-lang/go"
21 against ">=dev-lang/go-1.18" in an ebuild.
22
23 Bug: https://bugs.gentoo.org/827974
24 Bug: https://bugs.gentoo.org/865115
25 Signed-off-by: Sam James <sam <AT> gentoo.org>
26
27 lib/portage/_sets/dbapi.py | 19 ++++++++++++++++++-
28 1 file changed, 18 insertions(+), 1 deletion(-)
29
30 diff --git a/lib/portage/_sets/dbapi.py b/lib/portage/_sets/dbapi.py
31 index 4a837522f..5e7b00e08 100644
32 --- a/lib/portage/_sets/dbapi.py
33 +++ b/lib/portage/_sets/dbapi.py
34 @@ -168,14 +168,31 @@ class VariableSet(EverythingSet):
35 return False
36 (values,) = self._metadatadb.aux_get(ebuild, [self._variable])
37 values = values.split()
38 +
39 + if "DEPEND" in self._variable:
40 + include_atoms = []
41 + for include in self._includes:
42 + include_atoms.append(Atom(include))
43 +
44 + for x in use_reduce(values, token_class=Atom):
45 + if not isinstance(x, Atom):
46 + continue
47 +
48 + for include_atom in include_atoms:
49 + if include_atom.match(x):
50 + return True
51 +
52 + return False
53 +
54 if self._includes and not self._includes.intersection(values):
55 return False
56 +
57 if self._excludes and self._excludes.intersection(values):
58 return False
59 +
60 return True
61
62 def singleBuilder(cls, options, settings, trees):
63 -
64 variable = options.get("variable")
65 if variable is None:
66 raise SetConfigError(_("missing required attribute: 'variable'"))