From: "Arthur Zamarin" <arthurzam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/, tests/ebuild/
Date: Thu, 22 Dec 2022 07:11:55 +0000 (UTC) [thread overview]
Message-ID: <1671693100.0517f1315251e5693ef994b2e2ae20d5aef13c6c.arthurzam@gentoo> (raw)
commit: 0517f1315251e5693ef994b2e2ae20d5aef13c6c
Author: Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Thu Dec 22 01:45:29 2022 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> 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 <ferringb <AT> gmail.com>
Closes: https://github.com/pkgcore/pkgcore/pull/381
Signed-off-by: Arthur Zamarin <arthurzam <AT> 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
next reply other threads:[~2022-12-22 7:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-22 7:11 Arthur Zamarin [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-01-12 7:13 [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/ebuild/, tests/ebuild/ Arthur Zamarin
2023-12-26 17:45 Arthur Zamarin
2023-08-28 17:49 Arthur Zamarin
2022-10-08 10:09 Arthur Zamarin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1671693100.0517f1315251e5693ef994b2e2ae20d5aef13c6c.arthurzam@gentoo \
--to=arthurzam@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox