* [gentoo-commits] portage r10724 - main/branches/2.1.2/bin
@ 2008-06-19 5:14 Zac Medico (zmedico)
0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2008-06-19 5:14 UTC (permalink / raw
To: gentoo-commits
Author: zmedico
Date: 2008-06-19 05:14:38 +0000 (Thu, 19 Jun 2008)
New Revision: 10724
Modified:
main/branches/2.1.2/bin/repoman
Log:
Refactor the 'inherit.autotools' and 'IUSE.undefined' checks
into classes derived from LineCheck.
Modified: main/branches/2.1.2/bin/repoman
===================================================================
--- main/branches/2.1.2/bin/repoman 2008-06-19 05:01:18 UTC (rev 10723)
+++ main/branches/2.1.2/bin/repoman 2008-06-19 05:14:38 UTC (rev 10724)
@@ -997,11 +997,17 @@
"""A regular expression to determine whether to ignore the line"""
ignore_line = False
+ def new(self):
+ pass
+
def check(self, num, line):
"""Run the check on line and return error if there is one"""
if self.re.match(line):
return self.error
+ def end(self):
+ pass
+
class EbuildQuote(LineCheck):
"""Ensure ebuilds have valid quoting around things like D,FILESDIR, etc..."""
@@ -1117,44 +1123,79 @@
if match:
return "Quoted \"${A}\" on line: %d"
+class InheritAutotools(LineCheck):
+ """
+ Make sure appropriate functions are called in
+ ebuilds that inherit autotools.eclass.
+ """
+
+ repoman_check_name = 'inherit.autotools'
+ ignore_line = re.compile(r'(^|\s*)#')
+ _inherit_autotools_re = re.compile(r'^\s*inherit\s(.*\s)?autotools(\s|$)')
+ _autotools_funcs = (
+ "eaclocal", "eautoconf", "eautoheader",
+ "eautomake", "eautoreconf", "_elibtoolize")
+ _autotools_func_re = re.compile(r'(^|\s)(' + \
+ "|".join(_autotools_funcs) + ')(\s|$)')
+
+ def new(self):
+ self._inherit_autotools = None
+ self._autotools_func_call = None
+
+ def check(self, num, line):
+ if self._inherit_autotools is None:
+ self._inherit_autotools = self._inherit_autotools_re.match(line)
+ if self._inherit_autotools is not None and \
+ self._autotools_func_call is None:
+ self._autotools_func_call = self._autotools_func_re.search(line)
+
+ def end(self):
+ if self._inherit_autotools and self._autotools_func_call is None:
+ yield 'no eauto* function called'
+
+class IUseUndefined(LineCheck):
+ """
+ Make sure the ebuild defines IUSE (style guideline
+ says to define IUSE even when empty).
+ """
+
+ repoman_check_name = 'IUSE.undefined'
+ _iuse_def_re = re.compile(r'^IUSE=.*')
+
+ def new(self):
+ self._iuse_def = None
+
+ def check(self, num, line):
+ if self._iuse_def is None:
+ self._iuse_def = self._iuse_def_re.match(line)
+
+ def end(self):
+ if self._iuse_def is None:
+ yield 'IUSE is not defined'
+
_constant_checks = tuple((c() for c in (
EbuildQuote, EbuildUselessDodoc,
EbuildUselessCdS, EbuildNestedDie,
- EbuildPatches, EbuildQuotedA)))
+ EbuildPatches, EbuildQuotedA,
+ IUseUndefined, InheritAutotools)))
-_iuse_def_re = re.compile(r'^IUSE=.*')
-_comment_re = re.compile(r'(^|\s*)#')
-_inherit_autotools_re = re.compile(r'^\s*inherit\s(.*\s)?autotools(\s|$)')
-_autotools_funcs = (
- "eaclocal", "eautoconf", "eautoheader",
- "eautomake", "eautoreconf", "_elibtoolize")
-_autotools_func_re = re.compile(r'(^|\s)(' + \
- "|".join(_autotools_funcs) + ')(\s|$)')
+def run_checks(contents, pkg):
+ checks = _constant_checks
-def run_checks(contents, pkg):
- iuse_def = None
- inherit_autotools = None
- autotools_func_call = None
+ for lc in checks:
+ lc.new()
for num, line in enumerate(contents):
- comment = _comment_re.match(line)
- if comment is None:
- if inherit_autotools is None:
- inherit_autotools = _inherit_autotools_re.match(line)
- if inherit_autotools is not None and \
- autotools_func_call is None:
- autotools_func_call = _autotools_func_re.search(line)
- if iuse_def is None:
- iuse_def = _iuse_def_re.match(line)
- for lc in _constant_checks:
+ for lc in checks:
ignore = lc.ignore_line
if not ignore or not ignore.match(line):
e = lc.check(num, line)
if e:
yield lc.repoman_check_name, e % (num + 1)
- if iuse_def is None:
- yield 'IUSE.undefined', 'IUSE is not defined'
- if inherit_autotools and autotools_func_call is None:
- yield 'inherit.autotools', 'no eauto* function called'
+ for lc in checks:
+ i = lc.end()
+ if i is not None:
+ for e in i:
+ yield lc.repoman_check_name, e
if mymode == "commit":
retval = ("","")
--
gentoo-commits@lists.gentoo.org mailing list
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2008-06-19 5:14 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-19 5:14 [gentoo-commits] portage r10724 - main/branches/2.1.2/bin Zac Medico (zmedico)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox