aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/pkgcheck/checks/repo.py26
-rw-r--r--testdata/data/repos/compatibility/RepositoryCategories/CategoryIsNotDirectory/expected.json1
-rwxr-xr-xtestdata/data/repos/compatibility/RepositoryCategories/CategoryIsNotDirectory/fix.sh2
-rw-r--r--testdata/repos/compatibility/CategoryIsNotDirectory0
-rw-r--r--testdata/repos/compatibility/profiles/categories1
5 files changed, 30 insertions, 0 deletions
diff --git a/src/pkgcheck/checks/repo.py b/src/pkgcheck/checks/repo.py
index eefc523e..1dcc99ad 100644
--- a/src/pkgcheck/checks/repo.py
+++ b/src/pkgcheck/checks/repo.py
@@ -1,4 +1,5 @@
import os
+import pathlib
from snakeoil.osutils import pjoin
@@ -89,3 +90,28 @@ class EmptyDirsCheck(GentooRepoCheck, RepoCheck):
for pkg in sorted(pkgs):
if not self.repo.versions[(cat, pkg)]:
yield EmptyPackageDir(pkg=RawCPV(cat, pkg, None))
+
+
+class CategoryIsNotDirectory(results.CategoryResult, results.Error):
+ """A category was found that exists but isn't a directory."""
+
+ scope = base.repo_scope
+
+ @property
+ def desc(self):
+ return f"category on disk exists and is not a directory: {self.category}"
+
+
+class RepositoryCategories(RepoCheck):
+ """Scan for fundamental category issues in the repository layout"""
+
+ _source = (sources.EmptySource, (base.repo_scope,))
+ known_results = frozenset({CategoryIsNotDirectory})
+
+ def finish(self):
+ repo = self.options.target_repo
+ repo_p = pathlib.Path(repo.location)
+ for category in repo.categories:
+ p = repo_p / category
+ if p.exists() and not p.is_dir():
+ yield CategoryIsNotDirectory(pkg=RawCPV(category, None, None))
diff --git a/testdata/data/repos/compatibility/RepositoryCategories/CategoryIsNotDirectory/expected.json b/testdata/data/repos/compatibility/RepositoryCategories/CategoryIsNotDirectory/expected.json
new file mode 100644
index 00000000..493a4a3b
--- /dev/null
+++ b/testdata/data/repos/compatibility/RepositoryCategories/CategoryIsNotDirectory/expected.json
@@ -0,0 +1 @@
+{"__class__": "CategoryIsNotDirectory", "category": "CategoryIsNotDirectory"}
diff --git a/testdata/data/repos/compatibility/RepositoryCategories/CategoryIsNotDirectory/fix.sh b/testdata/data/repos/compatibility/RepositoryCategories/CategoryIsNotDirectory/fix.sh
new file mode 100755
index 00000000..c37673b0
--- /dev/null
+++ b/testdata/data/repos/compatibility/RepositoryCategories/CategoryIsNotDirectory/fix.sh
@@ -0,0 +1,2 @@
+#!/bin/bash
+rm CategoryIsNotDirectory
diff --git a/testdata/repos/compatibility/CategoryIsNotDirectory b/testdata/repos/compatibility/CategoryIsNotDirectory
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/testdata/repos/compatibility/CategoryIsNotDirectory
diff --git a/testdata/repos/compatibility/profiles/categories b/testdata/repos/compatibility/profiles/categories
new file mode 100644
index 00000000..5578f02c
--- /dev/null
+++ b/testdata/repos/compatibility/profiles/categories
@@ -0,0 +1 @@
+CategoryIsNotDirectory