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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 9592D139694 for ; Wed, 31 May 2017 07:33:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A65A8E0E9B; Wed, 31 May 2017 07:33:04 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 50651E0E93 for ; Wed, 31 May 2017 07:33:04 +0000 (UTC) Received: from localhost (unknown [IPv6:2a01:e34:eeaa:6bd0:4ecc:6aff:fe03:1cfc]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: aballier) by smtp.gentoo.org (Postfix) with ESMTPSA id DF539341704 for ; Wed, 31 May 2017 07:33:02 +0000 (UTC) Date: Wed, 31 May 2017 09:32:57 +0200 From: Alexis Ballier To: gentoo-dev@lists.gentoo.org Subject: Re: [gentoo-dev] [RFC] Forced/automatic USE flag constraints (codename: ENFORCED_USE) Message-ID: <20170531093257.23b66f88@gentoo.org> In-Reply-To: <1496213717.1164.1.camel@gentoo.org> References: <1496071993.31087.1.camel@gentoo.org> <20170529200037.2559f80a@gentoo.org> <1496093035.12795.3.camel@gentoo.org> <20170530094245.40e1cf64@gentoo.org> <20170530092245.681d4aeb@snowblower> <20170530104654.31b89e10@gentoo.org> <20170530095607.1adbc0b8@snowblower> <20170530112518.65b4f9e9@gentoo.org> <22829.24276.295.969060@a1i15.kph.uni-mainz.de> <1496154812.1238.5.camel@gentoo.org> <20170530173340.0b575526@gentoo.org> <1496167898.1335.1.camel@gentoo.org> <20170530204614.61e8e42c@gentoo.org> <1496213717.1164.1.camel@gentoo.org> Organization: Gentoo X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 223c61d7-213e-4c2a-b173-299606b97d80 X-Archives-Hash: 2118b0bcf5369272b6d50fb00864c462 On Wed, 31 May 2017 08:55:17 +0200 Micha=C5=82 G=C3=B3rny wrote: > On wto, 2017-05-30 at 20:46 +0200, Alexis Ballier wrote: > > On Tue, 30 May 2017 20:11:38 +0200 > > Micha=C5=82 G=C3=B3rny wrote: > > [...] =20 > > > > > Of course, we could just validate all the possible cases via > > > > > repoman, and reject the ebuild if there's at least one > > > > > conflict between them. Not sure how to express that properly > > > > > in the spec though. Not sure how it would work > > > > > practically. =20 > > > >=20 > > > > Adding a 2^n check to repoman isn't gonna work well. > > > > =20 > > >=20 > > > I'm not saying it's the most optimal algorithm of verifying > > > the correctness of the constraints. It's just the one that's quite > > > obvious -- relatively simple and reliable. If someone can come up > > > with something better that covers at least the most common cases, > > > I'm all for it. > > >=20 > > > That said, this wouldn't be that much of a problem if we can keep > > > the n low. For a start, we can rule out all flags that don't > > > appear in REQUIRED_USE at all. Furthermore, I think we could also > > > ignore the constraints for flags that don't appear there at least > > > 'twice', and so on. =20 > >=20 > > :) > >=20 > > You're applying classical techniques to lower the size of a SAT > > instance so that your exponential algorithm does not explode, but > > it's still hard. > >=20 > > I'm not sure what you want: If you want to detect that there is an > > impossible constraint, well, ebuild writer will notice soon enough > > when testing it. If you want to detect that there is a way to have a > > conflict between useflags, then there will be valid cases where this > > will happen. > >=20 > > That said, assuming we have REQUIRED_USE in CNF form, its negation > > is in DNF form. Solving SAT on DNF formulas is easy (linear I > > think), and this would give you an assignment of useflags > > triggering an impossible constraint. e.g. 'foo? ( bar )' with > > USE=3D'foo -bar' in make.conf. This could be used to trigger a > > repoman warning but basically every single ebuild would trigger > > those. =20 >=20 > Not sure if we understand each other. >=20 > I'd like the constraints to be plain straightforward, to the point of > having only one acceptable solution. No special Portage-style > algorithms that attempt to provide a reasonable solution to > unreasonable input, resulting in horrible solutions that need 20 more > hacks every few months. Yes, we definitely agree here. For that, you need to kill the SAT solver and define (spec) what is the straightforward solution, aka a deterministic and straightforward (*) algorithm. Otherwise, you fall into the problems Ciaran explained in an earlier email. (*) It's better for the algorithm to be simple enough so that REQUIRED_USE can be written easily for achieving a given behavior. > For example: >=20 > foo? ( bar ) >=20 > would mean 'if you have USE=3Dfoo, then USE=3Dbar is enabled as well'. Not > 'find some random solution which satisfies this'. In other words, here > changing USE=3Dfoo into USE=3D-foo is not an acceptable solution. What if I specifically set USE=3D-bar in make.conf ? Do we really want PM to override that without telling me ? I believe that, from the ebuild POV, the ternary useflag model is more appropriate: You have a whole bunch of ways to specify useflags with portage (make.conf, package.use, profiles, command line, ...). From the ebuild those are collapsed into 'user input'. You only have IUSE (with its defaults) and that's what the auto-solver should play with: those are the flags that can be toggled. > Now, this also means that every constraint that can't be solved in > this easy fashion is invalid. We want to detect that, and warn the > developer. Some of those could be tricky. Simple example: >=20 > foo? ( baz ) bar? ( !baz ) >=20 > This one is invalid because USE=3D'foo bar' requires both 'baz' and > '!baz' as a solution. Remember that we don't want to do any changes > besides what's explicitly written there, no guessing. Besides that, what makes it invalid ? How is it more invalid than '?? ( foo bar )' ? > However, the > following should be valid: >=20 > foo? ( baz ) bar? ( !foo !baz ) >=20 > Because now we clearly indicate that USE=3Dbar disables USE=3Dfoo, > and therefore makes the first constraint inapplicable. It clearly > indicates course of action for all combinations: Ok, I now think you're aiming for giving full power to the solver, overriding user inputs if necessary. Before going further, I think we should first agree on what are the useflags such a solver can toggle. I'm not sure 'USE=3Dfoo emerge blah' should disable foo instead of failing for example. Alexis.