1 |
Hi all, |
2 |
|
3 |
This is a followup to the discussion on the thread "Suggestion: DONT_USE |
4 |
flags". It describes a new (suggested) system to replace USE flags. I don't |
5 |
include the reasons for switching, they should be obvious. |
6 |
|
7 |
This is a very long post. It includes not just ideas but syntax examples etc. |
8 |
This are just examples, sometimes not even suggestions. If even half of what |
9 |
I've written here is implemented, it will be complete success for this memo. |
10 |
|
11 |
Comments are gladly accepted, only please try to read everything first. |
12 |
|
13 |
------- |
14 |
|
15 |
For clarity, let's call the new system With flags. |
16 |
|
17 |
With flags can serve different purposes: |
18 |
1. They can set usage of shared libraries e.g. qt, sdl. |
19 |
2. They can set ebuild-specific options and program-specific configuration |
20 |
details. This doesn't mean duplicating the program's configuration files, but |
21 |
rather more global things. |
22 |
3. They can address h/w availability & utils (e.g. mmx, 3dnow, pcmcia) and |
23 |
other misc. things. |
24 |
This isn't an important distinction, the above 3 things are just examples. |
25 |
|
26 |
In make.globals (or somewhere else), a large number of With flags will be |
27 |
defined. They will all have default values (yes/no), either static or |
28 |
dynamically determined based on the values of other With flags. |
29 |
|
30 |
Note: I may be misunderstaing the use of make.globals. What I need is a file |
31 |
with unchanging factory settings, which can be customized in make.conf. |
32 |
|
33 |
An entry will look like this (2 lines): |
34 |
|
35 |
qt=yes |
36 |
an X interface library, used e.g. by KDE. |
37 |
|
38 |
Every With flag can have 2 parts of increasing verbosity: |
39 |
1. Name. ex: qt. Default value appended. |
40 |
2. Description. ex: an X interface library, used e.g. by KDE. |
41 |
|
42 |
The above gives an example of a static definition of a flag's default value. |
43 |
A dynamic definition would look like this: |
44 |
|
45 |
flagA=yes |
46 |
flagB=no |
47 |
flagC=flagA # gives yes |
48 |
flagD=!flagA # ! is not, gives no |
49 |
flagE=flagA|flagB # | is inclusive or, gives yes |
50 |
|
51 |
and so on. |
52 |
|
53 |
In make.conf there will be a partial list of flags, preferrably with short |
54 |
comments, for user setting. A user can thus override any default setting. He |
55 |
can also add to make.conf any flag from make.globals and set it, even if it |
56 |
isn't in make.conf's default list. |
57 |
|
58 |
An example entry in make.conf: |
59 |
|
60 |
qt=yes # override here |
61 |
an X interface library, used e.g. by KDE. # This is a description |
62 |
|
63 |
The make.conf entry's description might be longer than the make.globals one. |
64 |
|
65 |
The default list should only include things which apply to more than just one |
66 |
or two packages, and which can be understood by the average end |
67 |
user/developer who isn't particularly familiar with the library/package |
68 |
discussed. No ebuild-specific (e.g. configuration) settings should go here. |
69 |
|
70 |
The default way of will be non-interactive, essentially the same as it is |
71 |
now. However, emerge (and ebuild) will accept a --interactive parameter. |
72 |
|
73 |
Whenever an ebuild needs to make any decision, it will call a function |
74 |
provided by emerge (or ebuild). So (I know this isn't a shell script, but I |
75 |
hate shell scripts!): |
76 |
|
77 |
# need to know whether to build qt interface |
78 |
result = with(qt, "foo uses qt to such and such an effect.") |
79 |
|
80 |
The second parameter to the with function is the description of the |
81 |
applicability of the With flag to this specific ebuild, and what the ebuild |
82 |
will do without it. |
83 |
The ebuild will get a response, it doesn't need to know how the decision was |
84 |
made. |
85 |
|
86 |
The function will have two modes: interactive and noninteractive. |
87 |
|
88 |
In noninteractive mode (the default), the With answer will be decided based |
89 |
on the default value (from make.globals) and the user-defined value if |
90 |
present (make.conf). |
91 |
|
92 |
In interactive mode, activated by the --interactive command line parameter, |
93 |
the user will be asked to decide. This is where the description of the flag |
94 |
is used. |
95 |
The user will see: |
96 |
|
97 |
# emerge --interactive foo.ebuild |
98 |
Calculating dependencies.. done! |
99 |
>>> emerge foo to / |
100 |
Decide: qt (default yes, override No): |
101 |
Description: an X interface library, used e.g. by KDE |
102 |
Specifics: foo uses qt to such and such an effect. |
103 |
[y/N] |
104 |
|
105 |
Note: not all flags need to be defined somewhere! If an ebuild calls with on |
106 |
an undefined flag, it needs to supply a default value. This is the value |
107 |
returned to it in noninteractive mode. The call would become: |
108 |
|
109 |
result = with(qt=yes, "foo uses qt to such and such an effect.") |
110 |
|
111 |
Dynamic definitions can be used as well as static, as defined earlier. |
112 |
|
113 |
The next thing to have is choice betwen mutually exclusive With flags (this |
114 |
is sorely lacking in the USE system). |
115 |
|
116 |
An ebuild might look so: |
117 |
# Choose between mutually exclusive sound output interfaces |
118 |
result=which(sdl_mixer, libmikmod, "Any one of these will do for sound.") |
119 |
|
120 |
In interactive mode, the user will see: |
121 |
|
122 |
# emerge --interactive foo.ebuild |
123 |
Calculating dependencies.. done! |
124 |
>>> emerge foo to / |
125 |
Choose: sdl_mixer, libmikmod (default sdl_mixer): |
126 |
Specifics: Any one of these will do for sound. |
127 |
[sdl_mixer/libmikmod] |
128 |
|
129 |
sdl_mixer is default, simply because it is named first. That is, the ebuild |
130 |
should pass the name of what it wants as default first. |
131 |
Of course this will accept more than two flags at a time. |
132 |
There is no Description (only Specifics) because this is not a 'generic' |
133 |
situation. An ebuild can request choice between any combination of flags in |
134 |
any order. |
135 |
The last parameter passed to Which is thus the Specifics string, all the |
136 |
others are taken to be names of With flags. |
137 |
|
138 |
In non-interactive mode, the which function will simply return the first flag |
139 |
named, sdl_mixer in this example. |
140 |
|
141 |
As above, a flag undefined in make.globals and make.conf can be used. No |
142 |
default value for it is needed. You can just pass a list of flags. |
143 |
|
144 |
------- |
145 |
|
146 |
Subsystem: default values of mutually exclusive choices - groups: |
147 |
|
148 |
It is true that an ebuild can pass any list of flags and get a result. |
149 |
However, for noninteractive operation, it would be very useful to assign |
150 |
default results outside the ebuild (i.e. not by selecting the order of flags |
151 |
passed to which). |
152 |
For this purpose, flags can be 'registered' in make.globals (or make.conf) as |
153 |
belonging to a group (or several groups). An example make.* entry: |
154 |
|
155 |
sdl_mixer=yes (audio-out) |
156 |
Description of sdl_mixer. |
157 |
|
158 |
libmikmod=yes (audio-out) |
159 |
Description of libmikmod. |
160 |
|
161 |
The entries thus classified will be arranged by group. The first flag in a |
162 |
group to be listed becomes the default choice for that group. |
163 |
|
164 |
A flag can be part of any number of groups, or none. Example: |
165 |
libggi=!libsdl (audio-out,video-out) |
166 |
|
167 |
Whenever an ebuild calls which on flags that are all part of one group (e.g. |
168 |
audio-out), this becomes the default for an interactive choice, and the |
169 |
result returned from a noninteractive one. |
170 |
|
171 |
The ebuild doesn't need to know the name of the group, or even that there is |
172 |
one. |
173 |
|
174 |
And, if even this isn't enough, we could add a Groups section in make.* which |
175 |
would: |
176 |
1. Optionally define a group as a list of flags, even if those flags don't |
177 |
specify themselves as part of the group. |
178 |
2. Define the group's order. |
179 |
3. Provide an extra description of the group. |
180 |
For example: |
181 |
|
182 |
<groups> |
183 |
audio-out=libmikmod,sdl_mixer,libggi |
184 |
The audio-out group is foobar foobar foo. |
185 |
|
186 |
In this example, the order in whch the flags are defined is overriden, and |
187 |
libmikmod is set to be the new default choice. |
188 |
|
189 |
The reason we have an entire list and not just a default value is subgroups. |
190 |
If an ebuild asks result=which(sdl_mixer,mikmod,libggi,"select audio lib") |
191 |
then it will get libmikmod (from noninteractive mode) since it's first in the |
192 |
list defined in make.*'s <groups>. |
193 |
If however it says result=which(libggi,libmikmod,"subgroup choice") then it |
194 |
will get sdl_mixer because that's the best ('foremost') choice left without |
195 |
sdl_mixer. |
196 |
|
197 |
------- |
198 |
|
199 |
Comments welcome! |
200 |
|
201 |
-- |
202 |
|
203 |
Dan Armak |
204 |
Gentoo Linux Developer |
205 |
Matan, Israel |