On Wed, Mar 07, 2012 at 09:41:02PM +0100, Ulrich Mueller wrote > Written in a more formal way, appropriate for a specification: > - Ebuilds must contain at most one EAPI assignment statement. > - It must occur within the first N lines of the ebuild (N=10 and N=30 > have been suggested). > - The statement must match the following regular expression (extended > regexp syntax): > ^[ \t]*EAPI=(['"]?)([A-Za-z0-9._+-]*)\1[ \t]*(#.*)?$ > > Note: The first and the third point are already fulfilled by all > ebuilds in the Portage tree. The second point will require very few > ebuilds to be changed (9 packages for N=10, or 2 packages for N=30).
The second point could be rendered moot with a little sanity checking like so... #!/bin/bash counter=`grep -c "^EAPI=" ${1}` if [ ${counter} -eq 0 ]; then # <call routine for processing EAPI 0> exit elif [ ${counter} -gt 1 ]; then echo "***ERROR*** only 1 line allowed beginning with EAPI=" exit else # <parse value of EAPI and call appropriate ebuild parser version> exit fi This treats the EAPI statement as a declaration, and doesn't care where it shows up in the file. I'm assuming no leading blanks in front of "EAPI". -- Walter Dnes <waltd...@waltdnes.org>