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