summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico2012-04-15 22:21:49 (GMT)
committerZac Medico2012-04-15 22:23:11 (GMT)
commitdb49b97f8d9d855482ecdc9a5760d3d620948d1d (patch)
tree6bf297444e0aae65429be4ee7129bc2c964fb7bc
parent4fd43df42a9705bdb7681f4d67fb49b8da24a5d9 (diff)
repoman: update EAPI.definition check for PMS
The plan is to update PMS section 8.3.1 as discussed here: http://archives.gentoo.org/gentoo-pms/msg_ef7635aa655913f2386e64e385f5a6ae.xml
-rwxr-xr-xbin/repoman2
-rw-r--r--man/repoman.13
-rw-r--r--pym/repoman/checks.py34
3 files changed, 28 insertions, 11 deletions
diff --git a/bin/repoman b/bin/repoman
index 4253924..651c0be 100755
--- a/bin/repoman
+++ b/bin/repoman
@@ -326,7 +326,7 @@ qahelp={
"LICENSE.virtual":"Virtuals that have a non-empty LICENSE variable",
"DESCRIPTION.missing":"Ebuilds that have a missing or empty DESCRIPTION variable",
"DESCRIPTION.toolong":"DESCRIPTION is over %d characters" % max_desc_len,
- "EAPI.definition":"EAPI is defined after an inherit call (must be defined before)",
+ "EAPI.definition":"EAPI definition does not conform to PMS section 8.3.1 (first non-comment, non-blank line)",
"EAPI.deprecated":"Ebuilds that use features that are deprecated in the current EAPI",
"EAPI.incompatible":"Ebuilds that use features that are only available with a different EAPI",
"EAPI.unsupported":"Ebuilds that have an unsupported EAPI version (you must upgrade portage)",
diff --git a/man/repoman.1 b/man/repoman.1
index 37babcd..0e0715c 100644
--- a/man/repoman.1
+++ b/man/repoman.1
@@ -146,7 +146,8 @@ Syntax error in DEPEND (usually an extra/missing space/parenthesis)
Ebuilds that have a missing or empty DESCRIPTION variable
.TP
.B EAPI.definition
-EAPI is defined after an inherit call (must be defined before)
+EAPI definition does not conform to PMS section 8.3.1 (first
+non\-comment, non\-blank line)
.TP
.B EAPI.deprecated
Ebuilds that use features that are deprecated in the current EAPI
diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py
index 50c017a..c3d110f 100644
--- a/pym/repoman/checks.py
+++ b/pym/repoman/checks.py
@@ -283,21 +283,37 @@ class EbuildUselessCdS(LineCheck):
self.check_next_line = True
class EapiDefinition(LineCheck):
- """ Check that EAPI is defined before inherits"""
+ """
+ Check that EAPI assignment conforms to PMS section 8.3.1
+ (first non-comment, non-blank line).
+ """
repoman_check_name = 'EAPI.definition'
+ ignore_comment = True
- eapi_re = re.compile(r'^EAPI=')
- inherit_re = re.compile(r'^\s*inherit\s')
+ # This pattern is specified by PMS section 8.3.1.
+ _eapi_re = re.compile(r"^[ \t]*EAPI=(['\"]?)([A-Za-z0-9+_.-]*)\1[ \t]*(#.*)?$")
def new(self, pkg):
- self.inherit_line = None
+ self._cached_eapi = pkg.metadata['EAPI']
+ self._parsed_eapi = None
+ self._eapi_line_num = None
def check(self, num, line):
- if self.eapi_re.match(line) is not None:
- if self.inherit_line is not None:
- return errors.EAPI_DEFINED_AFTER_INHERIT
- elif self.inherit_re.match(line) is not None:
- self.inherit_line = line
+ if self._eapi_line_num is None and line.strip():
+ self._eapi_line_num = num + 1
+ m = self._eapi_re.match(line)
+ if m is not None:
+ self._parsed_eapi = m.group(2)
+
+ def end(self):
+ if self._parsed_eapi is None:
+ if self._cached_eapi != "0":
+ yield "valid EAPI assignment must occur on or before line: %d" % \
+ self._eapi_line_num
+ elif self._parsed_eapi != self._cached_eapi:
+ yield ("bash returned EAPI '%s' which does not match "
+ "assignment on line: %d") % \
+ (self._cached_eapi, self._eapi_line_num)
class EbuildPatches(LineCheck):
"""Ensure ebuilds use bash arrays for PATCHES to ensure white space safety"""