|
2 | 2 |
|
3 | 3 | import os |
4 | 4 | from collections import defaultdict |
| 5 | +from typing import Iterable |
5 | 6 |
|
6 | 7 | from pkgcore.ebuild import misc |
7 | 8 | from pkgcore.ebuild import profiles as profiles_mod |
@@ -96,16 +97,17 @@ def desc(self): |
96 | 97 | class UnknownProfileUseExpand(results.ProfilesResult, results.Warning): |
97 | 98 | """Profile includes nonexistent USE_EXPAND group(s).""" |
98 | 99 |
|
99 | | - def __init__(self, path, groups): |
| 100 | + def __init__(self, path: str, var: str, groups: Iterable[str]): |
100 | 101 | super().__init__() |
101 | 102 | self.path = path |
| 103 | + self.var = var |
102 | 104 | self.groups = tuple(groups) |
103 | 105 |
|
104 | 106 | @property |
105 | 107 | def desc(self): |
106 | 108 | s = pluralism(self.groups) |
107 | 109 | groups = ", ".join(self.groups) |
108 | | - return f"{self.path!r}: unknown USE_EXPAND group{s}: {groups}" |
| 110 | + return f"{self.path!r}: unknown USE_EXPAND group{s} in {self.var!r}: {groups}" |
109 | 111 |
|
110 | 112 |
|
111 | 113 | class UnknownProfileArch(results.ProfilesResult, results.Warning): |
@@ -181,7 +183,10 @@ def __init__(self, *args, use_addon: addons.UseAddon, keywords_addon: addons.Key |
181 | 183 | self.keywords = keywords_addon |
182 | 184 | self.search_repo = self.options.search_repo |
183 | 185 | self.profiles_dir = repo.config.profiles_base |
184 | | - self.use_expand_groups = frozenset(x.upper() for x in repo.config.use_expand_desc) |
| 186 | + self.use_expand_groups = { |
| 187 | + use.upper(): frozenset({val.removeprefix(f"{use}_") for val, _desc in vals}) |
| 188 | + for use, vals in repo.config.use_expand_desc.items() |
| 189 | + } |
185 | 190 |
|
186 | 191 | local_iuse = {use for _pkg, (use, _desc) in repo.config.use_local_desc} |
187 | 192 | self.available_iuse = frozenset( |
@@ -289,22 +294,30 @@ def _pkg_use(self, filename, node, vals): |
289 | 294 | yield UnknownProfilePackage(pjoin(node.name, filename), a) |
290 | 295 |
|
291 | 296 | @verify_files(("make.defaults", "make_defaults")) |
292 | | - def _make_defaults(self, filename: str, node, vals: dict[str, str]): |
| 297 | + def _make_defaults(self, filename: str, node: sources.ProfileNode, vals: dict[str, str]): |
293 | 298 | if use_flags := { |
294 | 299 | use.removeprefix("-") |
295 | 300 | for use_group in ("USE", "IUSE_IMPLICIT") |
296 | 301 | for use in vals.get(use_group, "").split() |
297 | 302 | }: |
298 | 303 | if unknown := use_flags - self.available_iuse: |
299 | 304 | yield UnknownProfileUse(pjoin(node.name, filename), sorted(unknown)) |
300 | | - if defined := set(vals.get("USE_EXPAND", "").split()): |
301 | | - if unknown := defined - self.use_expand_groups: |
302 | | - yield UnknownProfileUseExpand(pjoin(node.name, filename), sorted(unknown)) |
| 305 | + implicit_use_expands = set(vals.get("USE_EXPAND_IMPLICIT", "").split()) |
| 306 | + for use_group in ( |
| 307 | + "USE_EXPAND", |
| 308 | + "USE_EXPAND_HIDDEN", |
| 309 | + "USE_EXPAND_UNPREFIXED", |
| 310 | + ): |
| 311 | + values = {use.removeprefix("-") for use in vals.get(use_group, "").split()} |
| 312 | + if unknown := values - self.use_expand_groups.keys() - implicit_use_expands: |
| 313 | + yield UnknownProfileUseExpand( |
| 314 | + pjoin(node.name, filename), use_group, sorted(unknown) |
| 315 | + ) |
303 | 316 | if arch := vals.get("ARCH", None): |
304 | 317 | if arch not in self.keywords.arches: |
305 | 318 | yield UnknownProfileArch(pjoin(node.name, filename), arch) |
306 | 319 |
|
307 | | - def feed(self, profile): |
| 320 | + def feed(self, profile: sources.Profile): |
308 | 321 | for f in profile.files.intersection(self.known_files): |
309 | 322 | attr, func = self.known_files[f] |
310 | 323 | with base.LogReports(*_logmap) as log_reports: |
|
0 commit comments