From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 37723158020 for ; Thu, 22 Dec 2022 07:12:02 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B736AE085B; Thu, 22 Dec 2022 07:11:59 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 9F149E085B for ; Thu, 22 Dec 2022 07:11:59 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 7A1013412D5 for ; Thu, 22 Dec 2022 07:11:58 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id B10EA7F1 for ; Thu, 22 Dec 2022 07:11:55 +0000 (UTC) From: "Arthur Zamarin" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Arthur Zamarin" Message-ID: <1671693100.0517f1315251e5693ef994b2e2ae20d5aef13c6c.arthurzam@gentoo> Subject: [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/, tests/ebuild/ X-VCS-Repository: proj/pkgcore/pkgcore X-VCS-Files: src/pkgcore/ebuild/restricts.py tests/ebuild/test_atom.py X-VCS-Directories: tests/ebuild/ src/pkgcore/ebuild/ X-VCS-Committer: arthurzam X-VCS-Committer-Name: Arthur Zamarin X-VCS-Revision: 0517f1315251e5693ef994b2e2ae20d5aef13c6c X-VCS-Branch: master Date: Thu, 22 Dec 2022 07:11:55 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: db8894ae-ebd5-4800-99f7-1d569fca2d2a X-Archives-Hash: 5918feb276b4e701822e1bae69286c2a commit: 0517f1315251e5693ef994b2e2ae20d5aef13c6c Author: Brian Harring gmail com> AuthorDate: Thu Dec 22 01:45:29 2022 +0000 Commit: Arthur Zamarin gentoo org> CommitDate: Thu Dec 22 07:11:40 2022 +0000 URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=0517f131 Fix use default dep matching when working against IUSE defaults. Tests are added to validate, but essentially an atom like `sys-libs/libxcrypt[abi_x86_32(-),abi_x86_64(-),system(-)]` would fail to match IUSE='+system' due to the restriction using the unstripped iuse for a set check. With that fixed, the resolver- at least on my system- now actually can generate solutions that are sane/correct. Signed-off-by: Brian Harring gmail.com> Closes: https://github.com/pkgcore/pkgcore/pull/381 Signed-off-by: Arthur Zamarin gentoo.org> src/pkgcore/ebuild/restricts.py | 20 ++++++++++---------- tests/ebuild/test_atom.py | 23 ++++++++++++++++++++++- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/src/pkgcore/ebuild/restricts.py b/src/pkgcore/ebuild/restricts.py index 8240717e8..3b847fa55 100644 --- a/src/pkgcore/ebuild/restricts.py +++ b/src/pkgcore/ebuild/restricts.py @@ -222,8 +222,8 @@ class _UseDepDefaultContainment(values.ContainmentMatch): def match(self, val): reduced_vals = self.vals - iuse, use = val - if reduced_vals.issubset(iuse): + iuse_stripped, use = val + if reduced_vals.issubset(iuse_stripped): # use normal pathways. return values.ContainmentMatch.match(self, use) if self.if_missing == self.negate: @@ -234,7 +234,7 @@ class _UseDepDefaultContainment(values.ContainmentMatch): # to reach here, either we're trying to force all flags false and the default is False, # or we're trying to force all flags on, and the default is on. # recall that negate is unfortunately a double negative in labeling... - reduced_vals = reduced_vals.intersection(iuse) + reduced_vals = reduced_vals.intersection(iuse_stripped) if reduced_vals: return values.ContainmentMatch.match(self, use, _values_override=reduced_vals) # nothing to match means all are missing, but the default makes them considered a match. @@ -243,12 +243,12 @@ class _UseDepDefaultContainment(values.ContainmentMatch): def force_False(self, pkg, attr, val): reduced_vals = self.vals # see comments in .match for clarification of logic. - iuse, use = val - if reduced_vals.issubset(iuse): + iuse_stripped, use = val + if reduced_vals.issubset(iuse_stripped): return values.ContainmentMatch.force_False(self, pkg, 'use', use) if self.if_missing == self.negate: return False - reduced_vals = reduced_vals.intersection(iuse) + reduced_vals = reduced_vals.intersection(iuse_stripped) if reduced_vals: return values.ContainmentMatch.force_False(self, pkg, 'use', use, reduced_vals) return True @@ -256,12 +256,12 @@ class _UseDepDefaultContainment(values.ContainmentMatch): def force_True(self, pkg, attr, val): reduced_vals = self.vals # see comments in .match for clarification of logic. - iuse, use = val - if reduced_vals.issubset(iuse): + iuse_stripped, use = val + if reduced_vals.issubset(iuse_stripped): return values.ContainmentMatch.force_True(self, pkg, 'use', use) if self.if_missing == self.negate: return False - reduced_vals = reduced_vals.intersection(iuse) + reduced_vals = reduced_vals.intersection(iuse_stripped) if reduced_vals: return values.ContainmentMatch.force_True(self, pkg, 'use', use, reduced_vals) return True @@ -287,7 +287,7 @@ class UseDepDefault(packages.PackageRestrictionMulti): else: v = values.AlwaysTrue - super().__init__(('iuse', 'use'), v) + super().__init__(('iuse_stripped', 'use'), v) def _parse_nontransitive_use(sequence): diff --git a/tests/ebuild/test_atom.py b/tests/ebuild/test_atom.py index ceb4c4959..0893b817a 100644 --- a/tests/ebuild/test_atom.py +++ b/tests/ebuild/test_atom.py @@ -2,15 +2,16 @@ from functools import partial from pickle import dumps, loads import pytest +from snakeoil.compatibility import cmp from pkgcore.ebuild import atom, errors, restricts from pkgcore.ebuild.cpv import CPV from pkgcore.restrictions.boolean import AndRestriction from pkgcore.test.misc import FakePkg, FakeRepo -from snakeoil.compatibility import cmp from ..restrictions.utils import TestRestriction + def assert_equal_bidirectional(o1, o2): # logic bugs hidden behind short circuiting comparisons for metadata # is why we test the comparison *both* ways. @@ -547,3 +548,23 @@ class TestAtom(TestRestriction): def test_get_atom_without_use_deps(self, original, wanted): orig_atom = self.kls(original) assert str(orig_atom.get_atom_without_use_deps) == wanted + + @pytest.mark.parametrize(('dep', 'iuse', 'use', 'wanted', 'eapi'), ( + ("x(-)", {'x'}, {'x'}, True, '5'), + ("x(-)", {'x'}, (), False, '5'), + ("x(+)", (), (), True, '5'), + ("x(-)", (), (), False, '5'), + ("x(-),y(-)", (), (), False, '5'), + ("x(-),y(-)", {'x', 'y'}, ("x", "y"), True, '5'), + ("x(+),y(-)", (), (), False, '5'), + ("x(+),y(-)", {"y"}, (), False, '5'), + ("x(+),y(-)", {'y'}, {"y"}, True, '5'), + # verify that it's not sensitive to iuse defaults + ("x(-)", {"+x"}, {"x"}, True, '5'), + ("x(+)", {"-x"}, {"x"}, True, '5'), + )) + def test_use_dep_defaults(self, dep, iuse, use, wanted, eapi): + pkg = FakePkg("dev-util/diffball-1", eapi=eapi, iuse=frozenset(iuse), use=frozenset(use)) + a = self.kls(f'dev-util/diffball[{dep}]') + #import pdb;pdb.set_trace() + assert a.match(pkg) == wanted