Gentoo Archives: gentoo-dev

From: Daniel Drake <dsd@g.o>
To: gentoo-dev@l.g.o
Cc: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-dev] More general interface to use flags
Date: Fri, 02 Nov 2007 14:21:44
Message-Id: 472B31BE.8080504@gentoo.org
1 Marijn Schouten (hkBst) wrote:
2 > Hi list,
3 >
4 > the current interface to use flags, useq, usev, use_with, use_enable, as
5 > defined in /usr/lib/portage/bin/ebuild.sh lacks generality. The common thing
6 > is testing a use flag and possibly echoing a string, but there is no function
7 > that implements this common behaviour.
8 >
9 > I propose that we add such a function. Proposed name for the function is "ifuse".
10
11 So these modifications are just cleanups to portage internals and would
12 not affect the interfaces or behaviour of use/use_with/...?
13
14 > I also propose to add the utility function "ifv" which is useful for writing
15 > concise and clean code.
16 >
17 > These additions would allow you to easily define your own function for
18 > processing use flags in ebuilds and eclasses. One such example is
19 >
20 > use_mime() {
21 > local WORD=$(ifv "$2" "$2" "$1")
22 >
23 > ifuse "$1" "${WORD};"
24 > }
25 >
26 > for generating a string of ';'-separated mime-types based on use flags.
27 >
28 > The explanation of this function is:
29 >
30 > #set WORD to argument 2 or if that is empty to argument 1
31 > #output "${WORD};" if use flag $1 is set (or if it starts with ! and is unset)
32 > #otherwise don't output anything
33
34 I don't quite understand what this function does. What ebuild nastiness
35 does it replace, or what does it allow that was not previously possible?
36 (can you give an example?)
37
38 Thanks,
39 Daniel
40 --
41 gentoo-dev@g.o mailing list

Replies

Subject Author
Re: [gentoo-dev] More general interface to use flags "Marijn Schouten (hkBst)" <hkBst@g.o>
Re: [gentoo-dev] More general interface to use flags "Marijn Schouten (hkBst)" <hkBst@g.o>