1 |
On 01/31/2010 12:22 PM, Mike Frysinger wrote: |
2 |
> On Saturday 30 January 2010 18:31:35 Nikos Chantziaras wrote: |
3 |
>> What's the best way to have an ebuild abort if two mutually exclusive |
4 |
>> USE flags are both set? |
5 |
>> |
6 |
>> I'm trying the modify the mozilla-firefox and xulrunner ebuilds to |
7 |
>> support building with OSS instead of ALSA (sadly, the current versions |
8 |
>> of the ebuilds in Portage only allow ALSA to be enabled, not OSS), but |
9 |
>> the build system of Xulrunner/Firefox does not allow to build with both. |
10 |
>> So I need to abort when both "alsa" and "oss" are set rather than having |
11 |
>> the build proceed and the user getting a compilation error later on. |
12 |
> |
13 |
> put a check into pkg_setup() that does ewarn's on conflicting USE flags, and |
14 |
> then have the rest of the ebuild pick a sensible default. in the case of oss |
15 |
> vs alsa, the latter would be the sensible default. |
16 |
> -mike |
17 |
|
18 |
OK, this what I ended up with. Please note that my scripting skills are |
19 |
a bit rusty :P |
20 |
|
21 |
(The wrong line breaks don't appear in the actual ebuild and tabs are |
22 |
used to indent.) |
23 |
|
24 |
|
25 |
In pkg_setup(): |
26 |
|
27 |
if use alsa && use oss ; then |
28 |
einfo |
29 |
ewarn "You have enabled both the \"alsa\" as well as the \"oss\" USE |
30 |
flags. It" |
31 |
ewarn "is not possible to build mozilla-firefox or xulrunner with |
32 |
support for" |
33 |
ewarn "both. ALSA will be used in this case. If you want OSS |
34 |
support, unset the" |
35 |
ewarn "\"alsa\" USE flag and leave only \"oss\" set." |
36 |
fi |
37 |
|
38 |
|
39 |
In src_prepare(): |
40 |
|
41 |
# Switch from ALSA to OSS |
42 |
if use oss && ! use alsa; then |
43 |
ebegin "Switching from ALSA to Open Sound System" |
44 |
sed -i 's/sydney_audio_alsa/sydney_audio_oss/' \ |
45 |
media/libsydneyaudio/src/Makefile.in || die "sed failed!" \ |
46 |
&& sed -i '/alsa\//d' config/system-headers || die "sed failed!" \ |
47 |
&& sed -i '/alsa\//d' \ |
48 |
js/src/config/system-headers || die "sed failed!" \ |
49 |
&& sed -i '/LIB(asound/d' configure.in || die "sed failed!" |
50 |
eend $? |
51 |
fi |
52 |
|
53 |
|
54 |
In src_configure(): |
55 |
|
56 |
# Enable/Disable audio in firefox |
57 |
if use alsa || use oss ; then |
58 |
mozconfig_annotate '' --enable-ogg |
59 |
mozconfig_annotate '' --enable-wave |
60 |
fi |
61 |
|
62 |
|
63 |
In this last one, I'm not sure how to pass something to the first |
64 |
argument of mozconfig_annotate. The original was: |
65 |
|
66 |
mozconfig_use_enable alsa ogg |
67 |
|
68 |
which translates into: |
69 |
|
70 |
mozconfig_annotate 'alsa' --enable-ogg |
71 |
|
72 |
The point is that the user will see which USE flags are responsible for |
73 |
"--enable-*" and "--disable-*" options. Unfortunately, this: |
74 |
|
75 |
mozconfig_use_enable ( alsa || oss ) ogg |
76 |
|
77 |
is not possible. Should I therefore write the block twice in a nested |
78 |
if block or leave it as is (and losing the information about which USE |
79 |
flag resulted in "--enable-ogg|wave"?) |