Gentoo Archives: gentoo-dev

From: Alexis Ballier <aballier@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [RFC] Forced/automatic USE flag constraints (codename: ENFORCED_USE)
Date: Tue, 30 May 2017 18:46:30
Message-Id: 20170530204614.61e8e42c@gentoo.org
In Reply to: Re: [gentoo-dev] [RFC] Forced/automatic USE flag constraints (codename: ENFORCED_USE) by "Michał Górny"
1 On Tue, 30 May 2017 20:11:38 +0200
2 Michał Górny <mgorny@g.o> wrote:
3 [...]
4 > > > Of course, we could just validate all the possible cases via
5 > > > repoman, and reject the ebuild if there's at least one conflict
6 > > > between them. Not sure how to express that properly in the spec
7 > > > though. Not sure how it would work practically.
8 > >
9 > > Adding a 2^n check to repoman isn't gonna work well.
10 > >
11 >
12 > I'm not saying it's the most optimal algorithm of verifying
13 > the correctness of the constraints. It's just the one that's quite
14 > obvious -- relatively simple and reliable. If someone can come up with
15 > something better that covers at least the most common cases, I'm all
16 > for it.
17 >
18 > That said, this wouldn't be that much of a problem if we can keep the
19 > n low. For a start, we can rule out all flags that don't appear
20 > in REQUIRED_USE at all. Furthermore, I think we could also ignore
21 > the constraints for flags that don't appear there at least 'twice',
22 > and so on.
23
24 :)
25
26 You're applying classical techniques to lower the size of a SAT
27 instance so that your exponential algorithm does not explode, but it's
28 still hard.
29
30 I'm not sure what you want: If you want to detect that there is an
31 impossible constraint, well, ebuild writer will notice soon enough when
32 testing it. If you want to detect that there is a way to have a
33 conflict between useflags, then there will be valid cases where this
34 will happen.
35
36 That said, assuming we have REQUIRED_USE in CNF form, its negation is
37 in DNF form. Solving SAT on DNF formulas is easy (linear I think), and
38 this would give you an assignment of useflags triggering an impossible
39 constraint. e.g. 'foo? ( bar )' with USE='foo -bar' in make.conf.
40 This could be used to trigger a repoman warning but basically every
41 single ebuild would trigger those.

Replies