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: Mon, 29 May 2017 18:00:58
Message-Id: 20170529200037.2559f80a@gentoo.org
In Reply to: [gentoo-dev] [RFC] Forced/automatic USE flag constraints (codename: ENFORCED_USE) by "Michał Górny"
1 On Mon, 29 May 2017 17:33:13 +0200
2 Michał Górny <mgorny@g.o> wrote:
3
4 > Hello,
5 >
6 > For a long time we seem to be missing appropriate tools to handle USE
7 > flag constraints efficiently. EAPI 4 brought REQUIRED_USE but all
8 > things considered, it has proven to be far from an optimal solution.
9 > I would therefore like to discuss adding a better tool to amend or
10 > replace it, to allow for automated handling of USE flag constraints.
11
12
13 This has been discussed in the past and I'm basically all for it. Some
14 more detailed comments below.
15
16 [...]
17 > 2. Specification
18 > ================
19 >
20 > 2.1. Forced USE flag constraints
21 > ================================
22 >
23 > This proposal introduces USE flag constraints that are meant to be
24 > solved automatically by the package manager. This is somewhat similar
25 > to REQUIRED_USE, except that it does not require the user to take any
26 > explicit action. In that regard, it is closer to conditional
27 > package.use.force/mask.
28 >
29 > In the basic form, it can be used to conditionally force a specific
30 > flag to be enabled or disabled. For example:
31 >
32 > foo? ( bar )
33 >
34 > would mean that the bar flag is implicitly enabled (forced) if foo is
35 > enabled as well. Appropriately:
36 >
37 > foo? ( !bar )
38 >
39 > would mean that the bar flag is implicitly disabled (masked) in that
40 > case.
41
42 All good here.
43
44
45 > It can also be used with multi-flag ??, ^^ and || constraints, i.e.:
46 >
47 > - ?? means that at most one of the flags can be enabled. If user
48 > configuration causes more than one of the flags to be enabled,
49 > additional flags are implicitly disabled (masked) to satisfy
50 > the constraint.
51 >
52 > - || means that at least one of the flags must be enabled. If user
53 > configuration causes none of the flags to be enabled, one of them is
54 > enabled implicitly (forced).
55 >
56 > - ^^ means that exactly one of the flags must be enabled. The behavior
57 > is a combination of both above constraints.
58 >
59 > The automated solving of USE constraints would require the developers
60 > to consider the implicit effect of the constraints they are writing.
61
62
63 Can you provide an efficient algorithm for the above syntax?
64 That is, given a set of +/- useflags forced by user, output the set of
65 effective useflags (or a rant if it is inconsistent).
66 Maybe I'm mistaken, but I doubt it is possible with n-ary constraints.
67
68 Now the extra question: Do those n-ary operators have any advantage ?
69 The point is to express some preference, below you suggest to leave
70 that to the user, but what about leaving that to the ebuild developer?
71 That way, e.g., || can be rewritten as implications: '|| ( a b c )'
72 becomes '!b? !c? a' meaning if none is enabled then a is automatically
73 enabled.
74
75 Note that with only unary constraints, computing the set of effective
76 useflags becomes trivial (linear in the # of useflags + constraints):
77 take the constraints as a list, solve the first one, add its
78 consequences (if any) to the set of forced useflags, continue with next
79 constraint or rant if the set of forced flags is inconsistent.
80
81
82 > 2.2. UI implications
83 > ====================
84 [...]
85
86 I really like that part. It becomes even simpler with only unary
87 constraints :)
88
89 [...]
90 > 2.4. Backwards compatibility
91 > ============================
92 >
93 > Before choosing the exact way of implementing this, we need to answer
94 > how far we want to provide backwards compatibility. In particular:
95 >
96 > a. Do we need the REQUIRED_USE requiring explicit user selection? Or
97 > can we rely completely on other solutions (automatic solving,
98 > pkg_pretend())?
99 >
100 > b. Would changing REQUIRED_USE behavior in place cause unintended side
101 > effects? Are we going to accept those effects until the packages are
102 > fixed? (e.g. selecting less preferred solution of constraint)
103
104
105 I would prefer changing REQUIRED_USE in a new EAPI. We definitely do
106 not need a new variable, REQUIRED_USE is good enough, but PMS has been
107 vague enough not to define that so we can't assume the selection of
108 auto-enabled useflags will be what was meant rather than something
109 completely stupid.
110
111 I'm even more inclined towards changing that in a new EAPI since using
112 the current REQUIRED_USE syntax seems to introduce yet another
113 exponential algorithm in the critical path of 'emerge -uDN world'...
114
115 [...]
116 > 2.5. Ebuild interface
117 > =====================
118 >
119 > This section is most flexible as I don't really care how it's done,
120 > as long as it's done. Depending on our preferences, and the answers to
121 > questions in the preceding section, the options include:
122 >
123 > 1. changing behavior of REQUIRED_USE retroactively -- i.e. making
124 > Portage start solving USE constraints automatically, and being able to
125 > rely on that a few months from now,
126 >
127 > 2. changing behavior of REQUIRED_USE in a future EAPI,
128 >
129 > 3. adding ENFORCED_USE with the new behavior in a future EAPI
130 > (and either keeping or removing REQUIRED_USE),
131 >
132 > 4. adding special syntax to REQUIRED_USE to indicate which constraints
133 > can be solved automatically,
134 >
135 > 5. adding special syntax to IUSE to indicate which flags can be
136 > enabled or disabled automatically via REQUIRED_USE (a little
137 > different from the exact proposal),
138 >
139 > 6. adding a dedicated variable to indicate USE_EXPAND sets that can be
140 > solved automatically via REQUIRED_USE (partial solution).
141
142
143 In that order:
144 2
145 1
146 4
147 _reopen_nominations
148 3 5 6
149
150
151 [...]
152 > 4. Comments
153 > ===========
154 >
155 > What do you think?
156
157 +1
158
159 Alexis.

Replies