commit: 141e7fbab84b2e39bfa61311b25d6b05f7908c1f Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> AuthorDate: Sun May 14 17:51:32 2023 +0000 Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org> CommitDate: Sun May 14 18:46:44 2023 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcheck.git/commit/?id=141e7fba
StaleLiveCheck: new check for stale live eapi Resolves: https://github.com/pkgcore/pkgcheck/issues/578 Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org> src/pkgcheck/checks/metadata.py | 36 ++++++++++++++++++++++ .../StaleLiveCheck/StaleLiveEAPI/expected.json | 3 ++ .../StaleLiveEAPI/StaleLiveEAPI-0.ebuild | 6 ++++ .../StaleLiveEAPI/StaleLiveEAPI-1.9999.ebuild | 7 +++++ .../StaleLiveEAPI/StaleLiveEAPI-1.ebuild | 6 ++++ .../StaleLiveEAPI/StaleLiveEAPI-2.1.ebuild | 6 ++++ .../StaleLiveEAPI/StaleLiveEAPI-2.9999.ebuild | 7 +++++ .../StaleLiveEAPI/StaleLiveEAPI-2.ebuild | 6 ++++ .../StaleLiveEAPI/StaleLiveEAPI-3.1.ebuild | 6 ++++ .../StaleLiveEAPI/StaleLiveEAPI-3.9999.ebuild | 7 +++++ .../StaleLiveEAPI/StaleLiveEAPI-3.ebuild | 6 ++++ .../StaleLiveEAPI/StaleLiveEAPI-4.9999.ebuild | 7 +++++ 12 files changed, 103 insertions(+) diff --git a/src/pkgcheck/checks/metadata.py b/src/pkgcheck/checks/metadata.py index 8a26024c..8a6c5ba5 100644 --- a/src/pkgcheck/checks/metadata.py +++ b/src/pkgcheck/checks/metadata.py @@ -1782,3 +1782,39 @@ class VirtualProvidersCheck(Check): } if len(unversioned_rdepends) == 1 and not self.pkg_has_conditional_exception(pkgs): yield VirtualWithSingleProvider(unversioned_rdepends.pop(), pkg=pkgs[0]) + + +class StaleLiveEAPI(results.VersionResult, results.Warning): + """Live ebuild is using older an EAPI then release ebuilds. + + Live ebuilds should always use an EAPI version at least as new as the + release ebuilds. + """ + + def __init__(self, old_eapi, new_eapi, **kwargs): + super().__init__(**kwargs) + self.old_eapi = old_eapi + self.new_eapi = new_eapi + + @property + def desc(self): + return f"live ebuild uses older EAPI={self.old_eapi} than release ebuilds (EAPI={self.new_eapi})" + + +class StaleLiveCheck(Check): + """Check for stale live ebuilds.""" + + _source = sources.PackageRepoSource + known_results = frozenset({StaleLiveEAPI}) + + def feed(self, pkgs): + slots_pkgs = defaultdict(list) + for pkg in pkgs: + slots_pkgs[pkg.slot].append(pkg) + + for pkgs in slots_pkgs.values(): + if non_live := [pkg for pkg in pkgs if not pkg.live]: + max_non_live_eapi = max(int(str(pkg.eapi)) for pkg in non_live) + for pkg in pkgs: + if pkg.live and (old_eapi := int(str(pkg.eapi))) < max_non_live_eapi: + yield StaleLiveEAPI(old_eapi=old_eapi, new_eapi=max_non_live_eapi, pkg=pkg) diff --git a/testdata/data/repos/standalone/StaleLiveCheck/StaleLiveEAPI/expected.json b/testdata/data/repos/standalone/StaleLiveCheck/StaleLiveEAPI/expected.json new file mode 100644 index 00000000..0f9a204e --- /dev/null +++ b/testdata/data/repos/standalone/StaleLiveCheck/StaleLiveEAPI/expected.json @@ -0,0 +1,3 @@ +{"__class__": "StaleLiveEAPI", "category": "StaleLiveCheck", "package": "StaleLiveEAPI", "version": "2.9999", "old_eapi": 7, "new_eapi": 8} +{"__class__": "StaleLiveEAPI", "category": "StaleLiveCheck", "package": "StaleLiveEAPI", "version": "3.9999", "old_eapi": 7, "new_eapi": 8} +{"__class__": "StaleLiveEAPI", "category": "EclassUsageCheck", "package": "DuplicateEclassInherit", "version": "0", "old_eapi": 0, "new_eapi": 7} diff --git a/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-0.ebuild b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-0.ebuild new file mode 100644 index 00000000..dd44344e --- /dev/null +++ b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-0.ebuild @@ -0,0 +1,6 @@ +EAPI=7 + +DESCRIPTION="SLOT 0 is release only" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +SLOT="0" +LICENSE="BSD" diff --git a/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-1.9999.ebuild b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-1.9999.ebuild new file mode 100644 index 00000000..4badbd0d --- /dev/null +++ b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-1.9999.ebuild @@ -0,0 +1,7 @@ +EAPI=8 + +DESCRIPTION="SLOT 1 is fine" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +SLOT="1" +LICENSE="BSD" +PROPERTIES="live" diff --git a/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-1.ebuild b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-1.ebuild new file mode 100644 index 00000000..5b79a320 --- /dev/null +++ b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-1.ebuild @@ -0,0 +1,6 @@ +EAPI=8 + +DESCRIPTION="SLOT 1 is fine" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +SLOT="1" +LICENSE="BSD" diff --git a/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-2.1.ebuild b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-2.1.ebuild new file mode 100644 index 00000000..34aba958 --- /dev/null +++ b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-2.1.ebuild @@ -0,0 +1,6 @@ +EAPI=8 + +DESCRIPTION="SLOT 2 is not fine" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +SLOT="2" +LICENSE="BSD" diff --git a/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-2.9999.ebuild b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-2.9999.ebuild new file mode 100644 index 00000000..55570296 --- /dev/null +++ b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-2.9999.ebuild @@ -0,0 +1,7 @@ +EAPI=7 + +DESCRIPTION="SLOT 2 is not fine" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +SLOT="2" +LICENSE="BSD" +PROPERTIES="live" diff --git a/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-2.ebuild b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-2.ebuild new file mode 100644 index 00000000..1f1fe229 --- /dev/null +++ b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-2.ebuild @@ -0,0 +1,6 @@ +EAPI=7 + +DESCRIPTION="SLOT 2 is not fine" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +SLOT="2" +LICENSE="BSD" diff --git a/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-3.1.ebuild b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-3.1.ebuild new file mode 100644 index 00000000..ddb5f28e --- /dev/null +++ b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-3.1.ebuild @@ -0,0 +1,6 @@ +EAPI=7 + +DESCRIPTION="SLOT 3 is not fine" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +SLOT="3" +LICENSE="BSD" diff --git a/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-3.9999.ebuild b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-3.9999.ebuild new file mode 100644 index 00000000..d4a646ba --- /dev/null +++ b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-3.9999.ebuild @@ -0,0 +1,7 @@ +EAPI=7 + +DESCRIPTION="SLOT 3 is not fine" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +SLOT="3" +LICENSE="BSD" +PROPERTIES="live" diff --git a/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-3.ebuild b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-3.ebuild new file mode 100644 index 00000000..a9add003 --- /dev/null +++ b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-3.ebuild @@ -0,0 +1,6 @@ +EAPI=8 + +DESCRIPTION="SLOT 3 is not fine" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +SLOT="3" +LICENSE="BSD" diff --git a/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-4.9999.ebuild b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-4.9999.ebuild new file mode 100644 index 00000000..8c102d1a --- /dev/null +++ b/testdata/repos/standalone/StaleLiveCheck/StaleLiveEAPI/StaleLiveEAPI-4.9999.ebuild @@ -0,0 +1,7 @@ +EAPI=8 + +DESCRIPTION="SLOT 4 is live only" +HOMEPAGE="https://github.com/pkgcore/pkgcheck" +SLOT="4" +LICENSE="BSD" +PROPERTIES="live"