Gentoo Archives: gentoo-dev

From: William Hubbs <williamh@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] Re: RFC: USE flags in virtuals, to allow a specific provider to be determined
Date: Sun, 27 Jul 2014 15:39:01
Message-Id: 20140727153849.GA17979@linux1
In Reply to: [gentoo-dev] Re: RFC: USE flags in virtuals, to allow a specific provider to be determined by Jonathan Callen
1 On Sat, Jul 26, 2014 at 01:45:46PM -0400, Jonathan Callen wrote:
2
3 *snip*
4
5 > If you want to say "At most one of the flags 'foo', 'bar', and 'baz'
6 > may be selected", then you say it like so (requires EAPI=5):
7 >
8 > REQUIRED_USE="?? ( foo bar baz )"
9 >
10 > If you want to say "Exactly one of the flags ...", then you use:
11 >
12 > REQUIRED_USE="^^ ( foo bar baz )"
13 >
14 > And, as always, you can say "At least one of the flags ..." with:
15 >
16 > REQUIRED_USE="|| ( foo bar baz )"
17 >
18 > While each of these can be written using the "foo? ( !bar )"-type
19 > primitives, the messages portage outputs are generally better with
20 > '??', '^^', and '||', as you might see something like:
21 >
22 > "
23 > The following REQUIRED_USE flag constraints are unsatisfied:
24 > at-most-one-of ( foo bar baz )
25 > "
26 >
27 > Which is, in my opinion, more readable.
28
29 Now I understand what ciaranm was suggesting in pkg_pretend. Note, this
30 is not shell syntax, but it conveys the idea...
31
32 pkg_pretend() {
33 count=0
34 for x in foo bar bas; do
35 use $x && count += 1
36 done
37 # Now, if count == 0 none of the flags are used, and
38 # if count > 1 more than one is used, so die whenever appropriate
39 # with any error message you choose.
40 }
41
42 William

Attachments

File name MIME type
signature.asc application/pgp-signature