Gentoo Archives: gentoo-dev

From: Michael Orlitzky <michael@××××××××.com>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] RFD: EAPI specification in ebuilds
Date: Fri, 09 Mar 2012 05:36:22
Message-Id: 4F599692.9050503@orlitzky.com
In Reply to: Re: [gentoo-dev] RFD: EAPI specification in ebuilds by "Michał Górny"
1 On 03/09/2012 12:04 AM, Michał Górny wrote:
2 >>
3 >> This is of course isomorphic to requiring a specific EAPI=4 format,
4 >> but does allow you to do stupid things like x=`seq 4 4`; eapi $x; if
5 >> you want.
6 >
7 > What advantage does it give us? We still can't change ebuild syntax in
8 > global scope because bash will barf.
9 >
10
11 Not in EAPI=5, no, but once all PMs are using the eapi function we could.
12
13 The function can do any crazy thing you want. Right now, we need to
14 source the entire ebuild to get at its environment. Before we source it
15 for real, we just want to know the value of $EAPI. Since eapi() will be
16 the first function called, it can be our interface to this variable.
17 Here's a stupid but hopefully clear example:
18
19 $ cat test.ebuild
20 eapi 4
21 HOMEPAGE="http://www.example.com/"
22 echo "test.ebuild, current EAPI=${EAPI}"
23
24
25 $ cat test-sourcer.sh
26 #!/bin/bash
27
28 function eapi() {
29 if [ "$TELL_ME_YOUR_EAPI" == 1 ]; then
30 exit $1
31 fi
32 export EAPI=$1
33 }
34
35 export TELL_ME_YOUR_EAPI=1
36 `eval 'source test.ebuild'`
37 echo "Found EAPI: $?"
38
39 export TELL_ME_YOUR_EAPI=0
40 source test.ebuild
41
42
43 This sources it once, which short-circuits at the eapi() call returning
44 '4'. Then we source it a second time with EAPI=4, and see that it makes
45 it past the call to eapi() where any incompatible features would be.
46
47 $ ./test-sourcer.sh
48 Found EAPI: 4
49 test.ebuild, current EAPI=4

Replies

Subject Author
Re: [gentoo-dev] RFD: EAPI specification in ebuilds Zac Medico <zmedico@g.o>
Re: [gentoo-dev] RFD: EAPI specification in ebuilds "Michał Górny" <mgorny@g.o>