summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-11-14 21:57:14 +0000
committerZac Medico <zmedico@gentoo.org>2008-11-14 21:57:14 +0000
commit420a428b6e59afd5e5743c8ac9b19a281410e9f1 (patch)
treefc4da66ceb993f43d28d52216c579e02e348f7c5
parentfc99e6d10c0d359de1d28d1ff414b8c2a0f6a969 (diff)
downloadportage-420a428b6e59afd5e5743c8ac9b19a281410e9f1.tar.gz
portage-420a428b6e59afd5e5743c8ac9b19a281410e9f1.tar.bz2
portage-420a428b6e59afd5e5743c8ac9b19a281410e9f1.zip
Make the EbuildQuote check filter out matches that appear to be an argument
to a message command. For example: false || ewarn "foo $WORKDIR/bar baz" Thanks to Diego 'Flameeyes' Pettenò <flameeyes@g.o> for reporting this issue (currently triggered by ruby-prof-0.7.0.ebuild). svn path=/main/trunk/; revision=11913
-rw-r--r--pym/repoman/checks.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py
index dd81d8716..c9415b759 100644
--- a/pym/repoman/checks.py
+++ b/pym/repoman/checks.py
@@ -83,8 +83,11 @@ class EbuildQuote(LineCheck):
"""Ensure ebuilds have valid quoting around things like D,FILESDIR, etc..."""
repoman_check_name = 'ebuild.minorsyn'
- _ignored_commands = ["echo", "local", "export"]
- _ignored_commands += ["eerror", "einfo", "elog", "eqawarn", "ewarn"]
+ _message_commands = ["die", "echo", "eerror",
+ "einfo", "elog", "eqawarn", "ewarn"]
+ _message_re = re.compile(r'\s(' + "|".join(_message_commands) + \
+ r')\s+"[^"]*"\s*$')
+ _ignored_commands = ["local", "export"] + _message_commands
ignore_line = re.compile(r'(^$)|(^\s*#.*)|(^\s*\w+=.*)' + \
r'|(^\s*(' + "|".join(_ignored_commands) + r')\s+)')
var_names = ["D", "DISTDIR", "FILESDIR", "S", "T", "ROOT", "WORKDIR"]
@@ -125,6 +128,15 @@ class EbuildQuote(LineCheck):
if self.var_reference.search(group) is None:
continue
+ # Filter matches that appear to be an
+ # argument to a message command.
+ # For example: false || ewarn "foo $WORKDIR/bar baz"
+ message_match = self._message_re.search(line)
+ if message_match is not None and \
+ message_match.start() < pos and \
+ message_match.end() > pos:
+ break
+
# This is an attempt to avoid false positives without getting
# too complex, while possibly allowing some (hopefully
# unlikely) violations to slip through. We just assume