Skip to content

Commit 1d0838b

Browse files
committed
RepoProfilesCheck: check for banned&deprecated profile EAPIs
1 parent 21b4327 commit 1d0838b

21 files changed

Lines changed: 73 additions & 5 deletions

File tree

requirements/install.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ lxml
44
pathspec
55
tree-sitter~=0.19.0
66
snakeoil~=0.9.6
7-
pkgcore~=0.12.2
7+
pkgcore~=0.12.3

requirements/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ requires = [
77
"pathspec",
88
"tree-sitter~=0.19.0",
99
"snakeoil~=0.9.6",
10-
"pkgcore~=0.12.2",
10+
"pkgcore~=0.12.3",
1111
]
1212
build-backend = "setuptools.build_meta"

src/pkgcheck/checks/profiles.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,33 @@ def desc(self):
302302
)
303303

304304

305+
class _ProfileEapiResult(results.ProfilesResult):
306+
"""Generic profile EAPI result."""
307+
308+
_type = None
309+
310+
def __init__(self, profile, eapi):
311+
super().__init__()
312+
self.profile = profile
313+
self.eapi = str(eapi)
314+
315+
@property
316+
def desc(self):
317+
return f"{self.profile!r} profile is using {self._type} EAPI {self.eapi}"
318+
319+
320+
class BannedProfileEapi(_ProfileEapiResult, results.Error):
321+
"""Profile has an EAPI that is banned in the repository."""
322+
323+
_type = 'banned'
324+
325+
326+
class DeprecatedProfileEapi(_ProfileEapiResult, results.Warning):
327+
"""Profile has an EAPI that is deprecated in the repository."""
328+
329+
_type = 'deprecated'
330+
331+
305332
class UnknownCategoryDirs(results.ProfilesResult, results.Warning):
306333
"""Category directories that aren't listed in a repo's categories.
307334
@@ -359,7 +386,7 @@ class RepoProfilesCheck(RepoCheck):
359386
known_results = frozenset([
360387
ArchesWithoutProfiles, UnusedProfileDirs, NonexistentProfilePath,
361388
UnknownCategoryDirs, NonexistentCategories, LaggingProfileEapi,
362-
ProfileError, ProfileWarning,
389+
ProfileError, ProfileWarning, BannedProfileEapi, DeprecatedProfileEapi,
363390
])
364391

365392
# known profile status types for the gentoo repo
@@ -401,7 +428,12 @@ def finish(self):
401428
known_status=known_profile_statuses, known_arch=self.arches)
402429
yield from log_reports
403430

431+
banned_eapis = self.repo.config.profile_eapis_banned
432+
deprecated_eapis = self.repo.config.profile_eapis_deprecated
433+
404434
seen_profile_dirs = set()
435+
banned_profile_eapi = set()
436+
deprecated_profile_eapi = set()
405437
lagging_profile_eapi = defaultdict(list)
406438
for p in profiles:
407439
try:
@@ -413,11 +445,19 @@ def finish(self):
413445
seen_profile_dirs.update(dir_parents(parent.name))
414446
if profile.eapi is not parent.eapi and profile.eapi in parent.eapi.inherits:
415447
lagging_profile_eapi[profile].append(parent)
448+
if str(parent.eapi) in banned_eapis:
449+
banned_profile_eapi.add(parent)
450+
if str(parent.eapi) in deprecated_eapis:
451+
deprecated_profile_eapi.add(parent)
416452

417453
for profile, parents in lagging_profile_eapi.items():
418454
parent = parents[-1]
419455
yield LaggingProfileEapi(
420456
profile.name, str(profile.eapi), parent.name, str(parent.eapi))
457+
for profile in banned_profile_eapi:
458+
yield BannedProfileEapi(profile.name, profile.eapi)
459+
for profile in deprecated_profile_eapi:
460+
yield DeprecatedProfileEapi(profile.name, profile.eapi)
421461

422462
if unused_profile_dirs := available_profile_dirs - seen_profile_dirs:
423463
yield UnusedProfileDirs(sorted(unused_profile_dirs))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"__class__": "BannedProfileEapi", "profile": "banned-eapi", "eapi": "0"}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
diff -Naur profiledir/profiles/banned-eapi/eapi fixed/profiles/banned-eapi/eapi
2+
--- profiledir/profiles/banned-eapi/eapi 1970-01-01 01:00:00.000000000 +0100
3+
+++ fixed/profiles/banned-eapi/eapi 2021-08-09 12:02:18.373080570 +0200
4+
@@ -0,0 +1 @@
5+
+7
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"__class__": "DeprecatedProfileEapi", "profile": "deprecated-eapi", "eapi": "1"}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
diff -Naur profiledir/profiles/deprecated-eapi/eapi fixed/profiles/deprecated-eapi/eapi
2+
--- profiledir/profiles/deprecated-eapi/eapi 2021-08-09 11:54:37.593718237 +0200
3+
+++ fixed/profiles/deprecated-eapi/eapi 2021-08-09 12:02:23.956527121 +0200
4+
@@ -1 +1 @@
5+
-1
6+
+7
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
masters =
22
cache-formats =
33
thin-manifests = true
4+
profile-eapis-banned = 0
5+
profile-eapis-deprecated = 1 2 3
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7

0 commit comments

Comments
 (0)