Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: mgorny@g.o
Subject: Re: [gentoo-portage-dev] [PATCH 16/18] Disallow helpers in global scope in EAPI 6
Date: Fri, 16 Jan 2015 19:53:57
Message-Id: 54B96C4F.4080208@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH 16/18] Disallow helpers in global scope in EAPI 6 by Zac Medico
1 On 01/16/2015 10:18 AM, Zac Medico wrote:
2 > On 01/16/2015 02:14 AM, Sergei Trofimovich wrote:
3 >> On Mon, 1 Dec 2014 22:28:34 +0100
4 >> Michał Górny <mgorny@g.o> wrote:
5 >>
6 >>> Disallow calling most of the ebuild helpers in global scope since they
7 >>> are meaningless in that context. Most of them are also prohibited by PMS
8 >>> for all EAPIs, so EAPI 6 sounds like a good moment to finally enforce
9 >>> that restriction.
10 >>> ---
11 >>> bin/eapi.sh | 2 +-
12 >>> 1 file changed, 1 insertion(+), 1 deletion(-)
13 >>>
14 >>> diff --git a/bin/eapi.sh b/bin/eapi.sh
15 >>> index e0ade02..5ab92f4 100644
16 >>> --- a/bin/eapi.sh
17 >>> +++ b/bin/eapi.sh
18 >>> @@ -159,7 +159,7 @@ ___eapi_helpers_can_die() {
19 >>> }
20 >>>
21 >>> ___eapi_disallows_helpers_in_global_scope() {
22 >>> - [[ ${1-${EAPI}} =~ ^(4-python|5-progress)$ ]]
23 >>> + [[ ! ${1-${EAPI}} =~ ^(0|1|2|3|4|4-slot-abi|5|5-hdepend)$ ]]
24 >>> }
25 >>>
26 >>> ___eapi_unpack_is_case_sensitive() {
27 >>
28 >> Looks like it cries on ebuilds with unset EAPI in main tree (attached).
29 >> Can be easily fixed in tree by adding EAPI=0, but better handle it
30 >> here: ${EAPI-0} (untested!)
31 >
32 > Using ${EAPI-0} would not be the correct fix, because portage is
33 > supposed to export the EAPI that was previously determined via the
34 > _parse_eapi_ebuild_head function (preprocessor).
35
36 Actually, ebuild.sh unsets the EAPI just before it sources the ebuild,
37 and then it does this after it sources the ebuild:
38
39 [ "${EAPI+set}" = set ] || EAPI=0
40
41 So, for any code that is called while the ebuild is being sourced, using
42 ${EAPI-0} would be correct.
43 --
44 Thanks,
45 Zac