From 2b66a5ab1f678bcebc59b36abd9254123077c45b Mon Sep 17 00:00:00 2001 From: Brian Harring Date: Thu, 18 Jan 2024 20:16:50 -0800 Subject: compatibilty: remove reliance on repo.category_dirs pkgcore's `category_dirs` is a fossil that shouldn't be relied upon. My recollection is this property was from before `profiles/categories` existed, but it's just a listdir() intersection against known directories. PMS mandates categories be in `profiles/categories`, thus that functionality breaks compatibility. It will be removed from pkgcore in future semver breaks for that reason. Signed-off-by: Brian Harring --- src/pkgcheck/checks/repo.py | 6 ++- testdata/repos/eapis-testing/profiles/categories | 2 + testdata/repos/eclass/profiles/categories | 5 +++ testdata/repos/network/profiles/categories | 3 ++ testdata/repos/overlay/profiles/categories | 1 + testdata/repos/overlayed/profiles/categories | 1 + testdata/repos/profiledir/profiles/categories | 2 + testdata/repos/python/profiles/categories | 8 ++++ testdata/repos/standalone/profiles/categories | 55 ++++++++++++++++++++++++ testdata/repos/visibility/profiles/categories | 8 ++++ 10 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 testdata/repos/eapis-testing/profiles/categories create mode 100644 testdata/repos/eclass/profiles/categories create mode 100644 testdata/repos/network/profiles/categories create mode 100644 testdata/repos/overlay/profiles/categories create mode 100644 testdata/repos/overlayed/profiles/categories create mode 100644 testdata/repos/profiledir/profiles/categories create mode 100644 testdata/repos/python/profiles/categories create mode 100644 testdata/repos/standalone/profiles/categories create mode 100644 testdata/repos/visibility/profiles/categories diff --git a/src/pkgcheck/checks/repo.py b/src/pkgcheck/checks/repo.py index 1dcc99ad..08abe802 100644 --- a/src/pkgcheck/checks/repo.py +++ b/src/pkgcheck/checks/repo.py @@ -82,10 +82,12 @@ class EmptyDirsCheck(GentooRepoCheck, RepoCheck): self.repo = self.options.target_repo def finish(self): + repo_p = pathlib.Path(self.repo.location) for cat, pkgs in sorted(self.repo.packages.items()): # ignore entries in profiles/categories with nonexistent dirs - if not pkgs and cat in self.repo.category_dirs: - yield EmptyCategoryDir(pkg=RawCPV(cat, None, None)) + if not pkgs: + if (repo_p / cat).exists(): + yield EmptyCategoryDir(pkg=RawCPV(cat, None, None)) continue for pkg in sorted(pkgs): if not self.repo.versions[(cat, pkg)]: diff --git a/testdata/repos/eapis-testing/profiles/categories b/testdata/repos/eapis-testing/profiles/categories new file mode 100644 index 00000000..077b068b --- /dev/null +++ b/testdata/repos/eapis-testing/profiles/categories @@ -0,0 +1,2 @@ +EapiCheck +MissingRemoteIdCheck diff --git a/testdata/repos/eclass/profiles/categories b/testdata/repos/eclass/profiles/categories new file mode 100644 index 00000000..a7c758c3 --- /dev/null +++ b/testdata/repos/eclass/profiles/categories @@ -0,0 +1,5 @@ +EapiCheck +EclassParseCheck +EclassUsageCheck +InheritsCheck +stub diff --git a/testdata/repos/network/profiles/categories b/testdata/repos/network/profiles/categories new file mode 100644 index 00000000..83f6db7f --- /dev/null +++ b/testdata/repos/network/profiles/categories @@ -0,0 +1,3 @@ +FetchablesUrlCheck +HomepageUrlCheck +MetadataUrlCheck diff --git a/testdata/repos/overlay/profiles/categories b/testdata/repos/overlay/profiles/categories new file mode 100644 index 00000000..367e18ec --- /dev/null +++ b/testdata/repos/overlay/profiles/categories @@ -0,0 +1 @@ +UnusedInMastersCheck diff --git a/testdata/repos/overlayed/profiles/categories b/testdata/repos/overlayed/profiles/categories new file mode 100644 index 00000000..39802f64 --- /dev/null +++ b/testdata/repos/overlayed/profiles/categories @@ -0,0 +1 @@ +stub diff --git a/testdata/repos/profiledir/profiles/categories b/testdata/repos/profiledir/profiles/categories new file mode 100644 index 00000000..5ab67d3f --- /dev/null +++ b/testdata/repos/profiledir/profiles/categories @@ -0,0 +1,2 @@ +cat +RedundantVersionCheck diff --git a/testdata/repos/python/profiles/categories b/testdata/repos/python/profiles/categories new file mode 100644 index 00000000..07e87fc9 --- /dev/null +++ b/testdata/repos/python/profiles/categories @@ -0,0 +1,8 @@ +app-arch +dev-lang +dev-python +PythonCheck +PythonCompatCheck +PythonFetchableCheck +RubyCompatCheck +stub diff --git a/testdata/repos/standalone/profiles/categories b/testdata/repos/standalone/profiles/categories new file mode 100644 index 00000000..9a5bd29c --- /dev/null +++ b/testdata/repos/standalone/profiles/categories @@ -0,0 +1,55 @@ +app-arch +BadCommandsCheck +CatBadlyFormedXml +CatInvalidXml +CatMetadataXmlEmptyElement +CatMetadataXmlIndentation +CatMetadataXmlInvalidCatRef +CatMetadataXmlInvalidPkgRef +DeclarationShadowedCheck +DependencyCheck +DescriptionCheck +dev-lang +dev-ruby +DoCompressedFilesCheck +DroppedKeywordsCheck +EapiCheck +EbuildReservedCheck +EbuildUnquotedVariablesCheck +EclassManualDepsCheck +EclassUsageCheck +EendMissingArgCheck +EqualVersionsCheck +GlobalUseCheck +GlobCheck +HomepageCheck +InsintoCheck +IuseCheck +KeywordsCheck +LicenseCheck +LocalUseCheck +ManifestCheck +ManifestCollisionCheck +MetadataVarCheck +MissingSlotDepCheck +MissingUnpackerDepCheck +NonPosixCheck +PackageMetadataXmlCheck +PkgDirCheck +PropertiesCheck +ReadonlyVariableCheck +RedundantDodirCheck +RequiredUseCheck +RestrictCheck +RestrictTestCheck +RustCheck +SandboxCallCheck +SourcingCheck +SrcUriCheck +StaleLiveCheck +stub +test +VariableScopeCheck +virtual +VisibilityCheck +WhitespaceCheck diff --git a/testdata/repos/visibility/profiles/categories b/testdata/repos/visibility/profiles/categories new file mode 100644 index 00000000..53471351 --- /dev/null +++ b/testdata/repos/visibility/profiles/categories @@ -0,0 +1,8 @@ +DependencyMoved +DeprecatedDep +NonsolvableDepsInDev +NonsolvableDepsInExp +NonsolvableDepsInStable +stub +UncheckableDep +VisibilityCheck -- cgit v1.2.3-65-gdbad