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
In Reply to: Re: [gentoo-dev] RFD: EAPI specification in ebuilds by "Michał Górny"
On 03/09/2012 12:04 AM, Michał Górny wrote:
>> >> This is of course isomorphic to requiring a specific EAPI=4 format, >> but does allow you to do stupid things like x=`seq 4 4`; eapi $x; if >> you want. > > What advantage does it give us? We still can't change ebuild syntax in > global scope because bash will barf. >
Not in EAPI=5, no, but once all PMs are using the eapi function we could. The function can do any crazy thing you want. Right now, we need to source the entire ebuild to get at its environment. Before we source it for real, we just want to know the value of $EAPI. Since eapi() will be the first function called, it can be our interface to this variable. Here's a stupid but hopefully clear example: $ cat test.ebuild eapi 4 HOMEPAGE="" echo "test.ebuild, current EAPI=${EAPI}" $ cat #!/bin/bash function eapi() { if [ "$TELL_ME_YOUR_EAPI" == 1 ]; then exit $1 fi export EAPI=$1 } export TELL_ME_YOUR_EAPI=1 `eval 'source test.ebuild'` echo "Found EAPI: $?" export TELL_ME_YOUR_EAPI=0 source test.ebuild This sources it once, which short-circuits at the eapi() call returning '4'. Then we source it a second time with EAPI=4, and see that it makes it past the call to eapi() where any incompatible features would be. $ ./ Found EAPI: 4 test.ebuild, current EAPI=4


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