aboutsummaryrefslogtreecommitdiff
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-04-15 15:21:49 -0700
committerZac Medico <zmedico@gentoo.org>2012-04-15 15:23:11 -0700
commitdb49b97f8d9d855482ecdc9a5760d3d620948d1d (patch)
tree6bf297444e0aae65429be4ee7129bc2c964fb7bc /pym
parentHandle SystemError when importing xml libraries. (diff)
downloadportage-db49b97f8d9d855482ecdc9a5760d3d620948d1d.tar.gz
portage-db49b97f8d9d855482ecdc9a5760d3d620948d1d.tar.bz2
portage-db49b97f8d9d855482ecdc9a5760d3d620948d1d.zip
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
Diffstat (limited to 'pym')
-rw-r--r--pym/repoman/checks.py34
1 files changed, 25 insertions, 9 deletions
diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py
index 50c017af2..c3d110f88 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"""