aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Dolbec <dolsen@gentoo.org>2017-07-15 01:04:00 +0000
committerZac Medico <zmedico@gentoo.org>2018-03-29 20:51:18 -0700
commit3ea468dde4de8ec14c9da1dd6d522a31cc443851 (patch)
tree6e5defeb23e72eb8a907c27829a788a291e891c3
parentrepoman: New linechecks module, phases (diff)
downloadportage-3ea468dde4de8ec14c9da1dd6d522a31cc443851.tar.gz
portage-3ea468dde4de8ec14c9da1dd6d522a31cc443851.tar.bz2
portage-3ea468dde4de8ec14c9da1dd6d522a31cc443851.zip
repoman: New linechecks module, portage
-rw-r--r--repoman/pym/repoman/modules/linechecks/portage/__init__.py27
-rw-r--r--repoman/pym/repoman/modules/linechecks/portage/internal.py37
2 files changed, 64 insertions, 0 deletions
diff --git a/repoman/pym/repoman/modules/linechecks/portage/__init__.py b/repoman/pym/repoman/modules/linechecks/portage/__init__.py
new file mode 100644
index 000000000..d390c6054
--- /dev/null
+++ b/repoman/pym/repoman/modules/linechecks/portage/__init__.py
@@ -0,0 +1,27 @@
+# Copyright 2015-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+doc = """Portage plug-in module for repoman LineChecks.
+Performs checks for internal portage variable usage in ebuilds."""
+__doc__ = doc[:]
+
+
+module_spec = {
+ 'name': 'do',
+ 'description': doc,
+ 'provides':{
+ 'internal-check': {
+ 'name': "portageinternal",
+ 'sourcefile': "internal",
+ 'class': "PortageInternal",
+ 'description': doc,
+ },
+ 'portageinternalvariableassignment-check': {
+ 'name': "portageinternalvariableassignment",
+ 'sourcefile': "internal",
+ 'class': "PortageInternalVariableAssignment",
+ 'description': doc,
+ },
+ }
+}
+
diff --git a/repoman/pym/repoman/modules/linechecks/portage/internal.py b/repoman/pym/repoman/modules/linechecks/portage/internal.py
new file mode 100644
index 000000000..869337221
--- /dev/null
+++ b/repoman/pym/repoman/modules/linechecks/portage/internal.py
@@ -0,0 +1,37 @@
+
+import re
+
+from repoman.modules.linechecks.base import LineCheck
+
+
+class PortageInternal(LineCheck):
+ repoman_check_name = 'portage.internal'
+ ignore_comment = True
+ # Match when the command is preceded only by leading whitespace or a shell
+ # operator such as (, {, |, ||, or &&. This prevents false positives in
+ # things like elog messages, as reported in bug #413285.
+
+ internal_portage_func_or_var = (
+ 'ecompress|ecompressdir|env-update|prepall|prepalldocs|preplib')
+ re = re.compile(
+ r'^(\s*|.*[|&{(]+\s*)\b(%s)\b' % internal_portage_func_or_var)
+
+ 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 ("'%s'" % m.group(2)) + " called on line: %d"
+
+
+class PortageInternalVariableAssignment(LineCheck):
+ repoman_check_name = 'portage.internal'
+ internal_assignment = re.compile(
+ r'\s*(export\s+)?(EXTRA_ECONF|EXTRA_EMAKE)\+?=')
+
+ def check(self, num, line):
+ match = self.internal_assignment.match(line)
+ e = None
+ if match is not None:
+ e = 'Assignment to variable %s' % match.group(2)
+ e += ' on line: %d'
+ return e