Skip to content

Commit 191300b

Browse files
committed
ProfilesCheck: check missing values for implicit in make.defaults
Related: #524 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent bca5e48 commit 191300b

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

src/pkgcheck/checks/profiles.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,21 @@ def desc(self):
126126
return f"{self.path!r}: unknown value{s} for {self.group!r}: {values}"
127127

128128

129+
class ProfileMissingImplicitExpandValues(results.ProfilesResult, results.Warning):
130+
"""Profile is missing USE_EXPAND_VALUES for implicit USE_EXPAND group."""
131+
132+
def __init__(self, path: str, groups: Iterable[str]):
133+
super().__init__()
134+
self.path = path
135+
self.groups = tuple(groups)
136+
137+
@property
138+
def desc(self):
139+
s = pluralism(self.groups)
140+
groups = ", ".join(self.groups)
141+
return f"{self.path!r}: missing USE_EXPAND_VALUES for USE_EXPAND group{s}: {groups}"
142+
143+
129144
class UnknownProfileArch(results.ProfilesResult, results.Warning):
130145
"""Profile includes unknown ARCH."""
131146

@@ -185,6 +200,7 @@ class ProfilesCheck(Check):
185200
UnknownProfilePackageKeywords,
186201
UnknownProfileUseExpand,
187202
UnknownProfileUseExpandValue,
203+
ProfileMissingImplicitExpandValues,
188204
UnknownProfileArch,
189205
ProfileWarning,
190206
ProfileError,
@@ -345,6 +361,14 @@ def _make_defaults(self, filename: str, node: sources.ProfileNode, vals: dict[st
345361
for key in vals.keys() & self.use_expand_groups.keys():
346362
if unknown := set(vals.get(key, "").split()) - self.use_expand_groups[key]:
347363
yield UnknownProfileUseExpandValue(pjoin(node.name, filename), key, sorted(unknown))
364+
if missing_values := {
365+
use_group
366+
for use_group in implicit_use_expands
367+
if f"USE_EXPAND_VALUES_{use_group}" not in vals
368+
}:
369+
yield ProfileMissingImplicitExpandValues(
370+
pjoin(node.name, filename), sorted(missing_values)
371+
)
348372
if arch := vals.get("ARCH", None):
349373
if arch not in self.keywords.arches:
350374
yield UnknownProfileArch(pjoin(node.name, filename), arch)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"__class__": "ProfileMissingImplicitExpandValues", "path": "unknown_use/make.defaults", "groups": ["ELIBC"]}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff -Naur profiledir/profiles/unknown_use/make.defaults fixed/profiles/unknown_use/make.defaults
2+
diff --git a/testdata/repos/profiledir/profiles/unknown_use/make.defaults b/testdata/repos/profiledir/profiles/unknown_use/make.defaults
3+
--- profiledir/profiles/unknown_use/make.defaults
4+
+++ fixed/profiles/unknown_use/make.defaults
5+
@@ -4,6 +4,7 @@
6+
USE_EXPAND="PYTHON_TARGETS PYTHON_SINGLE_TARGET"
7+
USE_EXPAND_UNPREFIXED="ARCH LUA_TARGETS PYTHON_TARGETS"
8+
USE_EXPAND_VALUES_ARCH="amd64 x86"
9+
+USE_EXPAND_VALUES_ELIBC="GNU"
10+
USE_EXPAND_VALUES_LUA_TARGETS="lua5_1"
11+
USE_EXPAND_VALUES_PYTHON_TARGETS="python3_9 python3_10"
12+
PYTHON_TARGETS="python3_9 python3_10"

0 commit comments

Comments
 (0)