Skip to content

Commit 6c3107f

Browse files
committed
bugs: handle case where multiple versions of dependency are present
For `dev-dotnet/dotnet-sdk-bin` package, PDEPEND has the value of:: ~dev-dotnet/dotnet-runtime-nugets-10.0.7 ~dev-dotnet/dotnet-runtime-nugets-6.0.36 ~dev-dotnet/dotnet-runtime-nugets-7.0.20 ~dev-dotnet/dotnet-runtime-nugets-8.0.26 ~dev-dotnet/dotnet-runtime-nugets-9.0.15 This value is grouped into a single dependency, which forces the matcher to find a single version matching all of them (impossible). Now I added an extra fallback to handle this case, which should be more robust and handle cases where multiple versions of the same dependency are present. Resolves: #221 Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
1 parent 212779b commit 6c3107f

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

src/pkgdev/scripts/pkgdev_bugs.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ def _find_dependencies(self, pkg: package, keywords: set[str]):
468468
for res in check.feed(self.mk_fake_pkg(pkg, keywords)):
469469
if isinstance(res, visibility.NonsolvableDeps):
470470
for dep in res.deps:
471-
dep = atom(dep).no_usedeps
471+
dep: atom = atom(dep).no_usedeps
472472
issues[dep.key][res.keyword.lstrip("~")].add(dep)
473473

474474
for pkgname, problems in issues.items():
@@ -481,13 +481,25 @@ def _find_dependencies(self, pkg: package, keywords: set[str]):
481481
for keyword, deps in problems.items():
482482
try:
483483
match = self.find_best_match(deps, pkgset)
484+
results[match].add(keyword)
484485
except (ValueError, IndexError):
485-
deps_str = " , ".join(map(str, deps))
486-
bugs.error(
487-
f"unable to find match for restrictions: {deps_str}",
488-
status=3,
489-
)
490-
results[match].add(keyword)
486+
# deps may contain contradictory version atoms (e.g. from
487+
# multiple USE-conditional targets like net8.0/net9.0/net10.0),
488+
# so try each atom individually
489+
found = False
490+
for dep in deps:
491+
try:
492+
match = self.find_best_match({dep}, pkgset)
493+
results[match].add(keyword)
494+
found = True
495+
except (ValueError, IndexError):
496+
pass
497+
if not found:
498+
deps_str = " , ".join(map(str, deps))
499+
bugs.error(
500+
f"unable to find match for restrictions: {deps_str}",
501+
status=3,
502+
)
491503
yield from results.items()
492504

493505
def load_targets(self, targets: list[tuple[str, str]]):

0 commit comments

Comments
 (0)