aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Zamarin <arthurzam@gentoo.org>2024-01-14 21:44:13 +0200
committerArthur Zamarin <arthurzam@gentoo.org>2024-01-14 21:44:13 +0200
commit1ed31be4c67c2a18c90235f306967169cba31839 (patch)
tree050aa70198451876578774cbcf44ebaa6a151528
parentSandboxCallCheck: new check for invalid sandbox calls (diff)
downloadpkgcheck-1ed31be4c67c2a18c90235f306967169cba31839.tar.gz
pkgcheck-1ed31be4c67c2a18c90235f306967169cba31839.tar.bz2
pkgcheck-1ed31be4c67c2a18c90235f306967169cba31839.zip
DependencyMoved: show better error for dependency on pkgmove
Catch cases where we depend on pkgmoved package, and instead of showing NonexistentDeps and NonsolvableDepsIn* errors, show DependencyMoved result, with nice and simple suggestion on action to take. Resolves: https://github.com/pkgcore/pkgcheck/issues/649 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r--src/pkgcheck/checks/visibility.py46
-rw-r--r--testdata/data/repos/visibility/VisibilityCheck/DependencyMoved/expected.json3
-rw-r--r--testdata/repos/visibility/DependencyMoved/DependencyMoved/DependencyMoved-0.ebuild8
-rw-r--r--testdata/repos/visibility/profiles/updates/1Q-20241
4 files changed, 52 insertions, 6 deletions
diff --git a/src/pkgcheck/checks/visibility.py b/src/pkgcheck/checks/visibility.py
index 5440db7f..874d1bbf 100644
--- a/src/pkgcheck/checks/visibility.py
+++ b/src/pkgcheck/checks/visibility.py
@@ -146,6 +146,20 @@ class UncheckableDep(results.VersionResult, results.Warning):
return f"depset {self.attr}: could not be checked due to pkgcore limitation"
+class DependencyMoved(results.VersionResult, results.Error):
+ """Ebuild depends on a dependency which was pkgmoved."""
+
+ def __init__(self, attr: str, source: str, target: str, **kwargs):
+ super().__init__(**kwargs)
+ self.attr = attr
+ self.source = source
+ self.target = target
+
+ @property
+ def desc(self):
+ return f"depset({self.attr}) dependency moved, update {self.source!r} to {self.target!r}"
+
+
class NonsolvableDeps(results.VersionResult, results.AliasResult, results.Error):
"""No potential solution for a depset attribute."""
@@ -210,19 +224,32 @@ class VisibilityCheck(feeds.EvaluateDepSet, feeds.QueryCache, Check):
required_addons = (addons.profiles.ProfileAddon,)
known_results = frozenset(
- [
+ {
VisibleVcsPkg,
NonexistentDeps,
UncheckableDep,
NonsolvableDepsInStable,
NonsolvableDepsInDev,
NonsolvableDepsInExp,
- ]
+ DependencyMoved,
+ }
)
+ @staticmethod
+ def _collect_pkgmoves(repo):
+ pkgmoves: dict[str, str] = {}
+ for master in repo.masters:
+ pkgmoves.update(VisibilityCheck._collect_pkgmoves(master))
+ for (action, *params), *_ in repo.config.updates.values():
+ if action == "move":
+ source, target = params
+ pkgmoves[source.key] = target.key
+ return pkgmoves
+
def __init__(self, *args, profile_addon):
super().__init__(*args, profile_addon=profile_addon)
self.profiles = profile_addon
+ self.pkgmoves = self._collect_pkgmoves(self.options.target_repo)
self.report_cls_map = {
"stable": NonsolvableDepsInStable,
"dev": NonsolvableDepsInDev,
@@ -271,8 +298,14 @@ class VisibilityCheck(feeds.EvaluateDepSet, feeds.QueryCache, Check):
yield UncheckableDep(attr, pkg=pkg)
suppressed_depsets.append(attr)
if nonexistent:
- nonexistent = map(str, sorted(nonexistent))
- yield NonexistentDeps(attr.upper(), nonexistent, pkg=pkg)
+ for dep in set(nonexistent):
+ if target := self.pkgmoves.get(dep.key):
+ new_dep = str(dep).replace(dep.key, target)
+ yield DependencyMoved(attr, str(dep), new_dep, pkg=pkg)
+
+ nonexistent = {dep for dep in nonexistent if dep.key not in self.pkgmoves}
+ if nonexistent := sorted(map(str, sorted(nonexistent))):
+ yield NonexistentDeps(attr.upper(), nonexistent, pkg=pkg)
for attr in (x.lower() for x in pkg.eapi.dep_keys):
if attr in suppressed_depsets:
@@ -281,8 +314,9 @@ class VisibilityCheck(feeds.EvaluateDepSet, feeds.QueryCache, Check):
profile_failures = defaultdict(lambda: defaultdict(set))
for edepset, profiles in self.collapse_evaluate_depset(pkg, attr, depset):
for profile, failures in self.process_depset(pkg, attr, depset, edepset, profiles):
- failures = tuple(map(str, sorted(stable_unique(failures))))
- profile_failures[failures][profile.status].add(profile)
+ failures = {failure for failure in failures if failure.key not in self.pkgmoves}
+ if failures := tuple(map(str, sorted(failures))):
+ profile_failures[failures][profile.status].add(profile)
if profile_failures:
if self.options.verbosity > 0:
diff --git a/testdata/data/repos/visibility/VisibilityCheck/DependencyMoved/expected.json b/testdata/data/repos/visibility/VisibilityCheck/DependencyMoved/expected.json
new file mode 100644
index 00000000..c83c44a1
--- /dev/null
+++ b/testdata/data/repos/visibility/VisibilityCheck/DependencyMoved/expected.json
@@ -0,0 +1,3 @@
+{"__class__": "DependencyMoved", "category": "DependencyMoved", "package": "DependencyMoved", "version": "0", "attr": "bdepend", "source": ">=stub/old-name-2.71-r6:2.71", "target": ">=stub/stable-2.71-r6:2.71"}
+{"__class__": "DependencyMoved", "category": "DependencyMoved", "package": "DependencyMoved", "version": "0", "attr": "rdepend", "source": "stub/old-name:2", "target": "stub/stable:2"}
+{"__class__": "DependencyMoved", "category": "DependencyMoved", "package": "DependencyMoved", "version": "0", "attr": "rdepend", "source": "~stub/old-name-2", "target": "~stub/stable-2"}
diff --git a/testdata/repos/visibility/DependencyMoved/DependencyMoved/DependencyMoved-0.ebuild b/testdata/repos/visibility/DependencyMoved/DependencyMoved/DependencyMoved-0.ebuild
new file mode 100644
index 00000000..99509a99
--- /dev/null
+++ b/testdata/repos/visibility/DependencyMoved/DependencyMoved/DependencyMoved-0.ebuild
@@ -0,0 +1,8 @@
+EAPI=7
+DESCRIPTION="Ebuild with dependency on moved package"
+HOMEPAGE="https://github.com/pkgcore/pkgcheck"
+SLOT="0"
+LICENSE="BSD"
+KEYWORDS="~amd64"
+RDEPEND="stub/old-name:2 ~stub/old-name-2"
+BDEPEND=">=stub/old-name-2.71-r6:2.71"
diff --git a/testdata/repos/visibility/profiles/updates/1Q-2024 b/testdata/repos/visibility/profiles/updates/1Q-2024
new file mode 100644
index 00000000..518e4bf5
--- /dev/null
+++ b/testdata/repos/visibility/profiles/updates/1Q-2024
@@ -0,0 +1 @@
+move stub/old-name stub/stable