From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id B53AE139694 for ; Sat, 15 Jul 2017 02:29:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 383741FC089; Sat, 15 Jul 2017 02:29:36 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 06F971FC089 for ; Sat, 15 Jul 2017 02:29:36 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C96BB3418E3 for ; Sat, 15 Jul 2017 02:29:34 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5CE5774C4 for ; Sat, 15 Jul 2017 02:29:31 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1500085545.0c847b8470903b896bc4bb06ae8184987b1f6719.dolsen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/portage/ X-VCS-Repository: proj/portage X-VCS-Files: repoman/pym/repoman/modules/linechecks/portage/__init__.py repoman/pym/repoman/modules/linechecks/portage/internal.py X-VCS-Directories: repoman/pym/repoman/modules/linechecks/portage/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 0c847b8470903b896bc4bb06ae8184987b1f6719 X-VCS-Branch: repoman Date: Sat, 15 Jul 2017 02:29:31 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: eb590f2c-b96a-4b93-a68d-504b1ce551cf X-Archives-Hash: 4c417e9af9889c1510d3f21f5f67d309 commit: 0c847b8470903b896bc4bb06ae8184987b1f6719 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:04:00 2017 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Sat Jul 15 02:25:45 2017 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=0c847b84 repoman: New linechecks module, portage .../repoman/modules/linechecks/portage/__init__.py | 27 ++++++++++++++++ .../repoman/modules/linechecks/portage/internal.py | 37 ++++++++++++++++++++++ 2 files changed, 64 insertions(+) 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