diff options
author | Sam James <sam@gentoo.org> | 2022-09-10 07:22:39 +0100 |
---|---|---|
committer | Sam James <sam@gentoo.org> | 2022-09-29 00:56:08 +0100 |
commit | bb09a2d4db4cd0f85f8ae8ceaddc05ae2585aba3 (patch) | |
tree | 31ba141f70e8a7cd3fed9e49ac862eae89b241c4 | |
parent | Add more error handling for binpkgs (diff) | |
download | portage-bb09a2d4.tar.gz portage-bb09a2d4.tar.bz2 portage-bb09a2d4.zip |
portage: sets: VariableSet: parse *DEPEND in includes/excludes
VariableSet takes a metadata variable and checks
its contents based on 'includes' or 'excludes'
from the set definition.
Unfortunately, until now, it didn't parse/expand the chosen variable
and would only match it literally (it'd also not check effective
metadata, just what's listed in the ebuild -- no *DEPEND
from an eclass, for example).
If variable is *DEPEND, actually parse includes/excludes
so we can effecitvely match say, includes="dev-lang/go"
against ">=dev-lang/go-1.18" in an ebuild.
Bug: https://bugs.gentoo.org/827974
Bug: https://bugs.gentoo.org/865115
Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r-- | lib/portage/_sets/dbapi.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/portage/_sets/dbapi.py b/lib/portage/_sets/dbapi.py index 4a837522f..5e7b00e08 100644 --- a/lib/portage/_sets/dbapi.py +++ b/lib/portage/_sets/dbapi.py @@ -168,14 +168,31 @@ class VariableSet(EverythingSet): return False (values,) = self._metadatadb.aux_get(ebuild, [self._variable]) values = values.split() + + if "DEPEND" in self._variable: + include_atoms = [] + for include in self._includes: + include_atoms.append(Atom(include)) + + for x in use_reduce(values, token_class=Atom): + if not isinstance(x, Atom): + continue + + for include_atom in include_atoms: + if include_atom.match(x): + return True + + return False + if self._includes and not self._includes.intersection(values): return False + if self._excludes and self._excludes.intersection(values): return False + return True def singleBuilder(cls, options, settings, trees): - variable = options.get("variable") if variable is None: raise SetConfigError(_("missing required attribute: 'variable'")) |