Add a new "ebuild.autotools" check for when ebuilds call
authorZac Medico <zmedico@gentoo.org>
Fri, 11 Jan 2008 09:27:38 +0000 (09:27 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 11 Jan 2008 09:27:38 +0000 (09:27 -0000)
 autotools directly instead of using autotools.eclass.
Thanks to Betelgeuse for the initial patch.

svn path=/main/trunk/; revision=9179

bin/repoman
pym/repoman/checks.py

index 51fc8a395514724e2cb9206f4ef7e489d9d2d2dc..3cb2b68effc5b65acf079064e38806fd82442429 100755 (executable)
@@ -298,6 +298,7 @@ qahelp={
        "ebuild.majorsyn":"This ebuild has a major syntax error that may cause the ebuild to fail partially or fully",
        "ebuild.minorsyn":"This ebuild has a minor syntax error that contravenes gentoo coding style",
        "ebuild.badheader":"This ebuild has a malformed header",
+       "ebuild.autotools":"Ebuild calls autotools directly instead of using autotools.eclass",
        "metadata.missing":"Missing metadata.xml files",
        "metadata.bad":"Bad metadata.xml files",
        "virtual.versioned":"PROVIDE contains virtuals with versions",
@@ -315,6 +316,7 @@ qawarnings=[
 "ebuild.notadded",
 "ebuild.nostable",
 "ebuild.allmasked",
+"ebuild.autotools",
 "ebuild.nesteddie",
 "desktop.invalid",
 "digest.assumed",
index 916003e7eb318749005e60dad4dedb494ceb7cb1..b4f1b016e6d1a87b13693774a62ecaf43218b4a9 100644 (file)
@@ -178,11 +178,25 @@ class EbuildUselessCdS(LineCheck):
                elif self.method_re.match(line):
                        self.check_next_line = True
 
+class Autotools(LineCheck):
+       """Check for direct calls to autotools"""
+       repoman_check_name = 'ebuild.autotools'
+       re = re.compile(r'^[^#]*([^e]|^)(autoconf|automake|aclocal|libtoolize)')
+
+       def check(self, num, line):
+               """Run the check on line and return error if there is one"""
+               m = self.re.match(line)
+               if m is not None:
+                       return ("Direct calls to '%s'" % m.group(2)) + \
+                               " instead of using autotools.eclass on line: %d"
+
+_constant_checks = tuple((c() for c in (Autotools,
+       EbuildWhitespace, EbuildQuote,
+       EbuildAssignment, EbuildUselessDodoc,
+       EbuildUselessCdS, EbuildNestedDie)))
+
 def run_checks(contents, st_mtime):
-       checks = []
-       for c in (EbuildWhitespace, EbuildQuote, EbuildAssignment,
-                       EbuildUselessDodoc, EbuildUselessCdS, EbuildNestedDie):
-               checks.append(c())
+       checks = list(_constant_checks)
        checks.append(EbuildHeader(st_mtime))
        for num, line in enumerate(contents):
                for lc in checks: