[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/gentoo_header/
commit: df1266a0fb757057658e5bea56a003ca0e5d5d7f Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:01:04 2017 + Commit: Zac Medico gentoo org> CommitDate: Fri Mar 30 03:51:17 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=df1266a0 repoman: New linechecks module, gentoo_header .../modules/linechecks/gentoo_header/__init__.py | 21 ++ .../modules/linechecks/gentoo_header/header.py | 49 ++ 2 files changed, 70 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py b/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py new file mode 100644 index 0..b80a83ecf --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Gentoo-header plug-in module for repoman LineChecks. +Performs header checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'header-check': { + 'name': "gentooheader", + 'sourcefile': "header", + 'class': "EbuildHeader", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py b/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py new file mode 100644 index 0..4b75fc4b5 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py @@ -0,0 +1,49 @@ + +import re +import time + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildHeader(LineCheck): + """Ensure ebuilds have proper headers + Copyright header errors + CVS header errors + License header errors + + Args: + modification_year - Year the ebuild was last modified + """ + + repoman_check_name = 'ebuild.badheader' + + gentoo_copyright = r'^# Copyright ((1999|2\d\d\d)-)?%s Gentoo Foundation$' + gentoo_license = ( + '# Distributed under the terms' + ' of the GNU General Public License v2') + id_header_re = re.compile(r'.*\$(Id|Header)(:.*)?\$.*') + blank_line_re = re.compile(r'^$') + ignore_comment = False + + def new(self, pkg): + if pkg.mtime is None: + self.modification_year = r'2\d\d\d' + else: + self.modification_year = str(time.gmtime(pkg.mtime)[0]) + self.gentoo_copyright_re = re.compile( + self.gentoo_copyright % self.modification_year) + + def check(self, num, line): + if num > 2: + return + elif num == 0: + if not self.gentoo_copyright_re.match(line): + return self.errors['COPYRIGHT_ERROR'] + elif num == 1 and line.rstrip('\n') != self.gentoo_license: + return self.errors['LICENSE_ERROR'] + elif num == 2 and self.id_header_re.match(line): + return self.errors['ID_HEADER_ERROR'] + elif num == 2 and not self.blank_line_re.match(line): + return self.errors['NO_BLANK_LINE_ERROR'] + +
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/emake/
commit: ac1df05ac0d49c3c98518d77a892d2c18ad38195 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:00:30 2017 + Commit: Zac Medico gentoo org> CommitDate: Fri Mar 30 03:51:17 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=ac1df05a repoman: New linechecks module, emake .../repoman/modules/linechecks/emake/__init__.py | 27 ++ .../pym/repoman/modules/linechecks/emake/emake.py | 23 ++ 2 files changed, 50 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/emake/__init__.py b/repoman/pym/repoman/modules/linechecks/emake/__init__.py new file mode 100644 index 0..2e930dae8 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/emake/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Emake plug-in module for repoman LineChecks. +Performs emake checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'paralleldisabled-check': { + 'name': "paralleldisabled", + 'sourcefile': "emake", + 'class': "EMakeParallelDisabledViaMAKEOPTS", + 'description': doc, + }, + 'autodefault-check': { + 'name': "autodefault", + 'sourcefile': "emake", + 'class': "WantAutoDefaultValue", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/emake/emake.py b/repoman/pym/repoman/modules/linechecks/emake/emake.py new file mode 100644 index 0..e1e3e638e --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/emake/emake.py @@ -0,0 +1,23 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EMakeParallelDisabledViaMAKEOPTS(LineCheck): + """Check for MAKEOPTS=-j1 that disables parallelization.""" + repoman_check_name = 'upstream.workaround' + re = re.compile(r'^\s*MAKEOPTS=(\'|")?.*-j\s*1\b') + error = 'EMAKE_PARALLEL_DISABLED_VIA_MAKEOPTS' + + +class WantAutoDefaultValue(LineCheck): + """Check setting WANT_AUTO* to latest (default value).""" + repoman_check_name = 'ebuild.minorsyn' + _re = re.compile(r'^WANT_AUTO(CONF|MAKE)=(\'|")?latest') + + def check(self, num, line): + m = self._re.match(line) + if m is not None: + return 'WANT_AUTO' + m.group(1) + \ + ' redundantly set to default value "latest" on line: %d'
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/whitespace/
commit: c52890d4cac9bb8423a27d938b3604b79e3b0f4c Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:07:13 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:46 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=c52890d4 repoman: New linechecks module, whitespace .../modules/linechecks/whitespace/__init__.py | 27 ++ .../repoman/modules/linechecks/whitespace/blank.py | 25 .../modules/linechecks/whitespace/whitespace.py| 21 + 3 files changed, 73 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/whitespace/__init__.py b/repoman/pym/repoman/modules/linechecks/whitespace/__init__.py new file mode 100644 index 0..ded690ed7 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/whitespace/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Whitespace plug-in module for repoman LineChecks. +Performs checks for useless whitespace in ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'whitespace-check': { + 'name': "whitespace", + 'sourcefile': "whitespace", + 'class': "EbuildWhitespace", + 'description': doc, + }, + 'blankline-check': { + 'name': "blankline", + 'sourcefile': "blank", + 'class': "EbuildBlankLine", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/whitespace/blank.py b/repoman/pym/repoman/modules/linechecks/whitespace/blank.py new file mode 100644 index 0..2ab4097a3 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/whitespace/blank.py @@ -0,0 +1,25 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildBlankLine(LineCheck): + repoman_check_name = 'ebuild.minorsyn' + ignore_comment = False + blank_line = re.compile(r'^$') + + def new(self, pkg): + self.line_is_blank = False + + def check(self, num, line): + if self.line_is_blank and self.blank_line.match(line): + return 'Useless blank line on line: %d' + if self.blank_line.match(line): + self.line_is_blank = True + else: + self.line_is_blank = False + + def end(self): + if self.line_is_blank: + yield 'Useless blank line on last line' diff --git a/repoman/pym/repoman/modules/linechecks/whitespace/whitespace.py b/repoman/pym/repoman/modules/linechecks/whitespace/whitespace.py new file mode 100644 index 0..556b2ab81 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/whitespace/whitespace.py @@ -0,0 +1,21 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildWhitespace(LineCheck): + """Ensure ebuilds have proper whitespacing""" + + repoman_check_name = 'ebuild.minorsyn' + + ignore_line = re.compile(r'(^$)|(^(\t)*#)') + ignore_comment = False + leading_spaces = re.compile(r'^[\S\t]') + trailing_whitespace = re.compile(r'.*([\S]$)') + + def check(self, num, line): + if self.leading_spaces.match(line) is None: + return self.errors['LEADING_SPACES_ERROR'] + if self.trailing_whitespace.match(line) is None: + return self.errors['TRAILING_WHITESPACE_ERROR']
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/scan/ebuild/
commit: e2e41bbd71c024ab34a87d5f6d9edea2e43fc713 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:10:13 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:46 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=e2e41bbd repoman: Remove the no longer used modules/scan/ebuild/checks.py repoman/pym/repoman/modules/scan/ebuild/checks.py | 1044 - 1 file changed, 1044 deletions(-) diff --git a/repoman/pym/repoman/modules/scan/ebuild/checks.py b/repoman/pym/repoman/modules/scan/ebuild/checks.py deleted file mode 100644 index de03bedd2..0 --- a/repoman/pym/repoman/modules/scan/ebuild/checks.py +++ /dev/null @@ -1,1044 +0,0 @@ -# -*- coding:utf-8 -*- -# repoman: Checks -# Copyright 2007-2017 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -"""This module contains functions used in Repoman to ascertain the quality -and correctness of an ebuild.""" - -from __future__ import unicode_literals - -from itertools import chain -import operator -import re -import time - -# import our initialized portage instance -from repoman._portage import portage - -from portage.eapi import ( - eapi_supports_prefix, eapi_has_implicit_rdepend, - eapi_has_src_prepare_and_src_configure, eapi_has_dosed_dohard, - eapi_exports_AA, eapi_has_pkg_pretend) - -from . import errors - - -class LineCheck(object): - """Run a check on a line of an ebuild.""" - """A regular expression to determine whether to ignore the line""" - ignore_line = False - """True if lines containing nothing more than comments with optional - leading whitespace should be ignored""" - ignore_comment = True - - def new(self, pkg): - pass - - def check_eapi(self, eapi): - """Returns if check should be run in the given EAPI (default: True)""" - return True - - 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 PhaseCheck(LineCheck): - """ basic class for function detection """ - - func_end_re = re.compile(r'^\}$') - phases_re = re.compile('(%s)' % '|'.join(( - 'pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare', - 'src_configure', 'src_compile', 'src_test', 'src_install', - 'pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm', - 'pkg_config'))) - in_phase = '' - - def check(self, num, line): - m = self.phases_re.match(line) - if m is not None: - self.in_phase = m.group(1) - if self.in_phase != '' and self.func_end_re.match(line) is not None: - self.in_phase = '' - - return self.phase_check(num, line) - - def phase_check(self, num, line): - """ override this function for your checks """ - pass - - -class EbuildHeader(LineCheck): - """Ensure ebuilds have proper headers - Copyright header errors - CVS header errors - License header errors - - Args: - modification_year - Year the ebuild was last modified - """ - - repoman_check_name = 'ebuild.badheader' - - gentoo_copyright = r'^# Copyright ((1999|2\d\d\d)-)?%s Gentoo Foundation$' - gentoo_license = ( - '# Distributed under the terms' - ' of the GNU General Public License v2') - id_header_re = re.compile(r'.*\$(Id|Header)(:.*)?\$.*') - blank_line_re = re.compile(r'^$') - ignore_comment = False - - def new(self, pkg): - if pkg.mtime is None: - self.modification_year = r'2\d\d\d' - else: - self.modification_year = str(time.gmtime(pkg.mtime)[0]) - self.gentoo_copyright_re = re.compile( - self.gentoo_copyright % self.modification_year) - - def check(self, num, line): - if num > 2: - return - elif num == 0: - if not self.gentoo_copyright_re.match(line): - return errors.COPYRIGHT_ERROR - elif num == 1 and line.rstrip('\n') != self.gentoo_license: - return errors.LICENSE_ERROR - elif num == 2 and self.id_header_re.match(line): - return errors.ID_HEADER_ERROR - elif num == 2 and not self.blank_line_re.match(line): - return errors.NO_BLANK_LINE_ERROR - - -class EbuildWhitespace(LineCheck): - """Ensure ebuilds have proper whitespacing""" - - repoman_check_name = 'ebuild.minorsyn' - - ignore_line
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/scan/metadata/, ...
commit: 287bab160e807b595fd12a606956644d7501ca48 Author: Brian Dolbec gentoo org> AuthorDate: Wed Aug 16 23:24:24 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:46 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=287bab16 repoman: Initial adding file/module/API version repoman/pym/repoman/config.py| 7 +-- repoman/pym/repoman/main.py | 3 +++ repoman/pym/repoman/modules/linechecks/assignment/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/config.py | 2 +- repoman/pym/repoman/modules/linechecks/depend/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/deprecated/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/do/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/eapi/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/emake/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/helpers/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/nested/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/patches/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/phases/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/portage/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/quotes/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/uri/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/use/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/useless/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/whitespace/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/workaround/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/depend/__init__.py | 3 ++- repoman/pym/repoman/modules/scan/directories/__init__.py | 3 ++- repoman/pym/repoman/modules/scan/eapi/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/ebuild/__init__.py | 3 ++- repoman/pym/repoman/modules/scan/eclasses/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/fetch/__init__.py | 3 ++- repoman/pym/repoman/modules/scan/keywords/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/manifest/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/metadata/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/module.py | 9 ++--- repoman/pym/repoman/modules/scan/options/__init__.py | 3 ++- repoman/pym/repoman/qa_data.py | 4 ++-- repoman/pym/repoman/repos.py | 2 +- repoman/pym/repoman/scanner.py | 3 ++- 35 files changed, 76 insertions(+), 38 deletions(-) diff --git a/repoman/pym/repoman/config.py b/repoman/pym/repoman/config.py index 9da30ed9e..0f2358cd9 100644 --- a/repoman/pym/repoman/config.py +++ b/repoman/pym/repoman/config.py @@ -144,8 +144,11 @@ def load_config(conf_dirs, file_extensions=None, valid_versions=None): if config: if config['version'] not in valid_versions: - raise ConfigError("Invalid file version: %s in: %s\nPlease upgrade repoman: current valid versions: %s" - % (config['version'], filename, valid_versions)) + raise ConfigError( + "Invalid file version: %s in: %s\nPlease upgrade to " + ">=app-portage/repoman-%s, current valid API versions: %s" + % (config['version'], filename, + config['repoman_version'], valid_versions)) result = merge_config(result, config) return result diff --git a/repoman/pym/repoman/main.py b/repoman/pym/repoman/main.py index c1e3b99fe..81e2ff61e 100755 --- a/repoman/pym/repoman/main.py +++ b/repoman/pym/repoman/main.py @@ -47,10 +47,12 @@ os.umask(0o22) LOGLEVEL = logging.WARNING portage.util.initialize_logger(LOGLEVEL) +VALID_VERSIONS = [1,] def repoman_main(argv): config_root = os.environ.get("PORTAGE_CONFIGROOT") repoman_settings = portage.config(config_root=config_root, local_config=False) + repoman_settings.valid_versions = VALID_VERSIONS if repoman_settings.get("NOCOLOR", "").lower() in ("yes", "true") or \ repoman_settings.get('TERM') == 'dumb' or \ @@ -92,6 +94,7 @@ def repoman_main(argv): config_root, portdir, portdir_overlay, repoman_settings, vcs_settings, options, qadata) repoman_settings = repo_settings.repoman_settings +
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/tests/
commit: e893506796c5bd4bd4a8f0543a23be955bfb4136 Author: El Acheche Anis ubuntu com> AuthorDate: Mon Jul 24 04:49:26 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:47 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=e8935067 repoman: repoman/pym/repoman/tests/runTests.py: Fix PEP8 E261 repoman/pym/repoman/tests/runTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repoman/pym/repoman/tests/runTests.py b/repoman/pym/repoman/tests/runTests.py index 1795aa487..ca37b14b3 100644 --- a/repoman/pym/repoman/tests/runTests.py +++ b/repoman/pym/repoman/tests/runTests.py @@ -17,7 +17,7 @@ def debug_signal(signum, frame): pdb.set_trace() if platform.python_implementation() == 'Jython': - debug_signum = signal.SIGUSR2 # bug #424259 + debug_signum = signal.SIGUSR2 # bug #424259 else: debug_signum = signal.SIGUSR1
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/scan/
commit: d94b56361df9b6ccf27fd325cc50de9a35fac8e8 Author: Brian Dolbec gentoo org> AuthorDate: Tue Dec 5 19:29:26 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:47 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d94b5636 repoman scan/module.py: fix typo repoman/pym/repoman/modules/scan/module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repoman/pym/repoman/modules/scan/module.py b/repoman/pym/repoman/modules/scan/module.py index fc0c66ccb..cebc0e708 100644 --- a/repoman/pym/repoman/modules/scan/module.py +++ b/repoman/pym/repoman/modules/scan/module.py @@ -85,7 +85,7 @@ class ModuleConfig(object): if loop in self.controller.get_spec(mod, 'module_runsIn'): mlist.append(mod) except InvalidModuleName: - logging.error("ModuleConfig; unkown module: %s, skipping", mod) + logging.error("ModuleConfig; unknown module: %s, skipping", mod) logging.debug("ModuleConfig; mlist: %s", mlist) return mlist
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/tests/
commit: e91ace3e0bc52a9d5f587460ad053e93a8dbffdd Author: El Acheche Anis ubuntu com> AuthorDate: Mon Jul 24 04:47:42 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:47 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=e91ace3e repoman: repoman/pym/repoman/tests/runTests.py: Fix PEP8 E302 repoman/pym/repoman/tests/runTests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/repoman/pym/repoman/tests/runTests.py b/repoman/pym/repoman/tests/runTests.py index 3125ff058..1795aa487 100644 --- a/repoman/pym/repoman/tests/runTests.py +++ b/repoman/pym/repoman/tests/runTests.py @@ -11,6 +11,7 @@ import platform import pwd import signal + def debug_signal(signum, frame): import pdb pdb.set_trace()
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/tests/
commit: ab00fed95fdffeceb8968fa733284910b59220f3 Author: El Acheche Anis ubuntu com> AuthorDate: Mon Jul 24 04:46:28 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:46 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=ab00fed9 repoman: repoman/pym/repoman/tests/runTests.py: Fix PEP8 E401 repoman/pym/repoman/tests/runTests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/repoman/pym/repoman/tests/runTests.py b/repoman/pym/repoman/tests/runTests.py index 759abdd82..3125ff058 100644 --- a/repoman/pym/repoman/tests/runTests.py +++ b/repoman/pym/repoman/tests/runTests.py @@ -3,7 +3,8 @@ # Copyright 2006-2017 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -import os, sys +import os +import sys import os.path as osp import grp import platform
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/, repoman/cnf/linechecks/
commit: 96c4c7ea02f5b908b09336365c04aa206d69a13b Author: Brian Dolbec gentoo org> AuthorDate: Tue Dec 5 18:17:15 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:47 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=96c4c7ea repoman linechecks/config.py: Move the errors loading to a new /usr/share/repoman/linechecks directory This new directory can be installed to by third party add on modules that extend the checks. We can also in future use these file to get loaclized translations. repoman/cnf/linechecks/linechecks.yaml | 35 repoman/pym/repoman/modules/linechecks/config.py | 19 +++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/repoman/cnf/linechecks/linechecks.yaml b/repoman/cnf/linechecks/linechecks.yaml new file mode 100644 index 0..634381e80 --- /dev/null +++ b/repoman/cnf/linechecks/linechecks.yaml @@ -0,0 +1,35 @@ +--- +# linecheck_help.yaml + +# Repoman API version (do not edit) +version: 1 +# minimum +repoman_version: 2.3.3 + +# configuration file for the LineCheck plugins run via the multicheck +# scan module +errors: +COPYRIGHT_ERROR: 'Invalid Gentoo Copyright on line: %d' +LICENSE_ERROR: 'Invalid Gentoo/GPL License on line: %d' +ID_HEADER_ERROR: 'Stale CVS header on line: %d' +NO_BLANK_LINE_ERROR: 'Non-blank line after header on line: %d' +LEADING_SPACES_ERROR: 'Ebuild contains leading spaces on line: %d' +TRAILING_WHITESPACE_ERROR: 'Trailing whitespace error on line: %d' +READONLY_ASSIGNMENT_ERROR: 'Ebuild contains assignment to read-only variable on line: %d' +MISSING_QUOTES_ERROR: 'Unquoted Variable on line: %d' +NESTED_DIE_ERROR: 'Ebuild calls die in a subshell on line: %d' +PATCHES_ERROR: 'PATCHES is not a bash array on line: %d' +REDUNDANT_CD_S_ERROR: 'Ebuild has redundant cd ${S} statement on line: %d' +EMAKE_PARALLEL_DISABLED: 'Upstream parallel compilation bug (ebuild calls emake -j1 on line: %d)' +EMAKE_PARALLEL_DISABLED_VIA_MAKEOPTS: 'Upstream parallel compilation bug (MAKEOPTS=-j1 on line: %d)' +DEPRECATED_BINDNOW_FLAGS: 'Deprecated bindnow-flags call on line: %d' +EAPI_DEFINED_AFTER_INHERIT: 'EAPI defined after inherit on line: %d' +NO_AS_NEEDED: 'Upstream asneeded linking bug (no-as-needed on line: %d)' +PRESERVE_OLD_LIB: 'Ebuild calls deprecated preserve_old_lib on line: %d' +BUILT_WITH_USE: 'built_with_use on line: %d' +NO_OFFSET_WITH_HELPERS: 'Helper function is used with D, ROOT, ED, EROOT or EPREFIX on line: %d' +SANDBOX_ADDPREDICT: 'Ebuild calls addpredict on line: %d' +USEQ_ERROR: 'Ebuild calls deprecated useq function on line: %d' +HASQ_ERROR: 'Ebuild calls deprecated hasq function on line: %d' +URI_HTTPS: 'Ebuild uses http:// but should use https:// on line: %d' + diff --git a/repoman/pym/repoman/modules/linechecks/config.py b/repoman/pym/repoman/modules/linechecks/config.py index 9190b18cf..96a27ac49 100644 --- a/repoman/pym/repoman/modules/linechecks/config.py +++ b/repoman/pym/repoman/modules/linechecks/config.py @@ -15,6 +15,7 @@ from copy import deepcopy from repoman._portage import portage from repoman.config import load_config +from repoman import _not_installed # Avoid a circular import issue in py2.7 portage.proxy.lazyimport.lazyimport(globals(), @@ -46,8 +47,7 @@ class LineChecksConfig(object): @param configpaths: ordered list of filepaths to load ''' self.repo_settings = repo_settings - self.infopaths = [os.path.join(path, 'linechecks.yaml') for path in self.repo_settings.masters_list] - logging.debug("LineChecksConfig; configpaths: %s", self.infopaths) + self.infopaths = None self.info_config = None self._config = None self.usex_supported_eapis = None @@ -58,8 +58,22 @@ class LineChecksConfig(object): self.eclass_info = {} self.eclass_info_experimental_inherit = {} self.errors = {} + self.set_infopaths() self.load_checks_info() + def set_infopaths(self): + if _not_installed: + cnfdir = os.path.realpath(os.path.join(os.path.dirname( + os.path.dirname(os.path.dirname(os.path.dirname( + os.path.dirname(__file__), 'cnf/linechecks')) + else: + cnfdir = os.path.join(portage.const.EPREFIX or '/', 'usr/share/repoman/linechecks') + repomanpaths = [os.path.join(cnfdir, _file_) for _file_ in os.listdir(cnfdir)] + logging.debug("LineChecksConfig; repomanpaths: %s", repomanpaths) + repopaths = [os.path.join(path, 'linechecks.yaml') for path in self.repo_settings.masters_list] + self.infopaths = repomanpaths +
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/tests/
commit: 09196ccf2d79f9eef2ce8618d74bc53e124eb21d Author: El Acheche Anis ubuntu com> AuthorDate: Mon Jul 24 04:50:07 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:47 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=09196ccf repoman: repoman/pym/repoman/tests/runTests.py: Fix PEP8 E226 repoman/pym/repoman/tests/runTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repoman/pym/repoman/tests/runTests.py b/repoman/pym/repoman/tests/runTests.py index ca37b14b3..b0e715ec6 100644 --- a/repoman/pym/repoman/tests/runTests.py +++ b/repoman/pym/repoman/tests/runTests.py @@ -35,7 +35,7 @@ repoman_pym = osp.dirname(osp.dirname(osp.dirname(osp.realpath(__file__ sys.path.insert(0, repoman_pym) # Add in the parent portage python modules -portage_pym = osp.dirname(osp.dirname(repoman_pym))+'/pym' +portage_pym = osp.dirname(osp.dirname(repoman_pym)) + '/pym' sys.path.insert(0, portage_pym) # import our centrally initialized portage instance
[gentoo-commits] proj/portage:repoman commit in: /
commit: 95a1a0d7ca46594c3cb4f7ab578ad5b984fe3243 Author: El Acheche Anis ubuntu com> AuthorDate: Wed Jul 26 22:20:56 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:47 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=95a1a0d7 repoman: .travis.yml: pyyaml python module is needed for builds .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index ebcfbeab9..94ed2dcb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,8 @@ install: - "[[ ${TRAVIS_PYTHON_VERSION} == 3.[6789] ]] || pip install pyblake2" # always install pygost for Streebog - pip install pygost +# pyyaml is needed for building +- pip install pyyaml script: - printf "[build_ext]\nportage-ext-modules=true" >> setup.cfg
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/portage/
commit: ee1a1b4621b2a276d228014a57d4a25ca90575b0 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:04:00 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:45 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=ee1a1b46 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 0..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 0..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
[gentoo-commits] proj/portage:repoman commit in: pym/portage/
commit: 4333abb4c54ba81b1622c3cd951ae8aacf8e4560 Author: Brian Dolbec gentoo org> AuthorDate: Thu Aug 17 01:50:21 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:46 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=4333abb4 module.py: Extend the module loader for API version checking If provided with an iterable of compatibility versions, The controller will check the plugin modules module_spec 'version' variable is compatible with the base application. pym/portage/module.py | 22 -- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pym/portage/module.py b/pym/portage/module.py index c79e65518..bd7c94d4e 100644 --- a/pym/portage/module.py +++ b/pym/portage/module.py @@ -15,6 +15,10 @@ class InvalidModuleName(PortageException): """An invalid or unknown module name.""" +class ModuleVersionError(PortageException): + '''An incompatible module version''' + + class Module(object): """Class to define and hold our plug-in module @@ -87,16 +91,17 @@ class Modules(object): @param namepath: Python import path to the "modules" directory """ - def __init__(self, path, namepath): + def __init__(self, path, namepath, compat_versions=None): self._module_path = path self._namepath = namepath + self.compat_versions = compat_versions self.parents = [] self._modules = self._get_all_modules() self.modules = ProtectedDict(self._modules) self.module_names = sorted(self._modules) def _get_all_modules(self): - """scans the emaint modules dir for loadable modules + """scans the _module_path dir for loadable modules @rtype: dictionary of module_plugins """ @@ -117,6 +122,7 @@ class Modules(object): kids = {} for entry in importables: new_module = Module(entry, self._namepath) + self._check_compat(new_module) for module_name in new_module.kids: kid = new_module.kids[module_name] kid['parent'] = new_module @@ -211,6 +217,8 @@ class Modules(object): @type modname: string @param modname: the module class name + @type var: string + @param var: the base level variable to return @type dictionary @return: the modules class exported options descriptions """ @@ -220,3 +228,13 @@ class Modules(object): raise InvalidModuleName( "Module name '%s' is invalid or not found" % modname) return value + + def _check_compat(self, module): + if self.compat_versions: + if not module.module_spec['version'] in self.compat_versions: + raise ModuleVersionError( + "Error loading '%s' plugin module: %s, version: %s\n" + "Module is not compatible with the current application version\n" + "Compatible module API versions are: %s" + % (self._namepath, module.module_spec['name'], + module.module_spec['version'], self.compat_versions))
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/, repoman/cnf/qa_data/
commit: 1a251341eb244cb84028f9e3892cefb283c04f36 Author: Brian Dolbec gentoo org> AuthorDate: Tue Dec 5 18:16:44 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:47 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=1a251341 repoman qa_data.py: Move the qahelp loading to a new /usr/share/repoman/qa_data directory This new directory can be installed to by third party add on modules that extend the checks. We can also in future use these file to get loaclized translations. repoman/cnf/qa_data/qa_data.yaml | 139 +++ repoman/pym/repoman/qa_data.py | 19 +- 2 files changed, 155 insertions(+), 3 deletions(-) diff --git a/repoman/cnf/qa_data/qa_data.yaml b/repoman/cnf/qa_data/qa_data.yaml new file mode 100644 index 0..c9fa2c024 --- /dev/null +++ b/repoman/cnf/qa_data/qa_data.yaml @@ -0,0 +1,139 @@ +--- +# qa_help.yaml + +# configuration file for the LineCheck plugins run via the multicheck +# scan module + +# Repoman API version (do not edit) +version: 1 +# minimum +repoman_version: 2.3.3 + +# qahelp: Primary QA help messages to describe the errors or warnings +# Dictionary +qahelp: +Entries: +IO_error: "Attempting to commit, and an IO error was encountered access the Entries file" +changelog: +ebuildadded: "An ebuild was added but the ChangeLog was not modified" +missing: "Missing ChangeLog files" +notadded: "ChangeLogs that exist but have not been added to cvs" +dependency: +bad: "User-visible ebuilds with unsatisfied dependencies (matched against *visible* ebuilds)" +badmasked: "Masked ebuilds with unsatisfied dependencies (matched against *all* ebuilds)" +badindev: "User-visible ebuilds with unsatisfied dependencies (matched against *visible* ebuilds) in developing arch" +badmaskedindev: "Masked ebuilds with unsatisfied dependencies (matched against *all* ebuilds) in developing arch" +badinexp: "User-visible ebuilds with unsatisfied dependencies (matched against *visible* ebuilds) in experimental arch" +badmaskedinexp: "Masked ebuilds with unsatisfied dependencies (matched against *all* ebuilds) in experimental arch" +badtilde: "Uses the ~ dep operator with a non-zero revision part, which is useless (the revision is ignored)" +missingslot: "RDEPEND matches more than one SLOT but does not specify a slot and/or use the := or :* slot operator" +perlcore: "This ebuild directly depends on a package in perl-core; it should use the corresponding virtual instead." +syntax: "Syntax error in dependency string (usually an extra/missing space/parenthesis)" +unknown: "Ebuild has a dependency that refers to an unknown package (which may be valid if it is a blocker for a renamed/removed package, or is an alternative choice provided by an overlay)" +badslotop: "RDEPEND contains ':=' slot operator under '||' dependency." +DESCRIPTION: +missing: "Ebuilds that have a missing or empty DESCRIPTION variable" +toolong: "DESCRIPTION is over %d characters" +digest: +assumed: "Existing digest must be assumed correct (Package level only)" +missing: "Some files listed in SRC_URI aren't referenced in the Manifest" +unused: "Some files listed in the Manifest aren't referenced in SRC_URI" +EAPI: +definition: "EAPI definition does not conform to PMS section 7.3.1 (first non-comment, non-blank line)" +deprecated: "Ebuilds that use features that are deprecated in the current EAPI" +incompatible: "Ebuilds that use features that are only available with a different EAPI" +unsupported: "Ebuilds that have an unsupported EAPI version (you must upgrade portage)" +ebuild: +absdosym: "This ebuild uses absolute target to dosym where relative symlink could be used instead" +badheader: "This ebuild has a malformed header" +invalidname: "Ebuild files with a non-parseable or syntactically incorrect name (or using 2.1 versioning extensions)" +majorsyn: "This ebuild has a major syntax error that may cause the ebuild to fail partially or fully" +minorsyn: "This ebuild has a minor syntax error that contravenes gentoo coding style" +namenomatch: "Ebuild files that do not have the same name as their parent directory" +notadded: "Ebuilds that exist but have not been added to the vcs" +nesteddie: "Placing 'die' inside ( ) prints an error, but doesn't stop the ebuild." +output: "A simple sourcing of the ebuild produces output; this breaks ebuild policy." +patches: "PATCHES variable should be a bash array to ensure white space safety" +syntax: "Error generating cache entry for ebuild; typically caused by ebuild syntax error or digest verification failure" +file: +executable: "Ebuilds,
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/patches/
commit: e9543034a931728ca96f0228213fa42844f4e0e7 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:02:58 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:45 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=e9543034 repoman: New linechecks module, patches .../repoman/modules/linechecks/patches/__init__.py | 21 + .../repoman/modules/linechecks/patches/patches.py | 16 2 files changed, 37 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/patches/__init__.py b/repoman/pym/repoman/modules/linechecks/patches/__init__.py new file mode 100644 index 0..67434f911 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/patches/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Patches plug-in module for repoman LineChecks. +Performs PATCHES variable checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'patches-check': { + 'name': "patches", + 'sourcefile': "patches", + 'class': "EbuildPatches", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/patches/patches.py b/repoman/pym/repoman/modules/linechecks/patches/patches.py new file mode 100644 index 0..63651cd7c --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/patches/patches.py @@ -0,0 +1,16 @@ + + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildPatches(LineCheck): + """Ensure ebuilds use bash arrays for PATCHES to ensure white space safety""" + repoman_check_name = 'ebuild.patches' + re = re.compile(r'^\s*PATCHES=[^\(]') + error = 'PATCHES_ERROR' + + def check_eapi(self, eapi): + return eapi in ("0", "1", "2", "3", "4", "4-python", + "4-slot-abi", "5", "5-hdepend", "5-progress")
[gentoo-commits] proj/portage:repoman commit in: repoman/
commit: 31e90868cd7f2b78d6f4c0ca400314048c2b4868 Author: Brian Dolbec gentoo org> AuthorDate: Tue Dec 5 18:22:33 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:47 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=31e90868 repoman setup.py: Add the new cnf/qa_data cnf/linechecks items repoman/setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/repoman/setup.py b/repoman/setup.py index aaf10cdb5..9ac58ef35 100755 --- a/repoman/setup.py +++ b/repoman/setup.py @@ -479,6 +479,8 @@ setup( data_files = list(get_manpages()) + [ ['$docdir', ['NEWS', 'RELEASE-NOTES']], + ['share/repoman/qa_data', ['cnf/qa_data/qa_data.yaml']], + ['share/repoman/linechecks', ['cnf/linechecks/linechecks.yaml']], ], cmdclass = {
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/uri/
commit: d6a80ae7971c995ff770a36793f0d0ed6a13b7a1 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:05:03 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:45 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d6a80ae7 repoman: New linechecks module, uri .../pym/repoman/modules/linechecks/uri/__init__.py | 21 +++ repoman/pym/repoman/modules/linechecks/uri/uri.py | 30 ++ 2 files changed, 51 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/uri/__init__.py b/repoman/pym/repoman/modules/linechecks/uri/__init__.py new file mode 100644 index 0..a7731e3cc --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/uri/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Uri plug-in module for repoman LineChecks. +Performs HOMEPAGE variable checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'httpsuri-check': { + 'name': "httpsuri", + 'sourcefile': "uri", + 'class': "UriUseHttps", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/uri/uri.py b/repoman/pym/repoman/modules/linechecks/uri/uri.py new file mode 100644 index 0..1a0afe682 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/uri/uri.py @@ -0,0 +1,30 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class UriUseHttps(LineCheck): + """Check that we use https:// for known good sites.""" + repoman_check_name = 'uri.https' + _SITES = ( + '([-._a-zA-Z0-9]*\.)?apache\.org', + '((alioth|packages(\.qa)?|people|www)\.)?debian\.org', + # Most FDO sites support https, but not all (like tango). + # List the most common ones here for now. + '((anongit|bugs|cgit|dri|patchwork|people|specifications|www|xcb|xorg)\.)?freedesktop\.org', + '((bugs|dev|wiki|www)\.)?gentoo\.org', + '((wiki)\.)?github\.(io|com)', + 'savannah\.(non)?gnu\.org', + '((gcc|www)\.)?gnu\.org', + 'curl\.haxx\.se', + '((bugzilla|git|mirrors|patchwork|planet|www(\.wiki)?)\.)?kernel\.org', + '((bugs|wiki|www)\.)?linuxfoundation\.org', + '((docs|pypi|www)\.)?python\.org', + '(sf|sourceforge)\.net', + '(www\.)?(enlightenment|sourceware|x)\.org', + ) + # Try to anchor the end of the URL so we don't get false positives + # with http://github.com.foo.bar.com/. Unlikely, but possible. + re = re.compile(r'.*\bhttp://(%s)(\s|["\'/]|$)' % r'|'.join(_SITES)) + error = 'URI_HTTPS'
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/scan/ebuild/, repoman/pym/repoman/
commit: dec86d1bc9b9f200ff95434e03208a9504b20d60 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:09:03 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:46 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=dec86d1b repoman: Convert multicheck module to the new linechecks sub-module repoman/pym/repoman/modules/scan/ebuild/__init__.py | 2 +- repoman/pym/repoman/modules/scan/ebuild/multicheck.py | 10 +++--- repoman/pym/repoman/scanner.py| 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/repoman/pym/repoman/modules/scan/ebuild/__init__.py b/repoman/pym/repoman/modules/scan/ebuild/__init__.py index 3e1d31951..1d8ec1941 100644 --- a/repoman/pym/repoman/modules/scan/ebuild/__init__.py +++ b/repoman/pym/repoman/modules/scan/ebuild/__init__.py @@ -47,7 +47,7 @@ module_spec = { 'functions': ['check'], 'func_kwargs': { }, - 'mod_kwargs': ['qatracker', 'options' + 'mod_kwargs': ['qatracker', 'options', 'repo_settings', 'linechecks', ], 'func_kwargs': { 'ebuild': (None, None), diff --git a/repoman/pym/repoman/modules/scan/ebuild/multicheck.py b/repoman/pym/repoman/modules/scan/ebuild/multicheck.py index 9e36e2a68..94526ae9e 100644 --- a/repoman/pym/repoman/modules/scan/ebuild/multicheck.py +++ b/repoman/pym/repoman/modules/scan/ebuild/multicheck.py @@ -8,7 +8,7 @@ import io from portage import _encodings, _unicode_encode from repoman.modules.scan.scanbase import ScanBase -from .checks import run_checks, checks_init +from repoman.modules.linechecks.controller import LineCheckController class MultiCheck(ScanBase): @@ -22,7 +22,11 @@ class MultiCheck(ScanBase): ''' self.qatracker = kwargs.get('qatracker') self.options = kwargs.get('options') - checks_init(self.options.experimental_inherit == 'y') + self.controller = LineCheckController( + kwargs.get('repo_settings'), + kwargs.get('linechecks') + ) + self.controller.checks_init(self.options.experimental_inherit == 'y') def check(self, **kwargs): '''Check the ebuild for utf-8 encoding @@ -40,7 +44,7 @@ class MultiCheck(ScanBase): errors='strict'), mode='r', encoding=_encodings['repo.content']) try: - for check_name, e in run_checks(f, pkg): + for check_name, e in self.controller.run_checks(f, pkg): self.qatracker.add_error( check_name, ebuild.relative_path + ': %s' % e) finally: diff --git a/repoman/pym/repoman/scanner.py b/repoman/pym/repoman/scanner.py index b3d030570..d61e50131 100644 --- a/repoman/pym/repoman/scanner.py +++ b/repoman/pym/repoman/scanner.py @@ -193,6 +193,7 @@ class Scanner(object): "env": self.env, "have": self.have, "dev_keywords": self.dev_keywords, + "linechecks": self.moduleconfig.linechecks, } # initialize the plugin checks here self.modules = {}
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/phases/
commit: 2500cb29f76c26df359ec3bca92cca36aec3a364 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:03:33 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:45 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=2500cb29 repoman: New linechecks module, phases .../repoman/modules/linechecks/phases/__init__.py | 34 +++ .../pym/repoman/modules/linechecks/phases/phase.py | 71 ++ 2 files changed, 105 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/phases/__init__.py b/repoman/pym/repoman/modules/linechecks/phases/__init__.py new file mode 100644 index 0..476443b25 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/phases/__init__.py @@ -0,0 +1,34 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Phases plug-in module for repoman LineChecks. +Performs phase dependant checks on ebuilds using a PhaseCheck base class. +""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'emakeparallel-check': { + 'name': "emakeparallel", + 'sourcefile': "phase", + 'class': "EMakeParallelDisabled", + 'description': doc, + }, + 'srccompileeconf-check': { + 'name': "srccompileeconf", + 'sourcefile': "phase", + 'class': "SrcCompileEconf", + 'description': doc, + }, + 'srcunpackpatches-check': { + 'name': "srcunpackpatches", + 'sourcefile': "phase", + 'class': "SrcUnpackPatches", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/phases/phase.py b/repoman/pym/repoman/modules/linechecks/phases/phase.py new file mode 100644 index 0..acc3a1e1d --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/phases/phase.py @@ -0,0 +1,71 @@ + +import re + +from portage.eapi import eapi_has_src_prepare_and_src_configure +from repoman.modules.linechecks.base import LineCheck + + +class PhaseCheck(LineCheck): + """ basic class for function detection """ + + func_end_re = re.compile(r'^\}$') + phases_re = re.compile('(%s)' % '|'.join(( + 'pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare', + 'src_configure', 'src_compile', 'src_test', 'src_install', + 'pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm', + 'pkg_config'))) + in_phase = '' + + def check(self, num, line): + m = self.phases_re.match(line) + if m is not None: + self.in_phase = m.group(1) + if self.in_phase != '' and self.func_end_re.match(line) is not None: + self.in_phase = '' + + return self.phase_check(num, line) + + def phase_check(self, num, line): + """ override this function for your checks """ + pass + + +class EMakeParallelDisabled(PhaseCheck): + """Check for emake -j1 calls which disable parallelization.""" + repoman_check_name = 'upstream.workaround' + re = re.compile(r'^\s*emake\s+.*-j\s*1\b') + + def phase_check(self, num, line): + if self.in_phase == 'src_compile' or self.in_phase == 'src_install': + if self.re.match(line): + return self.errors['EMAKE_PARALLEL_DISABLED'] + + +class SrcCompileEconf(PhaseCheck): + repoman_check_name = 'ebuild.minorsyn' + configure_re = re.compile(r'\s(econf|./configure)') + + def check_eapi(self, eapi): + return eapi_has_src_prepare_and_src_configure(eapi) + + def phase_check(self, num, line): + if self.in_phase == 'src_compile': + m = self.configure_re.match(line) + if m is not None: + return ("'%s'" % m.group(1)) + \ + " call should be moved to src_configure from line: %d" + + +class SrcUnpackPatches(PhaseCheck): + repoman_check_name = 'ebuild.minorsyn' + src_prepare_tools_re = re.compile(r'\s(e?patch|sed)\s') + + def check_eapi(self, eapi): + return eapi_has_src_prepare_and_src_configure(eapi) + + def phase_check(self, num, line): + if self.in_phase == 'src_unpack': + m = self.src_prepare_tools_re.search(line) + if m is not None: + return ("'%s'" % m.group(1)) + \ + " call should be moved to src_prepare from line: %d"
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/gentoo_header/
commit: 921078cfc279df30c2982f9516c0998a12505c2d Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:01:04 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:45 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=921078cf repoman: New linechecks module, gentoo_header .../modules/linechecks/gentoo_header/__init__.py | 21 ++ .../modules/linechecks/gentoo_header/header.py | 49 ++ 2 files changed, 70 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py b/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py new file mode 100644 index 0..b80a83ecf --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Gentoo-header plug-in module for repoman LineChecks. +Performs header checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'header-check': { + 'name': "gentooheader", + 'sourcefile': "header", + 'class': "EbuildHeader", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py b/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py new file mode 100644 index 0..4b75fc4b5 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py @@ -0,0 +1,49 @@ + +import re +import time + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildHeader(LineCheck): + """Ensure ebuilds have proper headers + Copyright header errors + CVS header errors + License header errors + + Args: + modification_year - Year the ebuild was last modified + """ + + repoman_check_name = 'ebuild.badheader' + + gentoo_copyright = r'^# Copyright ((1999|2\d\d\d)-)?%s Gentoo Foundation$' + gentoo_license = ( + '# Distributed under the terms' + ' of the GNU General Public License v2') + id_header_re = re.compile(r'.*\$(Id|Header)(:.*)?\$.*') + blank_line_re = re.compile(r'^$') + ignore_comment = False + + def new(self, pkg): + if pkg.mtime is None: + self.modification_year = r'2\d\d\d' + else: + self.modification_year = str(time.gmtime(pkg.mtime)[0]) + self.gentoo_copyright_re = re.compile( + self.gentoo_copyright % self.modification_year) + + def check(self, num, line): + if num > 2: + return + elif num == 0: + if not self.gentoo_copyright_re.match(line): + return self.errors['COPYRIGHT_ERROR'] + elif num == 1 and line.rstrip('\n') != self.gentoo_license: + return self.errors['LICENSE_ERROR'] + elif num == 2 and self.id_header_re.match(line): + return self.errors['ID_HEADER_ERROR'] + elif num == 2 and not self.blank_line_re.match(line): + return self.errors['NO_BLANK_LINE_ERROR'] + +
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/helpers/
commit: 176b456c8725432346affcfdbbd449203c308d88 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:01:52 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:45 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=176b456c repoman: New linechecks module, helpers .../repoman/modules/linechecks/helpers/__init__.py | 21 + .../repoman/modules/linechecks/helpers/offset.py | 22 ++ 2 files changed, 43 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/helpers/__init__.py b/repoman/pym/repoman/modules/linechecks/helpers/__init__.py new file mode 100644 index 0..e2d12afe4 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/helpers/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Helpers plug-in module for repoman LineChecks. +Performs variable helpers checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'nooffset-check': { + 'name': "nooffset", + 'sourcefile': "offset", + 'class': "NoOffsetWithHelpers", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/helpers/offset.py b/repoman/pym/repoman/modules/linechecks/helpers/offset.py new file mode 100644 index 0..5d7624a68 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/helpers/offset.py @@ -0,0 +1,22 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class NoOffsetWithHelpers(LineCheck): + """ Check that the image location, the alternate root offset, and the + offset prefix (D, ROOT, ED, EROOT and EPREFIX) are not used with + helpers """ + + repoman_check_name = 'variable.usedwithhelpers' + # Ignore matches in quoted strings like this: + # elog "installed into ${ROOT}usr/share/php5/apc/." + _install_funcs = ( + 'docinto|do(compress|dir|hard)' + '|exeinto|fowners|fperms|insinto|into') + _quoted_vars = 'D|ROOT|ED|EROOT|EPREFIX' + re = re.compile( + r'^[^#"\']*\b(%s)\s+"?\$\{?(%s)\b.*' % + (_install_funcs, _quoted_vars)) + error = 'NO_OFFSET_WITH_HELPERS'
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/workaround/
commit: 33c77aa6fdf90334ad726504e615a065c6947cf0 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:07:59 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:46 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=33c77aa6 repoman: New linechecks module, workaround .../modules/linechecks/workaround/__init__.py | 27 ++ .../modules/linechecks/workaround/workarounds.py | 18 +++ 2 files changed, 45 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/workaround/__init__.py b/repoman/pym/repoman/modules/linechecks/workaround/__init__.py new file mode 100644 index 0..0b5aa70c8 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/workaround/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Workaround plug-in module for repoman LineChecks. +Performs checks for upstream workarounds in ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'addpredict-check': { + 'name': "addpredict", + 'sourcefile': "workarounds", + 'class': "SandboxAddpredict", + 'description': doc, + }, + 'noasneeded-check': { + 'name': "noasneeded", + 'sourcefile': "workarounds", + 'class': "NoAsNeeded", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/workaround/workarounds.py b/repoman/pym/repoman/modules/linechecks/workaround/workarounds.py new file mode 100644 index 0..37cb54314 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/workaround/workarounds.py @@ -0,0 +1,18 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class NoAsNeeded(LineCheck): + """Check for calls to the no-as-needed function.""" + repoman_check_name = 'upstream.workaround' + re = re.compile(r'.*\$\(no-as-needed\)') + error = 'NO_AS_NEEDED' + + +class SandboxAddpredict(LineCheck): + """Check for calls to the addpredict function.""" + repoman_check_name = 'upstream.workaround' + re = re.compile(r'(^|\s)addpredict\b') + error = 'SANDBOX_ADDPREDICT'
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/use/
commit: a4fa59ec3f38eb1696519f6c627e3bf7270b540b Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:05:56 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:45 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=a4fa59ec repoman: New linechecks module, use .../pym/repoman/modules/linechecks/use/__init__.py | 21 + .../pym/repoman/modules/linechecks/use/builtwith.py | 10 ++ 2 files changed, 31 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/use/__init__.py b/repoman/pym/repoman/modules/linechecks/use/__init__.py new file mode 100644 index 0..e5665d2d8 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/use/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Use plug-in module for repoman LineChecks. +Performs Built-With-Use checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'builtwith-check': { + 'name': "builtwith", + 'sourcefile': "builtwith", + 'class': "BuiltWithUse", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/use/builtwith.py b/repoman/pym/repoman/modules/linechecks/use/builtwith.py new file mode 100644 index 0..0ec4fae21 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/use/builtwith.py @@ -0,0 +1,10 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class BuiltWithUse(LineCheck): + repoman_check_name = 'ebuild.minorsyn' + re = re.compile(r'(^|.*\b)built_with_use\b') + error = 'BUILT_WITH_USE'
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/nested/
commit: d99bc535bd3b9973ae098fcc1d71353b4b47e28d Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:02:24 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:45 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d99bc535 repoman: New linechecks module, nested .../repoman/modules/linechecks/nested/__init__.py | 21 + .../pym/repoman/modules/linechecks/nested/nested.py | 15 +++ .../repoman/modules/linechecks/nested/nesteddie.py | 11 +++ 3 files changed, 47 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/nested/__init__.py b/repoman/pym/repoman/modules/linechecks/nested/__init__.py new file mode 100644 index 0..8eeeccbac --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/nested/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Nested plug-in module for repoman LineChecks. +Performs nested subshell checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'nesteddie-check': { + 'name': "nesteddie", + 'sourcefile': "nested", + 'class': "EbuildNestedDie", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/nested/nested.py b/repoman/pym/repoman/modules/linechecks/nested/nested.py new file mode 100644 index 0..06b272772 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/nested/nested.py @@ -0,0 +1,15 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildNestedDie(LineCheck): + """Check ebuild for nested die statements (die statements in subshells)""" + + repoman_check_name = 'ebuild.nesteddie' + nesteddie_re = re.compile(r'^[^#]*\s\(\s[^)]*\bdie\b') + + def check(self, num, line): + if self.nesteddie_re.match(line): + return self.errors['NESTED_DIE_ERROR'] diff --git a/repoman/pym/repoman/modules/linechecks/nested/nesteddie.py b/repoman/pym/repoman/modules/linechecks/nested/nesteddie.py new file mode 100644 index 0..6c1e4be9f --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/nested/nesteddie.py @@ -0,0 +1,11 @@ + + +class EbuildNestedDie(LineCheck): + """Check ebuild for nested die statements (die statements in subshells)""" + + repoman_check_name = 'ebuild.nesteddie' + nesteddie_re = re.compile(r'^[^#]*\s\(\s[^)]*\bdie\b') + + def check(self, num, line): + if self.nesteddie_re.match(line): + return errors.NESTED_DIE_ERROR
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/quotes/
commit: 4d375cd6318dd5cc16853c931acf33e3e92a794c Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:04:31 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:45 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=4d375cd6 repoman: New linechecks module, quotes .../repoman/modules/linechecks/quotes/__init__.py | 27 +++ .../repoman/modules/linechecks/quotes/quoteda.py | 16 .../repoman/modules/linechecks/quotes/quotes.py| 86 ++ 3 files changed, 129 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/quotes/__init__.py b/repoman/pym/repoman/modules/linechecks/quotes/__init__.py new file mode 100644 index 0..6043ab20c --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/quotes/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Nested plug-in module for repoman LineChecks. +Performs nested subshell checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'quote-check': { + 'name': "quote", + 'sourcefile': "quotes", + 'class': "EbuildQuote", + 'description': doc, + }, + 'quoteda-check': { + 'name': "quoteda", + 'sourcefile': "quoteda", + 'class': "EbuildQuotedA", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/quotes/quoteda.py b/repoman/pym/repoman/modules/linechecks/quotes/quoteda.py new file mode 100644 index 0..7fd9ba797 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/quotes/quoteda.py @@ -0,0 +1,16 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildQuotedA(LineCheck): + """Ensure ebuilds have no quoting around ${A}""" + + repoman_check_name = 'ebuild.minorsyn' + a_quoted = re.compile(r'.*\"\$(\{A\}|A)\"') + + def check(self, num, line): + match = self.a_quoted.match(line) + if match: + return "Quoted \"${A}\" on line: %d" diff --git a/repoman/pym/repoman/modules/linechecks/quotes/quotes.py b/repoman/pym/repoman/modules/linechecks/quotes/quotes.py new file mode 100644 index 0..68c594e23 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/quotes/quotes.py @@ -0,0 +1,86 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildQuote(LineCheck): + """Ensure ebuilds have valid quoting around things like D,FILESDIR, etc...""" + + repoman_check_name = 'ebuild.minorsyn' + _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+)') + ignore_comment = False + var_names = ["D", "DISTDIR", "FILESDIR", "S", "T", "ROOT", "WORKDIR"] + + # EAPI=3/Prefix vars + var_names += ["ED", "EPREFIX", "EROOT"] + + # variables for games.eclass + var_names += [ + "Ddir", "GAMES_PREFIX_OPT", "GAMES_DATADIR", + "GAMES_DATADIR_BASE", "GAMES_SYSCONFDIR", "GAMES_STATEDIR", + "GAMES_LOGDIR", "GAMES_BINDIR"] + + # variables for multibuild.eclass + var_names += ["BUILD_DIR"] + + var_names = "(%s)" % "|".join(var_names) + var_reference = re.compile( + r'\$(\{%s\}|%s\W)' % (var_names, var_names)) + missing_quotes = re.compile( + r'(\s|^)[^"\'\s]*\$\{?%s\}?[^"\'\s]*(\s|$)' % var_names) + cond_begin = re.compile(r'(^|\s+)\[\[($|\\$|\s+)') + cond_end = re.compile(r'(^|\s+)\]\]($|\\$|\s+)') + + def check(self, num, line): + if self.var_reference.search(line) is None: + return + # There can be multiple matches / violations on a single line. We + # have to make sure none of the matches are violators. Once we've + # found one violator, any remaining matches on the same line can + # be ignored. + pos = 0 + while pos <= len(line) - 1: + missing_quotes = self.missing_quotes.search(line, pos) + if not missing_quotes: + break + # If the last character of the previous match is a whitespace + # character, that character may be
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/useless/
commit: 3992e59c9ff60cbd25b60d7bf4e47b09b845aba1 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:06:38 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Fri Mar 30 00:43:46 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=3992e59c repoman: New linechecks module, useless .../repoman/modules/linechecks/useless/__init__.py | 27 ++ .../pym/repoman/modules/linechecks/useless/cd.py | 24 +++ .../repoman/modules/linechecks/useless/dodoc.py| 16 + 3 files changed, 67 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/useless/__init__.py b/repoman/pym/repoman/modules/linechecks/useless/__init__.py new file mode 100644 index 0..acc4479f5 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/useless/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Useless plug-in module for repoman LineChecks. +Performs checks for useless operations on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'uselesscds-check': { + 'name': "uselesscds", + 'sourcefile': "cd", + 'class': "EbuildUselessCdS", + 'description': doc, + }, + 'uselessdodoc-check': { + 'name': "uselessdodoc", + 'sourcefile': "dodoc", + 'class': "EbuildUselessDodoc", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/useless/cd.py b/repoman/pym/repoman/modules/linechecks/useless/cd.py new file mode 100644 index 0..3daa04451 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/useless/cd.py @@ -0,0 +1,24 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildUselessCdS(LineCheck): + """Check for redundant cd ${S} statements""" + repoman_check_name = 'ebuild.minorsyn' + _src_phases = r'^\s*src_(prepare|configure|compile|install|test)\s*\(\)' + method_re = re.compile(_src_phases) + cds_re = re.compile(r'^\s*cd\s+("\$(\{S\}|S)"|\$(\{S\}|S))\s') + + def __init__(self, errors): + self.errors = errors + self.check_next_line = False + + def check(self, num, line): + if self.check_next_line: + self.check_next_line = False + if self.cds_re.match(line): + return self.errors['REDUNDANT_CD_S_ERROR'] + elif self.method_re.match(line): + self.check_next_line = True diff --git a/repoman/pym/repoman/modules/linechecks/useless/dodoc.py b/repoman/pym/repoman/modules/linechecks/useless/dodoc.py new file mode 100644 index 0..502bfbea8 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/useless/dodoc.py @@ -0,0 +1,16 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildUselessDodoc(LineCheck): + """Check ebuild for useless files in dodoc arguments.""" + repoman_check_name = 'ebuild.minorsyn' + uselessdodoc_re = re.compile( + r'^\s*dodoc(\s+|\s+.*\s+)(ABOUT-NLS|COPYING|LICENCE|LICENSE)($|\s)') + + def check(self, num, line): + match = self.uselessdodoc_re.match(line) + if match: + return "Useless dodoc '%s'" % (match.group(2), ) + " on line: %d"
[gentoo-commits] proj/portage:repoman commit in: pym/portage/
commit: 1dd08a1ed5ad1b848a30f29f93a3b051c8bf95c4 Author: Brian Dolbec gentoo org> AuthorDate: Thu Aug 17 01:50:21 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:40 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=1dd08a1e module.py: Extend the module loader for API version checking If provided with an iterable of compatibility versions, The controller will check the plugin modules module_spec 'version' variable is compatible with the base application. pym/portage/module.py | 22 -- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pym/portage/module.py b/pym/portage/module.py index c79e65518..bd7c94d4e 100644 --- a/pym/portage/module.py +++ b/pym/portage/module.py @@ -15,6 +15,10 @@ class InvalidModuleName(PortageException): """An invalid or unknown module name.""" +class ModuleVersionError(PortageException): + '''An incompatible module version''' + + class Module(object): """Class to define and hold our plug-in module @@ -87,16 +91,17 @@ class Modules(object): @param namepath: Python import path to the "modules" directory """ - def __init__(self, path, namepath): + def __init__(self, path, namepath, compat_versions=None): self._module_path = path self._namepath = namepath + self.compat_versions = compat_versions self.parents = [] self._modules = self._get_all_modules() self.modules = ProtectedDict(self._modules) self.module_names = sorted(self._modules) def _get_all_modules(self): - """scans the emaint modules dir for loadable modules + """scans the _module_path dir for loadable modules @rtype: dictionary of module_plugins """ @@ -117,6 +122,7 @@ class Modules(object): kids = {} for entry in importables: new_module = Module(entry, self._namepath) + self._check_compat(new_module) for module_name in new_module.kids: kid = new_module.kids[module_name] kid['parent'] = new_module @@ -211,6 +217,8 @@ class Modules(object): @type modname: string @param modname: the module class name + @type var: string + @param var: the base level variable to return @type dictionary @return: the modules class exported options descriptions """ @@ -220,3 +228,13 @@ class Modules(object): raise InvalidModuleName( "Module name '%s' is invalid or not found" % modname) return value + + def _check_compat(self, module): + if self.compat_versions: + if not module.module_spec['version'] in self.compat_versions: + raise ModuleVersionError( + "Error loading '%s' plugin module: %s, version: %s\n" + "Module is not compatible with the current application version\n" + "Compatible module API versions are: %s" + % (self._namepath, module.module_spec['name'], + module.module_spec['version'], self.compat_versions))
[gentoo-commits] proj/portage:repoman commit in: /
commit: 10a693bf4dd6f72ee3fbb3465dab1b3635feaf1f Author: El Acheche Anis ubuntu com> AuthorDate: Wed Jul 26 22:20:56 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:41 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=10a693bf repoman: .travis.yml: pyyaml python module is needed for builds .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index ebcfbeab9..94ed2dcb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,8 @@ install: - "[[ ${TRAVIS_PYTHON_VERSION} == 3.[6789] ]] || pip install pyblake2" # always install pygost for Streebog - pip install pygost +# pyyaml is needed for building +- pip install pyyaml script: - printf "[build_ext]\nportage-ext-modules=true" >> setup.cfg
[gentoo-commits] proj/portage:repoman commit in: repoman/cnf/linechecks/, repoman/pym/repoman/modules/linechecks/
commit: 563f121e6b4b21b56048a8d2e9b3e86569b87b96 Author: Brian Dolbec gentoo org> AuthorDate: Tue Dec 5 18:17:15 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 21:26:13 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=563f121e repoman linechecks/config.py: Move the errors loading to a new /usr/share/repoman/linechecks directory This new directory can be installed to by third party add on modules that extend the checks. We can also in future use these file to get loaclized translations. repoman/cnf/linechecks/linechecks.yaml | 35 repoman/pym/repoman/modules/linechecks/config.py | 19 +++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/repoman/cnf/linechecks/linechecks.yaml b/repoman/cnf/linechecks/linechecks.yaml new file mode 100644 index 0..634381e80 --- /dev/null +++ b/repoman/cnf/linechecks/linechecks.yaml @@ -0,0 +1,35 @@ +--- +# linecheck_help.yaml + +# Repoman API version (do not edit) +version: 1 +# minimum +repoman_version: 2.3.3 + +# configuration file for the LineCheck plugins run via the multicheck +# scan module +errors: +COPYRIGHT_ERROR: 'Invalid Gentoo Copyright on line: %d' +LICENSE_ERROR: 'Invalid Gentoo/GPL License on line: %d' +ID_HEADER_ERROR: 'Stale CVS header on line: %d' +NO_BLANK_LINE_ERROR: 'Non-blank line after header on line: %d' +LEADING_SPACES_ERROR: 'Ebuild contains leading spaces on line: %d' +TRAILING_WHITESPACE_ERROR: 'Trailing whitespace error on line: %d' +READONLY_ASSIGNMENT_ERROR: 'Ebuild contains assignment to read-only variable on line: %d' +MISSING_QUOTES_ERROR: 'Unquoted Variable on line: %d' +NESTED_DIE_ERROR: 'Ebuild calls die in a subshell on line: %d' +PATCHES_ERROR: 'PATCHES is not a bash array on line: %d' +REDUNDANT_CD_S_ERROR: 'Ebuild has redundant cd ${S} statement on line: %d' +EMAKE_PARALLEL_DISABLED: 'Upstream parallel compilation bug (ebuild calls emake -j1 on line: %d)' +EMAKE_PARALLEL_DISABLED_VIA_MAKEOPTS: 'Upstream parallel compilation bug (MAKEOPTS=-j1 on line: %d)' +DEPRECATED_BINDNOW_FLAGS: 'Deprecated bindnow-flags call on line: %d' +EAPI_DEFINED_AFTER_INHERIT: 'EAPI defined after inherit on line: %d' +NO_AS_NEEDED: 'Upstream asneeded linking bug (no-as-needed on line: %d)' +PRESERVE_OLD_LIB: 'Ebuild calls deprecated preserve_old_lib on line: %d' +BUILT_WITH_USE: 'built_with_use on line: %d' +NO_OFFSET_WITH_HELPERS: 'Helper function is used with D, ROOT, ED, EROOT or EPREFIX on line: %d' +SANDBOX_ADDPREDICT: 'Ebuild calls addpredict on line: %d' +USEQ_ERROR: 'Ebuild calls deprecated useq function on line: %d' +HASQ_ERROR: 'Ebuild calls deprecated hasq function on line: %d' +URI_HTTPS: 'Ebuild uses http:// but should use https:// on line: %d' + diff --git a/repoman/pym/repoman/modules/linechecks/config.py b/repoman/pym/repoman/modules/linechecks/config.py index 9190b18cf..96a27ac49 100644 --- a/repoman/pym/repoman/modules/linechecks/config.py +++ b/repoman/pym/repoman/modules/linechecks/config.py @@ -15,6 +15,7 @@ from copy import deepcopy from repoman._portage import portage from repoman.config import load_config +from repoman import _not_installed # Avoid a circular import issue in py2.7 portage.proxy.lazyimport.lazyimport(globals(), @@ -46,8 +47,7 @@ class LineChecksConfig(object): @param configpaths: ordered list of filepaths to load ''' self.repo_settings = repo_settings - self.infopaths = [os.path.join(path, 'linechecks.yaml') for path in self.repo_settings.masters_list] - logging.debug("LineChecksConfig; configpaths: %s", self.infopaths) + self.infopaths = None self.info_config = None self._config = None self.usex_supported_eapis = None @@ -58,8 +58,22 @@ class LineChecksConfig(object): self.eclass_info = {} self.eclass_info_experimental_inherit = {} self.errors = {} + self.set_infopaths() self.load_checks_info() + def set_infopaths(self): + if _not_installed: + cnfdir = os.path.realpath(os.path.join(os.path.dirname( + os.path.dirname(os.path.dirname(os.path.dirname( + os.path.dirname(__file__), 'cnf/linechecks')) + else: + cnfdir = os.path.join(portage.const.EPREFIX or '/', 'usr/share/repoman/linechecks') + repomanpaths = [os.path.join(cnfdir, _file_) for _file_ in os.listdir(cnfdir)] + logging.debug("LineChecksConfig; repomanpaths: %s", repomanpaths) + repopaths = [os.path.join(path, 'linechecks.yaml') for path in self.repo_settings.masters_list] + self.infopaths = repomanpaths +
[gentoo-commits] proj/portage:repoman commit in: repoman/cnf/qa_data/, repoman/pym/repoman/
commit: 17ef23c84f576c6e9b5dbd92ae0816f46b7b70df Author: Brian Dolbec gentoo org> AuthorDate: Tue Dec 5 18:16:44 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 21:26:08 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=17ef23c8 repoman qa_data.py: Move the qahelp loading to a new /usr/share/repoman/qa_data directory This new directory can be installed to by third party add on modules that extend the checks. We can also in future use these file to get loaclized translations. repoman/cnf/qa_data/qa_data.yaml | 140 +++ repoman/pym/repoman/qa_data.py | 19 +- 2 files changed, 156 insertions(+), 3 deletions(-) diff --git a/repoman/cnf/qa_data/qa_data.yaml b/repoman/cnf/qa_data/qa_data.yaml new file mode 100644 index 0..108963924 --- /dev/null +++ b/repoman/cnf/qa_data/qa_data.yaml @@ -0,0 +1,140 @@ +--- +# qa_help.yaml + +# configuration file for the LineCheck plugins run via the multicheck +# scan module + +# Repoman API version (do not edit) +version: 1 +# minimum +repoman_version: 2.3.3 + +# qahelp: Primary QA help messages to describe the errors or warnings +# Dictionary +qahelp: +Entries: +IO_error: "Attempting to commit, and an IO error was encountered access the Entries file" +ebuild: +invalidname: "Ebuild files with a non-parseable or syntactically incorrect name (or using 2.1 versioning extensions)" +namenomatch: "Ebuild files that do not have the same name as their parent directory" +notadded: "Ebuilds that exist but have not been added to the vcs" +patches: "PATCHES variable should be a bash array to ensure white space safety" +changelog: +ebuildadded: "An ebuild was added but the ChangeLog was not modified" +missing: "Missing ChangeLog files" +notadded: "ChangeLogs that exist but have not been added to cvs" +dependency: +bad: "User-visible ebuilds with unsatisfied dependencies (matched against *visible* ebuilds)" +badmasked: "Masked ebuilds with unsatisfied dependencies (matched against *all* ebuilds)" +badindev: "User-visible ebuilds with unsatisfied dependencies (matched against *visible* ebuilds) in developing arch" +badmaskedindev: "Masked ebuilds with unsatisfied dependencies (matched against *all* ebuilds) in developing arch" +badinexp: "User-visible ebuilds with unsatisfied dependencies (matched against *visible* ebuilds) in experimental arch" +badmaskedinexp: "Masked ebuilds with unsatisfied dependencies (matched against *all* ebuilds) in experimental arch" +badtilde: "Uses the ~ dep operator with a non-zero revision part, which is useless (the revision is ignored)" +missingslot: "RDEPEND matches more than one SLOT but does not specify a slot and/or use the := or :* slot operator" +perlcore: "This ebuild directly depends on a package in perl-core; it should use the corresponding virtual instead." +syntax: "Syntax error in dependency string (usually an extra/missing space/parenthesis)" +unknown: "Ebuild has a dependency that refers to an unknown package (which may be valid if it is a blocker for a renamed/removed package, or is an alternative choice provided by an overlay)" +badslotop: "RDEPEND contains ':=' slot operator under '||' dependency." +DESCRIPTION: +missing: "Ebuilds that have a missing or empty DESCRIPTION variable" +toolong: "DESCRIPTION is over %d characters" +digest: +assumed: "Existing digest must be assumed correct (Package level only)" +missing: "Some files listed in SRC_URI aren't referenced in the Manifest" +unused: "Some files listed in the Manifest aren't referenced in SRC_URI" +EAPI: +definition: "EAPI definition does not conform to PMS section 7.3.1 (first non-comment, non-blank line)" +deprecated: "Ebuilds that use features that are deprecated in the current EAPI" +incompatible: "Ebuilds that use features that are only available with a different EAPI" +unsupported: "Ebuilds that have an unsupported EAPI version (you must upgrade portage)" +ebuild: +absdosym: "This ebuild uses absolute target to dosym where relative symlink could be used instead" +badheader: "This ebuild has a malformed header" +majorsyn: "This ebuild has a major syntax error that may cause the ebuild to fail partially or fully" +minorsyn: "This ebuild has a minor syntax error that contravenes gentoo coding style" +nesteddie: "Placing 'die' inside ( ) prints an error, but doesn't stop the ebuild." +output: "A simple sourcing of the ebuild produces output; this breaks ebuild policy." +syntax: "Error generating cache entry for ebuild; typically caused by ebuild syntax error or digest verification failure" +file: +executable:
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/tests/
commit: 1b0ed497a2c3fe19debc774e6a4263344d8572f8 Author: El Acheche Anis ubuntu com> AuthorDate: Mon Jul 24 04:46:28 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:40 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=1b0ed497 repoman: repoman/pym/repoman/tests/runTests.py: Fix PEP8 E401 repoman/pym/repoman/tests/runTests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/repoman/pym/repoman/tests/runTests.py b/repoman/pym/repoman/tests/runTests.py index 759abdd82..3125ff058 100644 --- a/repoman/pym/repoman/tests/runTests.py +++ b/repoman/pym/repoman/tests/runTests.py @@ -3,7 +3,8 @@ # Copyright 2006-2017 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -import os, sys +import os +import sys import os.path as osp import grp import platform
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/tests/
commit: 0a8aae892cfd7fcb0485c9936607cd04edfb96b5 Author: El Acheche Anis ubuntu com> AuthorDate: Mon Jul 24 04:47:42 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:40 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=0a8aae89 repoman: repoman/pym/repoman/tests/runTests.py: Fix PEP8 E302 repoman/pym/repoman/tests/runTests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/repoman/pym/repoman/tests/runTests.py b/repoman/pym/repoman/tests/runTests.py index 3125ff058..1795aa487 100644 --- a/repoman/pym/repoman/tests/runTests.py +++ b/repoman/pym/repoman/tests/runTests.py @@ -11,6 +11,7 @@ import platform import pwd import signal + def debug_signal(signum, frame): import pdb pdb.set_trace()
[gentoo-commits] proj/portage:repoman commit in: repoman/
commit: dfc53030e25513a68a8c6b17f85719da9f1ac65c Author: Brian Dolbec gentoo org> AuthorDate: Tue Dec 5 18:22:33 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 21:26:13 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=dfc53030 repoman setup.py: Add the new cnf/qa_data cnf/linechecks items repoman/setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/repoman/setup.py b/repoman/setup.py index aaf10cdb5..9ac58ef35 100755 --- a/repoman/setup.py +++ b/repoman/setup.py @@ -479,6 +479,8 @@ setup( data_files = list(get_manpages()) + [ ['$docdir', ['NEWS', 'RELEASE-NOTES']], + ['share/repoman/qa_data', ['cnf/qa_data/qa_data.yaml']], + ['share/repoman/linechecks', ['cnf/linechecks/linechecks.yaml']], ], cmdclass = {
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/scan/
commit: 14f9b7d4d22a223eb54defb29e1fb2adc02fb111 Author: Brian Dolbec gentoo org> AuthorDate: Tue Dec 5 19:29:26 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 21:26:13 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=14f9b7d4 repoman scan/module.py: fix typo repoman/pym/repoman/modules/scan/module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repoman/pym/repoman/modules/scan/module.py b/repoman/pym/repoman/modules/scan/module.py index fc0c66ccb..cebc0e708 100644 --- a/repoman/pym/repoman/modules/scan/module.py +++ b/repoman/pym/repoman/modules/scan/module.py @@ -85,7 +85,7 @@ class ModuleConfig(object): if loop in self.controller.get_spec(mod, 'module_runsIn'): mlist.append(mod) except InvalidModuleName: - logging.error("ModuleConfig; unkown module: %s, skipping", mod) + logging.error("ModuleConfig; unknown module: %s, skipping", mod) logging.debug("ModuleConfig; mlist: %s", mlist) return mlist
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/workaround/
commit: 48ffac1217fe6383b4cd4fb5ad985abe344f90cb Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:07:59 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:40 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=48ffac12 repoman: New linechecks module, workaround .../modules/linechecks/workaround/__init__.py | 27 ++ .../modules/linechecks/workaround/workarounds.py | 18 +++ 2 files changed, 45 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/workaround/__init__.py b/repoman/pym/repoman/modules/linechecks/workaround/__init__.py new file mode 100644 index 0..0b5aa70c8 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/workaround/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Workaround plug-in module for repoman LineChecks. +Performs checks for upstream workarounds in ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'addpredict-check': { + 'name': "addpredict", + 'sourcefile': "workarounds", + 'class': "SandboxAddpredict", + 'description': doc, + }, + 'noasneeded-check': { + 'name': "noasneeded", + 'sourcefile': "workarounds", + 'class': "NoAsNeeded", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/workaround/workarounds.py b/repoman/pym/repoman/modules/linechecks/workaround/workarounds.py new file mode 100644 index 0..37cb54314 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/workaround/workarounds.py @@ -0,0 +1,18 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class NoAsNeeded(LineCheck): + """Check for calls to the no-as-needed function.""" + repoman_check_name = 'upstream.workaround' + re = re.compile(r'.*\$\(no-as-needed\)') + error = 'NO_AS_NEEDED' + + +class SandboxAddpredict(LineCheck): + """Check for calls to the addpredict function.""" + repoman_check_name = 'upstream.workaround' + re = re.compile(r'(^|\s)addpredict\b') + error = 'SANDBOX_ADDPREDICT'
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/portage/
commit: 266089a5eb062d276c8792c8aa6f1be03b9270a6 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:04:00 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:39 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=266089a5 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 0..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 0..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
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/helpers/
commit: 28875d7dce8e0421029fb57298385a5c20d68bef Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:01:52 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:38 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=28875d7d repoman: New linechecks module, helpers .../repoman/modules/linechecks/helpers/__init__.py | 21 + .../repoman/modules/linechecks/helpers/offset.py | 22 ++ 2 files changed, 43 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/helpers/__init__.py b/repoman/pym/repoman/modules/linechecks/helpers/__init__.py new file mode 100644 index 0..e2d12afe4 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/helpers/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Helpers plug-in module for repoman LineChecks. +Performs variable helpers checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'nooffset-check': { + 'name': "nooffset", + 'sourcefile': "offset", + 'class': "NoOffsetWithHelpers", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/helpers/offset.py b/repoman/pym/repoman/modules/linechecks/helpers/offset.py new file mode 100644 index 0..5d7624a68 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/helpers/offset.py @@ -0,0 +1,22 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class NoOffsetWithHelpers(LineCheck): + """ Check that the image location, the alternate root offset, and the + offset prefix (D, ROOT, ED, EROOT and EPREFIX) are not used with + helpers """ + + repoman_check_name = 'variable.usedwithhelpers' + # Ignore matches in quoted strings like this: + # elog "installed into ${ROOT}usr/share/php5/apc/." + _install_funcs = ( + 'docinto|do(compress|dir|hard)' + '|exeinto|fowners|fperms|insinto|into') + _quoted_vars = 'D|ROOT|ED|EROOT|EPREFIX' + re = re.compile( + r'^[^#"\']*\b(%s)\s+"?\$\{?(%s)\b.*' % + (_install_funcs, _quoted_vars)) + error = 'NO_OFFSET_WITH_HELPERS'
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/nested/, ...
commit: 92c8b12fa286eaa93d36c95059e5ac08111ca623 Author: Brian Dolbec gentoo org> AuthorDate: Wed Aug 16 23:24:24 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:40 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=92c8b12f repoman: Initial adding file/module/API version repoman/pym/repoman/config.py| 7 +-- repoman/pym/repoman/main.py | 3 +++ repoman/pym/repoman/modules/linechecks/assignment/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/config.py | 2 +- repoman/pym/repoman/modules/linechecks/depend/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/deprecated/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/do/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/eapi/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/emake/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/helpers/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/nested/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/patches/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/phases/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/portage/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/quotes/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/uri/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/use/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/useless/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/whitespace/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/workaround/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/depend/__init__.py | 3 ++- repoman/pym/repoman/modules/scan/directories/__init__.py | 3 ++- repoman/pym/repoman/modules/scan/eapi/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/ebuild/__init__.py | 3 ++- repoman/pym/repoman/modules/scan/eclasses/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/fetch/__init__.py | 3 ++- repoman/pym/repoman/modules/scan/keywords/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/manifest/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/metadata/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/module.py | 9 ++--- repoman/pym/repoman/modules/scan/options/__init__.py | 3 ++- repoman/pym/repoman/qa_data.py | 4 ++-- repoman/pym/repoman/repos.py | 2 +- repoman/pym/repoman/scanner.py | 3 ++- 35 files changed, 76 insertions(+), 38 deletions(-) diff --git a/repoman/pym/repoman/config.py b/repoman/pym/repoman/config.py index 3329f0e7e..6facf5cc8 100644 --- a/repoman/pym/repoman/config.py +++ b/repoman/pym/repoman/config.py @@ -144,8 +144,11 @@ def load_config(conf_dirs, file_extensions=None, valid_versions=None): if config: if config['version'] not in valid_versions: - raise ConfigError("Invalid file version: %s in: %s\nPlease upgrade repoman: current valid versions: %s" - % (config['version'], filename, valid_versions)) + raise ConfigError( + "Invalid file version: %s in: %s\nPlease upgrade to " + ">=app-portage/repoman-%s, current valid API versions: %s" + % (config['version'], filename, + config['repoman_version'], valid_versions)) result = merge_config(result, config) return result diff --git a/repoman/pym/repoman/main.py b/repoman/pym/repoman/main.py index c1e3b99fe..81e2ff61e 100755 --- a/repoman/pym/repoman/main.py +++ b/repoman/pym/repoman/main.py @@ -47,10 +47,12 @@ os.umask(0o22) LOGLEVEL = logging.WARNING portage.util.initialize_logger(LOGLEVEL) +VALID_VERSIONS = [1,] def repoman_main(argv): config_root = os.environ.get("PORTAGE_CONFIGROOT") repoman_settings = portage.config(config_root=config_root, local_config=False) + repoman_settings.valid_versions = VALID_VERSIONS if repoman_settings.get("NOCOLOR", "").lower() in ("yes", "true") or \ repoman_settings.get('TERM') == 'dumb' or \ @@ -92,6 +94,7 @@ def repoman_main(argv): config_root, portdir, portdir_overlay, repoman_settings, vcs_settings, options, qadata) repoman_settings = repo_settings.repoman_settings +
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/tests/
commit: 6c02e864d4a48a6d89caee464de71d21d60bde28 Author: El Acheche Anis ubuntu com> AuthorDate: Mon Jul 24 04:49:26 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:40 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=6c02e864 repoman: repoman/pym/repoman/tests/runTests.py: Fix PEP8 E261 repoman/pym/repoman/tests/runTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repoman/pym/repoman/tests/runTests.py b/repoman/pym/repoman/tests/runTests.py index 1795aa487..ca37b14b3 100644 --- a/repoman/pym/repoman/tests/runTests.py +++ b/repoman/pym/repoman/tests/runTests.py @@ -17,7 +17,7 @@ def debug_signal(signum, frame): pdb.set_trace() if platform.python_implementation() == 'Jython': - debug_signum = signal.SIGUSR2 # bug #424259 + debug_signum = signal.SIGUSR2 # bug #424259 else: debug_signum = signal.SIGUSR1
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/tests/
commit: 692e911e5bf7cdef693326dc165a6acb98652248 Author: El Acheche Anis ubuntu com> AuthorDate: Mon Jul 24 04:50:07 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:40 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=692e911e repoman: repoman/pym/repoman/tests/runTests.py: Fix PEP8 E226 repoman/pym/repoman/tests/runTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repoman/pym/repoman/tests/runTests.py b/repoman/pym/repoman/tests/runTests.py index ca37b14b3..b0e715ec6 100644 --- a/repoman/pym/repoman/tests/runTests.py +++ b/repoman/pym/repoman/tests/runTests.py @@ -35,7 +35,7 @@ repoman_pym = osp.dirname(osp.dirname(osp.dirname(osp.realpath(__file__ sys.path.insert(0, repoman_pym) # Add in the parent portage python modules -portage_pym = osp.dirname(osp.dirname(repoman_pym))+'/pym' +portage_pym = osp.dirname(osp.dirname(repoman_pym)) + '/pym' sys.path.insert(0, portage_pym) # import our centrally initialized portage instance
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/uri/
commit: 0381c6d1656eaec92b705c6833cc4be7502806b5 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:05:03 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:39 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=0381c6d1 repoman: New linechecks module, uri .../pym/repoman/modules/linechecks/uri/__init__.py | 21 +++ repoman/pym/repoman/modules/linechecks/uri/uri.py | 30 ++ 2 files changed, 51 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/uri/__init__.py b/repoman/pym/repoman/modules/linechecks/uri/__init__.py new file mode 100644 index 0..a7731e3cc --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/uri/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Uri plug-in module for repoman LineChecks. +Performs HOMEPAGE variable checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'httpsuri-check': { + 'name': "httpsuri", + 'sourcefile': "uri", + 'class': "UriUseHttps", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/uri/uri.py b/repoman/pym/repoman/modules/linechecks/uri/uri.py new file mode 100644 index 0..1a0afe682 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/uri/uri.py @@ -0,0 +1,30 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class UriUseHttps(LineCheck): + """Check that we use https:// for known good sites.""" + repoman_check_name = 'uri.https' + _SITES = ( + '([-._a-zA-Z0-9]*\.)?apache\.org', + '((alioth|packages(\.qa)?|people|www)\.)?debian\.org', + # Most FDO sites support https, but not all (like tango). + # List the most common ones here for now. + '((anongit|bugs|cgit|dri|patchwork|people|specifications|www|xcb|xorg)\.)?freedesktop\.org', + '((bugs|dev|wiki|www)\.)?gentoo\.org', + '((wiki)\.)?github\.(io|com)', + 'savannah\.(non)?gnu\.org', + '((gcc|www)\.)?gnu\.org', + 'curl\.haxx\.se', + '((bugzilla|git|mirrors|patchwork|planet|www(\.wiki)?)\.)?kernel\.org', + '((bugs|wiki|www)\.)?linuxfoundation\.org', + '((docs|pypi|www)\.)?python\.org', + '(sf|sourceforge)\.net', + '(www\.)?(enlightenment|sourceware|x)\.org', + ) + # Try to anchor the end of the URL so we don't get false positives + # with http://github.com.foo.bar.com/. Unlikely, but possible. + re = re.compile(r'.*\bhttp://(%s)(\s|["\'/]|$)' % r'|'.join(_SITES)) + error = 'URI_HTTPS'
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/scan/ebuild/
commit: 85df91ccfa0b13ab9ec856b28e92a4c76bcfe08d Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:10:13 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:40 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=85df91cc repoman: Remove the no longer used modules/scan/ebuild/checks.py repoman/pym/repoman/modules/scan/ebuild/checks.py | 1044 - 1 file changed, 1044 deletions(-) diff --git a/repoman/pym/repoman/modules/scan/ebuild/checks.py b/repoman/pym/repoman/modules/scan/ebuild/checks.py deleted file mode 100644 index de03bedd2..0 --- a/repoman/pym/repoman/modules/scan/ebuild/checks.py +++ /dev/null @@ -1,1044 +0,0 @@ -# -*- coding:utf-8 -*- -# repoman: Checks -# Copyright 2007-2017 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -"""This module contains functions used in Repoman to ascertain the quality -and correctness of an ebuild.""" - -from __future__ import unicode_literals - -from itertools import chain -import operator -import re -import time - -# import our initialized portage instance -from repoman._portage import portage - -from portage.eapi import ( - eapi_supports_prefix, eapi_has_implicit_rdepend, - eapi_has_src_prepare_and_src_configure, eapi_has_dosed_dohard, - eapi_exports_AA, eapi_has_pkg_pretend) - -from . import errors - - -class LineCheck(object): - """Run a check on a line of an ebuild.""" - """A regular expression to determine whether to ignore the line""" - ignore_line = False - """True if lines containing nothing more than comments with optional - leading whitespace should be ignored""" - ignore_comment = True - - def new(self, pkg): - pass - - def check_eapi(self, eapi): - """Returns if check should be run in the given EAPI (default: True)""" - return True - - 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 PhaseCheck(LineCheck): - """ basic class for function detection """ - - func_end_re = re.compile(r'^\}$') - phases_re = re.compile('(%s)' % '|'.join(( - 'pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare', - 'src_configure', 'src_compile', 'src_test', 'src_install', - 'pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm', - 'pkg_config'))) - in_phase = '' - - def check(self, num, line): - m = self.phases_re.match(line) - if m is not None: - self.in_phase = m.group(1) - if self.in_phase != '' and self.func_end_re.match(line) is not None: - self.in_phase = '' - - return self.phase_check(num, line) - - def phase_check(self, num, line): - """ override this function for your checks """ - pass - - -class EbuildHeader(LineCheck): - """Ensure ebuilds have proper headers - Copyright header errors - CVS header errors - License header errors - - Args: - modification_year - Year the ebuild was last modified - """ - - repoman_check_name = 'ebuild.badheader' - - gentoo_copyright = r'^# Copyright ((1999|2\d\d\d)-)?%s Gentoo Foundation$' - gentoo_license = ( - '# Distributed under the terms' - ' of the GNU General Public License v2') - id_header_re = re.compile(r'.*\$(Id|Header)(:.*)?\$.*') - blank_line_re = re.compile(r'^$') - ignore_comment = False - - def new(self, pkg): - if pkg.mtime is None: - self.modification_year = r'2\d\d\d' - else: - self.modification_year = str(time.gmtime(pkg.mtime)[0]) - self.gentoo_copyright_re = re.compile( - self.gentoo_copyright % self.modification_year) - - def check(self, num, line): - if num > 2: - return - elif num == 0: - if not self.gentoo_copyright_re.match(line): - return errors.COPYRIGHT_ERROR - elif num == 1 and line.rstrip('\n') != self.gentoo_license: - return errors.LICENSE_ERROR - elif num == 2 and self.id_header_re.match(line): - return errors.ID_HEADER_ERROR - elif num == 2 and not self.blank_line_re.match(line): - return errors.NO_BLANK_LINE_ERROR - - -class EbuildWhitespace(LineCheck): - """Ensure ebuilds have proper whitespacing""" - - repoman_check_name = 'ebuild.minorsyn' - - ignore_line
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/use/
commit: dd91714d7fc605aa9f29f8b8a5819246703f9110 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:05:56 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:39 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=dd91714d repoman: New linechecks module, use .../pym/repoman/modules/linechecks/use/__init__.py | 21 + .../pym/repoman/modules/linechecks/use/builtwith.py | 10 ++ 2 files changed, 31 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/use/__init__.py b/repoman/pym/repoman/modules/linechecks/use/__init__.py new file mode 100644 index 0..e5665d2d8 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/use/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Use plug-in module for repoman LineChecks. +Performs Built-With-Use checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'builtwith-check': { + 'name': "builtwith", + 'sourcefile': "builtwith", + 'class': "BuiltWithUse", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/use/builtwith.py b/repoman/pym/repoman/modules/linechecks/use/builtwith.py new file mode 100644 index 0..0ec4fae21 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/use/builtwith.py @@ -0,0 +1,10 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class BuiltWithUse(LineCheck): + repoman_check_name = 'ebuild.minorsyn' + re = re.compile(r'(^|.*\b)built_with_use\b') + error = 'BUILT_WITH_USE'
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/gentoo_header/
commit: 727c92c218a886f4d1fdcf69b68013c6600bb248 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:01:04 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:38 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=727c92c2 repoman: New linechecks module, gentoo_header .../modules/linechecks/gentoo_header/__init__.py | 21 ++ .../modules/linechecks/gentoo_header/header.py | 49 ++ 2 files changed, 70 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py b/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py new file mode 100644 index 0..b80a83ecf --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Gentoo-header plug-in module for repoman LineChecks. +Performs header checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'header-check': { + 'name': "gentooheader", + 'sourcefile': "header", + 'class': "EbuildHeader", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py b/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py new file mode 100644 index 0..4b75fc4b5 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py @@ -0,0 +1,49 @@ + +import re +import time + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildHeader(LineCheck): + """Ensure ebuilds have proper headers + Copyright header errors + CVS header errors + License header errors + + Args: + modification_year - Year the ebuild was last modified + """ + + repoman_check_name = 'ebuild.badheader' + + gentoo_copyright = r'^# Copyright ((1999|2\d\d\d)-)?%s Gentoo Foundation$' + gentoo_license = ( + '# Distributed under the terms' + ' of the GNU General Public License v2') + id_header_re = re.compile(r'.*\$(Id|Header)(:.*)?\$.*') + blank_line_re = re.compile(r'^$') + ignore_comment = False + + def new(self, pkg): + if pkg.mtime is None: + self.modification_year = r'2\d\d\d' + else: + self.modification_year = str(time.gmtime(pkg.mtime)[0]) + self.gentoo_copyright_re = re.compile( + self.gentoo_copyright % self.modification_year) + + def check(self, num, line): + if num > 2: + return + elif num == 0: + if not self.gentoo_copyright_re.match(line): + return self.errors['COPYRIGHT_ERROR'] + elif num == 1 and line.rstrip('\n') != self.gentoo_license: + return self.errors['LICENSE_ERROR'] + elif num == 2 and self.id_header_re.match(line): + return self.errors['ID_HEADER_ERROR'] + elif num == 2 and not self.blank_line_re.match(line): + return self.errors['NO_BLANK_LINE_ERROR'] + +
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/whitespace/
commit: 9f4cd5889130f9bb3f738873986a53175deac9e6 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:07:13 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:39 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=9f4cd588 repoman: New linechecks module, whitespace .../modules/linechecks/whitespace/__init__.py | 27 ++ .../repoman/modules/linechecks/whitespace/blank.py | 25 .../modules/linechecks/whitespace/whitespace.py| 21 + 3 files changed, 73 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/whitespace/__init__.py b/repoman/pym/repoman/modules/linechecks/whitespace/__init__.py new file mode 100644 index 0..ded690ed7 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/whitespace/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Whitespace plug-in module for repoman LineChecks. +Performs checks for useless whitespace in ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'whitespace-check': { + 'name': "whitespace", + 'sourcefile': "whitespace", + 'class': "EbuildWhitespace", + 'description': doc, + }, + 'blankline-check': { + 'name': "blankline", + 'sourcefile': "blank", + 'class': "EbuildBlankLine", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/whitespace/blank.py b/repoman/pym/repoman/modules/linechecks/whitespace/blank.py new file mode 100644 index 0..2ab4097a3 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/whitespace/blank.py @@ -0,0 +1,25 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildBlankLine(LineCheck): + repoman_check_name = 'ebuild.minorsyn' + ignore_comment = False + blank_line = re.compile(r'^$') + + def new(self, pkg): + self.line_is_blank = False + + def check(self, num, line): + if self.line_is_blank and self.blank_line.match(line): + return 'Useless blank line on line: %d' + if self.blank_line.match(line): + self.line_is_blank = True + else: + self.line_is_blank = False + + def end(self): + if self.line_is_blank: + yield 'Useless blank line on last line' diff --git a/repoman/pym/repoman/modules/linechecks/whitespace/whitespace.py b/repoman/pym/repoman/modules/linechecks/whitespace/whitespace.py new file mode 100644 index 0..556b2ab81 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/whitespace/whitespace.py @@ -0,0 +1,21 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildWhitespace(LineCheck): + """Ensure ebuilds have proper whitespacing""" + + repoman_check_name = 'ebuild.minorsyn' + + ignore_line = re.compile(r'(^$)|(^(\t)*#)') + ignore_comment = False + leading_spaces = re.compile(r'^[\S\t]') + trailing_whitespace = re.compile(r'.*([\S]$)') + + def check(self, num, line): + if self.leading_spaces.match(line) is None: + return self.errors['LEADING_SPACES_ERROR'] + if self.trailing_whitespace.match(line) is None: + return self.errors['TRAILING_WHITESPACE_ERROR']
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/quotes/
commit: 0e5a3c428e629d9784ad147ecc0dddea1acad96d Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:04:31 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:39 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=0e5a3c42 repoman: New linechecks module, quotes .../repoman/modules/linechecks/quotes/__init__.py | 27 +++ .../repoman/modules/linechecks/quotes/quoteda.py | 16 .../repoman/modules/linechecks/quotes/quotes.py| 86 ++ 3 files changed, 129 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/quotes/__init__.py b/repoman/pym/repoman/modules/linechecks/quotes/__init__.py new file mode 100644 index 0..6043ab20c --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/quotes/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Nested plug-in module for repoman LineChecks. +Performs nested subshell checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'quote-check': { + 'name': "quote", + 'sourcefile': "quotes", + 'class': "EbuildQuote", + 'description': doc, + }, + 'quoteda-check': { + 'name': "quoteda", + 'sourcefile': "quoteda", + 'class': "EbuildQuotedA", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/quotes/quoteda.py b/repoman/pym/repoman/modules/linechecks/quotes/quoteda.py new file mode 100644 index 0..7fd9ba797 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/quotes/quoteda.py @@ -0,0 +1,16 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildQuotedA(LineCheck): + """Ensure ebuilds have no quoting around ${A}""" + + repoman_check_name = 'ebuild.minorsyn' + a_quoted = re.compile(r'.*\"\$(\{A\}|A)\"') + + def check(self, num, line): + match = self.a_quoted.match(line) + if match: + return "Quoted \"${A}\" on line: %d" diff --git a/repoman/pym/repoman/modules/linechecks/quotes/quotes.py b/repoman/pym/repoman/modules/linechecks/quotes/quotes.py new file mode 100644 index 0..68c594e23 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/quotes/quotes.py @@ -0,0 +1,86 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildQuote(LineCheck): + """Ensure ebuilds have valid quoting around things like D,FILESDIR, etc...""" + + repoman_check_name = 'ebuild.minorsyn' + _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+)') + ignore_comment = False + var_names = ["D", "DISTDIR", "FILESDIR", "S", "T", "ROOT", "WORKDIR"] + + # EAPI=3/Prefix vars + var_names += ["ED", "EPREFIX", "EROOT"] + + # variables for games.eclass + var_names += [ + "Ddir", "GAMES_PREFIX_OPT", "GAMES_DATADIR", + "GAMES_DATADIR_BASE", "GAMES_SYSCONFDIR", "GAMES_STATEDIR", + "GAMES_LOGDIR", "GAMES_BINDIR"] + + # variables for multibuild.eclass + var_names += ["BUILD_DIR"] + + var_names = "(%s)" % "|".join(var_names) + var_reference = re.compile( + r'\$(\{%s\}|%s\W)' % (var_names, var_names)) + missing_quotes = re.compile( + r'(\s|^)[^"\'\s]*\$\{?%s\}?[^"\'\s]*(\s|$)' % var_names) + cond_begin = re.compile(r'(^|\s+)\[\[($|\\$|\s+)') + cond_end = re.compile(r'(^|\s+)\]\]($|\\$|\s+)') + + def check(self, num, line): + if self.var_reference.search(line) is None: + return + # There can be multiple matches / violations on a single line. We + # have to make sure none of the matches are violators. Once we've + # found one violator, any remaining matches on the same line can + # be ignored. + pos = 0 + while pos <= len(line) - 1: + missing_quotes = self.missing_quotes.search(line, pos) + if not missing_quotes: + break + # If the last character of the previous match is a whitespace + # character, that character may be
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/scan/ebuild/, repoman/pym/repoman/
commit: cea895f75fe43e61042da591b1e77f9d0ea2c6ae Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:09:03 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:40 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=cea895f7 repoman: Convert multicheck module to the new linechecks sub-module repoman/pym/repoman/modules/scan/ebuild/__init__.py | 2 +- repoman/pym/repoman/modules/scan/ebuild/multicheck.py | 10 +++--- repoman/pym/repoman/scanner.py| 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/repoman/pym/repoman/modules/scan/ebuild/__init__.py b/repoman/pym/repoman/modules/scan/ebuild/__init__.py index 3e1d31951..1d8ec1941 100644 --- a/repoman/pym/repoman/modules/scan/ebuild/__init__.py +++ b/repoman/pym/repoman/modules/scan/ebuild/__init__.py @@ -47,7 +47,7 @@ module_spec = { 'functions': ['check'], 'func_kwargs': { }, - 'mod_kwargs': ['qatracker', 'options' + 'mod_kwargs': ['qatracker', 'options', 'repo_settings', 'linechecks', ], 'func_kwargs': { 'ebuild': (None, None), diff --git a/repoman/pym/repoman/modules/scan/ebuild/multicheck.py b/repoman/pym/repoman/modules/scan/ebuild/multicheck.py index 9e36e2a68..94526ae9e 100644 --- a/repoman/pym/repoman/modules/scan/ebuild/multicheck.py +++ b/repoman/pym/repoman/modules/scan/ebuild/multicheck.py @@ -8,7 +8,7 @@ import io from portage import _encodings, _unicode_encode from repoman.modules.scan.scanbase import ScanBase -from .checks import run_checks, checks_init +from repoman.modules.linechecks.controller import LineCheckController class MultiCheck(ScanBase): @@ -22,7 +22,11 @@ class MultiCheck(ScanBase): ''' self.qatracker = kwargs.get('qatracker') self.options = kwargs.get('options') - checks_init(self.options.experimental_inherit == 'y') + self.controller = LineCheckController( + kwargs.get('repo_settings'), + kwargs.get('linechecks') + ) + self.controller.checks_init(self.options.experimental_inherit == 'y') def check(self, **kwargs): '''Check the ebuild for utf-8 encoding @@ -40,7 +44,7 @@ class MultiCheck(ScanBase): errors='strict'), mode='r', encoding=_encodings['repo.content']) try: - for check_name, e in run_checks(f, pkg): + for check_name, e in self.controller.run_checks(f, pkg): self.qatracker.add_error( check_name, ebuild.relative_path + ': %s' % e) finally: diff --git a/repoman/pym/repoman/scanner.py b/repoman/pym/repoman/scanner.py index b3d030570..d61e50131 100644 --- a/repoman/pym/repoman/scanner.py +++ b/repoman/pym/repoman/scanner.py @@ -193,6 +193,7 @@ class Scanner(object): "env": self.env, "have": self.have, "dev_keywords": self.dev_keywords, + "linechecks": self.moduleconfig.linechecks, } # initialize the plugin checks here self.modules = {}
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/useless/
commit: 588d47fd91ed5637d6a641d1e2ef39b80b5780f8 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:06:38 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:39 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=588d47fd repoman: New linechecks module, useless .../repoman/modules/linechecks/useless/__init__.py | 27 ++ .../pym/repoman/modules/linechecks/useless/cd.py | 24 +++ .../repoman/modules/linechecks/useless/dodoc.py| 16 + 3 files changed, 67 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/useless/__init__.py b/repoman/pym/repoman/modules/linechecks/useless/__init__.py new file mode 100644 index 0..acc4479f5 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/useless/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Useless plug-in module for repoman LineChecks. +Performs checks for useless operations on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'uselesscds-check': { + 'name': "uselesscds", + 'sourcefile': "cd", + 'class': "EbuildUselessCdS", + 'description': doc, + }, + 'uselessdodoc-check': { + 'name': "uselessdodoc", + 'sourcefile': "dodoc", + 'class': "EbuildUselessDodoc", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/useless/cd.py b/repoman/pym/repoman/modules/linechecks/useless/cd.py new file mode 100644 index 0..3daa04451 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/useless/cd.py @@ -0,0 +1,24 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildUselessCdS(LineCheck): + """Check for redundant cd ${S} statements""" + repoman_check_name = 'ebuild.minorsyn' + _src_phases = r'^\s*src_(prepare|configure|compile|install|test)\s*\(\)' + method_re = re.compile(_src_phases) + cds_re = re.compile(r'^\s*cd\s+("\$(\{S\}|S)"|\$(\{S\}|S))\s') + + def __init__(self, errors): + self.errors = errors + self.check_next_line = False + + def check(self, num, line): + if self.check_next_line: + self.check_next_line = False + if self.cds_re.match(line): + return self.errors['REDUNDANT_CD_S_ERROR'] + elif self.method_re.match(line): + self.check_next_line = True diff --git a/repoman/pym/repoman/modules/linechecks/useless/dodoc.py b/repoman/pym/repoman/modules/linechecks/useless/dodoc.py new file mode 100644 index 0..502bfbea8 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/useless/dodoc.py @@ -0,0 +1,16 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildUselessDodoc(LineCheck): + """Check ebuild for useless files in dodoc arguments.""" + repoman_check_name = 'ebuild.minorsyn' + uselessdodoc_re = re.compile( + r'^\s*dodoc(\s+|\s+.*\s+)(ABOUT-NLS|COPYING|LICENCE|LICENSE)($|\s)') + + def check(self, num, line): + match = self.uselessdodoc_re.match(line) + if match: + return "Useless dodoc '%s'" % (match.group(2), ) + " on line: %d"
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/nested/
commit: ad1f6f06b3846881244aa98bf24f293290ca5599 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:02:24 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:39 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=ad1f6f06 repoman: New linechecks module, nested .../repoman/modules/linechecks/nested/__init__.py | 21 + .../pym/repoman/modules/linechecks/nested/nested.py | 15 +++ .../repoman/modules/linechecks/nested/nesteddie.py | 11 +++ 3 files changed, 47 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/nested/__init__.py b/repoman/pym/repoman/modules/linechecks/nested/__init__.py new file mode 100644 index 0..8eeeccbac --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/nested/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Nested plug-in module for repoman LineChecks. +Performs nested subshell checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'nesteddie-check': { + 'name': "nesteddie", + 'sourcefile': "nested", + 'class': "EbuildNestedDie", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/nested/nested.py b/repoman/pym/repoman/modules/linechecks/nested/nested.py new file mode 100644 index 0..06b272772 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/nested/nested.py @@ -0,0 +1,15 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildNestedDie(LineCheck): + """Check ebuild for nested die statements (die statements in subshells)""" + + repoman_check_name = 'ebuild.nesteddie' + nesteddie_re = re.compile(r'^[^#]*\s\(\s[^)]*\bdie\b') + + def check(self, num, line): + if self.nesteddie_re.match(line): + return self.errors['NESTED_DIE_ERROR'] diff --git a/repoman/pym/repoman/modules/linechecks/nested/nesteddie.py b/repoman/pym/repoman/modules/linechecks/nested/nesteddie.py new file mode 100644 index 0..6c1e4be9f --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/nested/nesteddie.py @@ -0,0 +1,11 @@ + + +class EbuildNestedDie(LineCheck): + """Check ebuild for nested die statements (die statements in subshells)""" + + repoman_check_name = 'ebuild.nesteddie' + nesteddie_re = re.compile(r'^[^#]*\s\(\s[^)]*\bdie\b') + + def check(self, num, line): + if self.nesteddie_re.match(line): + return errors.NESTED_DIE_ERROR
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/phases/
commit: b05011a66a3f3275d81f0042fe5825fbec09985e Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:03:33 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:39 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=b05011a6 repoman: New linechecks module, phases .../repoman/modules/linechecks/phases/__init__.py | 34 +++ .../pym/repoman/modules/linechecks/phases/phase.py | 71 ++ 2 files changed, 105 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/phases/__init__.py b/repoman/pym/repoman/modules/linechecks/phases/__init__.py new file mode 100644 index 0..476443b25 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/phases/__init__.py @@ -0,0 +1,34 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Phases plug-in module for repoman LineChecks. +Performs phase dependant checks on ebuilds using a PhaseCheck base class. +""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'emakeparallel-check': { + 'name': "emakeparallel", + 'sourcefile': "phase", + 'class': "EMakeParallelDisabled", + 'description': doc, + }, + 'srccompileeconf-check': { + 'name': "srccompileeconf", + 'sourcefile': "phase", + 'class': "SrcCompileEconf", + 'description': doc, + }, + 'srcunpackpatches-check': { + 'name': "srcunpackpatches", + 'sourcefile': "phase", + 'class': "SrcUnpackPatches", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/phases/phase.py b/repoman/pym/repoman/modules/linechecks/phases/phase.py new file mode 100644 index 0..acc3a1e1d --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/phases/phase.py @@ -0,0 +1,71 @@ + +import re + +from portage.eapi import eapi_has_src_prepare_and_src_configure +from repoman.modules.linechecks.base import LineCheck + + +class PhaseCheck(LineCheck): + """ basic class for function detection """ + + func_end_re = re.compile(r'^\}$') + phases_re = re.compile('(%s)' % '|'.join(( + 'pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare', + 'src_configure', 'src_compile', 'src_test', 'src_install', + 'pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm', + 'pkg_config'))) + in_phase = '' + + def check(self, num, line): + m = self.phases_re.match(line) + if m is not None: + self.in_phase = m.group(1) + if self.in_phase != '' and self.func_end_re.match(line) is not None: + self.in_phase = '' + + return self.phase_check(num, line) + + def phase_check(self, num, line): + """ override this function for your checks """ + pass + + +class EMakeParallelDisabled(PhaseCheck): + """Check for emake -j1 calls which disable parallelization.""" + repoman_check_name = 'upstream.workaround' + re = re.compile(r'^\s*emake\s+.*-j\s*1\b') + + def phase_check(self, num, line): + if self.in_phase == 'src_compile' or self.in_phase == 'src_install': + if self.re.match(line): + return self.errors['EMAKE_PARALLEL_DISABLED'] + + +class SrcCompileEconf(PhaseCheck): + repoman_check_name = 'ebuild.minorsyn' + configure_re = re.compile(r'\s(econf|./configure)') + + def check_eapi(self, eapi): + return eapi_has_src_prepare_and_src_configure(eapi) + + def phase_check(self, num, line): + if self.in_phase == 'src_compile': + m = self.configure_re.match(line) + if m is not None: + return ("'%s'" % m.group(1)) + \ + " call should be moved to src_configure from line: %d" + + +class SrcUnpackPatches(PhaseCheck): + repoman_check_name = 'ebuild.minorsyn' + src_prepare_tools_re = re.compile(r'\s(e?patch|sed)\s') + + def check_eapi(self, eapi): + return eapi_has_src_prepare_and_src_configure(eapi) + + def phase_check(self, num, line): + if self.in_phase == 'src_unpack': + m = self.src_prepare_tools_re.search(line) + if m is not None: + return ("'%s'" % m.group(1)) + \ + " call should be moved to src_prepare from line: %d"
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/patches/
commit: 2173625e86de6ac66c68d4a8dd284885363ca376 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:02:58 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Thu Mar 29 20:43:39 2018 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=2173625e repoman: New linechecks module, patches .../repoman/modules/linechecks/patches/__init__.py | 21 + .../repoman/modules/linechecks/patches/patches.py | 16 2 files changed, 37 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/patches/__init__.py b/repoman/pym/repoman/modules/linechecks/patches/__init__.py new file mode 100644 index 0..67434f911 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/patches/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Patches plug-in module for repoman LineChecks. +Performs PATCHES variable checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'patches-check': { + 'name': "patches", + 'sourcefile': "patches", + 'class': "EbuildPatches", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/patches/patches.py b/repoman/pym/repoman/modules/linechecks/patches/patches.py new file mode 100644 index 0..63651cd7c --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/patches/patches.py @@ -0,0 +1,16 @@ + + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildPatches(LineCheck): + """Ensure ebuilds use bash arrays for PATCHES to ensure white space safety""" + repoman_check_name = 'ebuild.patches' + re = re.compile(r'^\s*PATCHES=[^\(]') + error = 'PATCHES_ERROR' + + def check_eapi(self, eapi): + return eapi in ("0", "1", "2", "3", "4", "4-python", + "4-slot-abi", "5", "5-hdepend", "5-progress")
[gentoo-commits] proj/portage:repoman commit in: repoman/cnf/qa_data/, repoman/pym/repoman/
commit: 21355477e10440e8eb31ef1a22bdeb2c651f833e Author: Brian Dolbec gentoo org> AuthorDate: Tue Dec 5 18:16:44 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:28 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=21355477 repoman qa_data.py: Move the qahelp loading to a new /usr/share/repoman/qa_data directory This new directory can be installed to by third party add on modules that extend the checks. We can also in future use these file to get loaclized translations. repoman/cnf/qa_data/qa_data.yaml | 138 +++ repoman/pym/repoman/qa_data.py | 19 +- 2 files changed, 154 insertions(+), 3 deletions(-) diff --git a/repoman/cnf/qa_data/qa_data.yaml b/repoman/cnf/qa_data/qa_data.yaml new file mode 100644 index 0..c3ce8a4f9 --- /dev/null +++ b/repoman/cnf/qa_data/qa_data.yaml @@ -0,0 +1,138 @@ +--- +# qa_help.yaml + +# configuration file for the LineCheck plugins run via the multicheck +# scan module + +# Repoman API version (do not edit) +version: 1 +# minimum +repoman_version: 2.3.3 + +# qahelp: Primary QA help messages to describe the errors or warnings +# Dictionary +qahelp: +Entries: +IO_error: "Attempting to commit, and an IO error was encountered access the Entries file" +ebuild: +invalidname: "Ebuild files with a non-parseable or syntactically incorrect name (or using 2.1 versioning extensions)" +namenomatch: "Ebuild files that do not have the same name as their parent directory" +notadded: "Ebuilds that exist but have not been added to the vcs" +patches: "PATCHES variable should be a bash array to ensure white space safety" +changelog: +ebuildadded: "An ebuild was added but the ChangeLog was not modified" +missing: "Missing ChangeLog files" +notadded: "ChangeLogs that exist but have not been added to cvs" +dependency: +bad: "User-visible ebuilds with unsatisfied dependencies (matched against *visible* ebuilds)" +badmasked: "Masked ebuilds with unsatisfied dependencies (matched against *all* ebuilds)" +badindev: "User-visible ebuilds with unsatisfied dependencies (matched against *visible* ebuilds) in developing arch" +badmaskedindev: Masked ebuilds with unsatisfied dependencies (matched against *all* ebuilds) in developing arch" +badtilde: "Uses the ~ dep operator with a non-zero revision part, which is useless (the revision is ignored)" +missingslot: "RDEPEND matches more than one SLOT but does not specify a slot and/or use the := or :* slot operator" +perlcore: "This ebuild directly depends on a package in perl-core; it should use the corresponding virtual instead." +syntax: "Syntax error in dependency string (usually an extra/missing space/parenthesis)" +unknown: "Ebuild has a dependency that refers to an unknown package (which may be valid if it is a blocker for a renamed/removed package, or is an alternative choice provided by an overlay)" +badslotop: "RDEPEND contains ':=' slot operator under '||' dependency." +DESCRIPTION: +missing: "Ebuilds that have a missing or empty DESCRIPTION variable" +toolong: "DESCRIPTION is over %d characters" +digest: +assumed: "Existing digest must be assumed correct (Package level only)" +missing: "Some files listed in SRC_URI aren't referenced in the Manifest" +unused: "Some files listed in the Manifest aren't referenced in SRC_URI" +EAPI: +definition: "EAPI definition does not conform to PMS section 7.3.1 (first non-comment, non-blank line)" +deprecated: "Ebuilds that use features that are deprecated in the current EAPI" +incompatible: "Ebuilds that use features that are only available with a different EAPI" +unsupported: "Ebuilds that have an unsupported EAPI version (you must upgrade portage)" +ebuild: +absdosym: "This ebuild uses absolute target to dosym where relative symlink could be used instead" +badheader: "This ebuild has a malformed header" +majorsyn: "This ebuild has a major syntax error that may cause the ebuild to fail partially or fully" +minorsyn: "This ebuild has a minor syntax error that contravenes gentoo coding style" +nesteddie: "Placing 'die' inside ( ) prints an error, but doesn't stop the ebuild." +output: "A simple sourcing of the ebuild produces output; this breaks ebuild policy." +syntax: "Error generating cache entry for ebuild; typically caused by ebuild syntax error or digest verification failure" +file: +executable: "Ebuilds, digests, metadata.xml, Manifest, and ChangeLog do not need the executable bit" +size: "Files in the files directory must be under 20 KiB" +size-fatal: "Files in the files directory must be under 60 KiB" +empty: "Empty file in
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/quotes/
commit: 7eed84f7c4c01b85583681c6d2c895739f6f41af Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:04:31 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:27 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=7eed84f7 repoman: New linechecks module, quotes .../repoman/modules/linechecks/quotes/__init__.py | 27 +++ .../repoman/modules/linechecks/quotes/quoteda.py | 16 .../repoman/modules/linechecks/quotes/quotes.py| 86 ++ 3 files changed, 129 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/quotes/__init__.py b/repoman/pym/repoman/modules/linechecks/quotes/__init__.py new file mode 100644 index 0..6043ab20c --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/quotes/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Nested plug-in module for repoman LineChecks. +Performs nested subshell checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'quote-check': { + 'name': "quote", + 'sourcefile': "quotes", + 'class': "EbuildQuote", + 'description': doc, + }, + 'quoteda-check': { + 'name': "quoteda", + 'sourcefile': "quoteda", + 'class': "EbuildQuotedA", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/quotes/quoteda.py b/repoman/pym/repoman/modules/linechecks/quotes/quoteda.py new file mode 100644 index 0..7fd9ba797 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/quotes/quoteda.py @@ -0,0 +1,16 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildQuotedA(LineCheck): + """Ensure ebuilds have no quoting around ${A}""" + + repoman_check_name = 'ebuild.minorsyn' + a_quoted = re.compile(r'.*\"\$(\{A\}|A)\"') + + def check(self, num, line): + match = self.a_quoted.match(line) + if match: + return "Quoted \"${A}\" on line: %d" diff --git a/repoman/pym/repoman/modules/linechecks/quotes/quotes.py b/repoman/pym/repoman/modules/linechecks/quotes/quotes.py new file mode 100644 index 0..68c594e23 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/quotes/quotes.py @@ -0,0 +1,86 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildQuote(LineCheck): + """Ensure ebuilds have valid quoting around things like D,FILESDIR, etc...""" + + repoman_check_name = 'ebuild.minorsyn' + _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+)') + ignore_comment = False + var_names = ["D", "DISTDIR", "FILESDIR", "S", "T", "ROOT", "WORKDIR"] + + # EAPI=3/Prefix vars + var_names += ["ED", "EPREFIX", "EROOT"] + + # variables for games.eclass + var_names += [ + "Ddir", "GAMES_PREFIX_OPT", "GAMES_DATADIR", + "GAMES_DATADIR_BASE", "GAMES_SYSCONFDIR", "GAMES_STATEDIR", + "GAMES_LOGDIR", "GAMES_BINDIR"] + + # variables for multibuild.eclass + var_names += ["BUILD_DIR"] + + var_names = "(%s)" % "|".join(var_names) + var_reference = re.compile( + r'\$(\{%s\}|%s\W)' % (var_names, var_names)) + missing_quotes = re.compile( + r'(\s|^)[^"\'\s]*\$\{?%s\}?[^"\'\s]*(\s|$)' % var_names) + cond_begin = re.compile(r'(^|\s+)\[\[($|\\$|\s+)') + cond_end = re.compile(r'(^|\s+)\]\]($|\\$|\s+)') + + def check(self, num, line): + if self.var_reference.search(line) is None: + return + # There can be multiple matches / violations on a single line. We + # have to make sure none of the matches are violators. Once we've + # found one violator, any remaining matches on the same line can + # be ignored. + pos = 0 + while pos <= len(line) - 1: + missing_quotes = self.missing_quotes.search(line, pos) + if not missing_quotes: + break + # If the last character of the previous match is a whitespace + # character, that character may be
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/workaround/
commit: e815df3f77d30338a6fc835cdc2f3533e93ab958 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:07:59 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:28 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=e815df3f repoman: New linechecks module, workaround .../modules/linechecks/workaround/__init__.py | 27 ++ .../modules/linechecks/workaround/workarounds.py | 18 +++ 2 files changed, 45 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/workaround/__init__.py b/repoman/pym/repoman/modules/linechecks/workaround/__init__.py new file mode 100644 index 0..0b5aa70c8 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/workaround/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Workaround plug-in module for repoman LineChecks. +Performs checks for upstream workarounds in ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'addpredict-check': { + 'name': "addpredict", + 'sourcefile': "workarounds", + 'class': "SandboxAddpredict", + 'description': doc, + }, + 'noasneeded-check': { + 'name': "noasneeded", + 'sourcefile': "workarounds", + 'class': "NoAsNeeded", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/workaround/workarounds.py b/repoman/pym/repoman/modules/linechecks/workaround/workarounds.py new file mode 100644 index 0..37cb54314 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/workaround/workarounds.py @@ -0,0 +1,18 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class NoAsNeeded(LineCheck): + """Check for calls to the no-as-needed function.""" + repoman_check_name = 'upstream.workaround' + re = re.compile(r'.*\$\(no-as-needed\)') + error = 'NO_AS_NEEDED' + + +class SandboxAddpredict(LineCheck): + """Check for calls to the addpredict function.""" + repoman_check_name = 'upstream.workaround' + re = re.compile(r'(^|\s)addpredict\b') + error = 'SANDBOX_ADDPREDICT'
[gentoo-commits] proj/portage:repoman commit in: pym/portage/
commit: 12f83daec005e3004a249b2e2ad600e47ae2c496 Author: Brian Dolbec gentoo org> AuthorDate: Thu Aug 17 01:50:21 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:28 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=12f83dae module.py: Extend the module loader for API version checking If provided with an iterable of compatibility versions, The controller will check the plugin modules module_spec 'version' variable is compatible with the base application. pym/portage/module.py | 22 -- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pym/portage/module.py b/pym/portage/module.py index c79e65518..bd7c94d4e 100644 --- a/pym/portage/module.py +++ b/pym/portage/module.py @@ -15,6 +15,10 @@ class InvalidModuleName(PortageException): """An invalid or unknown module name.""" +class ModuleVersionError(PortageException): + '''An incompatible module version''' + + class Module(object): """Class to define and hold our plug-in module @@ -87,16 +91,17 @@ class Modules(object): @param namepath: Python import path to the "modules" directory """ - def __init__(self, path, namepath): + def __init__(self, path, namepath, compat_versions=None): self._module_path = path self._namepath = namepath + self.compat_versions = compat_versions self.parents = [] self._modules = self._get_all_modules() self.modules = ProtectedDict(self._modules) self.module_names = sorted(self._modules) def _get_all_modules(self): - """scans the emaint modules dir for loadable modules + """scans the _module_path dir for loadable modules @rtype: dictionary of module_plugins """ @@ -117,6 +122,7 @@ class Modules(object): kids = {} for entry in importables: new_module = Module(entry, self._namepath) + self._check_compat(new_module) for module_name in new_module.kids: kid = new_module.kids[module_name] kid['parent'] = new_module @@ -211,6 +217,8 @@ class Modules(object): @type modname: string @param modname: the module class name + @type var: string + @param var: the base level variable to return @type dictionary @return: the modules class exported options descriptions """ @@ -220,3 +228,13 @@ class Modules(object): raise InvalidModuleName( "Module name '%s' is invalid or not found" % modname) return value + + def _check_compat(self, module): + if self.compat_versions: + if not module.module_spec['version'] in self.compat_versions: + raise ModuleVersionError( + "Error loading '%s' plugin module: %s, version: %s\n" + "Module is not compatible with the current application version\n" + "Compatible module API versions are: %s" + % (self._namepath, module.module_spec['name'], + module.module_spec['version'], self.compat_versions))
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/portage/
commit: b6243511e8294226837e75a5449960c649ad258e Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:04:00 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:27 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=b6243511 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 0..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 0..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
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/gentoo_header/
commit: 36dcdb2914ae040b1a9b85f83ea761488011239a Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:01:04 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:27 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=36dcdb29 repoman: New linechecks module, gentoo_header .../modules/linechecks/gentoo_header/__init__.py | 21 ++ .../modules/linechecks/gentoo_header/header.py | 49 ++ 2 files changed, 70 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py b/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py new file mode 100644 index 0..b80a83ecf --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Gentoo-header plug-in module for repoman LineChecks. +Performs header checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'header-check': { + 'name': "gentooheader", + 'sourcefile': "header", + 'class': "EbuildHeader", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py b/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py new file mode 100644 index 0..4b75fc4b5 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py @@ -0,0 +1,49 @@ + +import re +import time + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildHeader(LineCheck): + """Ensure ebuilds have proper headers + Copyright header errors + CVS header errors + License header errors + + Args: + modification_year - Year the ebuild was last modified + """ + + repoman_check_name = 'ebuild.badheader' + + gentoo_copyright = r'^# Copyright ((1999|2\d\d\d)-)?%s Gentoo Foundation$' + gentoo_license = ( + '# Distributed under the terms' + ' of the GNU General Public License v2') + id_header_re = re.compile(r'.*\$(Id|Header)(:.*)?\$.*') + blank_line_re = re.compile(r'^$') + ignore_comment = False + + def new(self, pkg): + if pkg.mtime is None: + self.modification_year = r'2\d\d\d' + else: + self.modification_year = str(time.gmtime(pkg.mtime)[0]) + self.gentoo_copyright_re = re.compile( + self.gentoo_copyright % self.modification_year) + + def check(self, num, line): + if num > 2: + return + elif num == 0: + if not self.gentoo_copyright_re.match(line): + return self.errors['COPYRIGHT_ERROR'] + elif num == 1 and line.rstrip('\n') != self.gentoo_license: + return self.errors['LICENSE_ERROR'] + elif num == 2 and self.id_header_re.match(line): + return self.errors['ID_HEADER_ERROR'] + elif num == 2 and not self.blank_line_re.match(line): + return self.errors['NO_BLANK_LINE_ERROR'] + +
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/helpers/
commit: b08b55e65daa058eec6958609869e534d6f78d70 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:01:52 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:27 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=b08b55e6 repoman: New linechecks module, helpers .../repoman/modules/linechecks/helpers/__init__.py | 21 + .../repoman/modules/linechecks/helpers/offset.py | 22 ++ 2 files changed, 43 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/helpers/__init__.py b/repoman/pym/repoman/modules/linechecks/helpers/__init__.py new file mode 100644 index 0..e2d12afe4 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/helpers/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Helpers plug-in module for repoman LineChecks. +Performs variable helpers checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'nooffset-check': { + 'name': "nooffset", + 'sourcefile': "offset", + 'class': "NoOffsetWithHelpers", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/helpers/offset.py b/repoman/pym/repoman/modules/linechecks/helpers/offset.py new file mode 100644 index 0..5d7624a68 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/helpers/offset.py @@ -0,0 +1,22 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class NoOffsetWithHelpers(LineCheck): + """ Check that the image location, the alternate root offset, and the + offset prefix (D, ROOT, ED, EROOT and EPREFIX) are not used with + helpers """ + + repoman_check_name = 'variable.usedwithhelpers' + # Ignore matches in quoted strings like this: + # elog "installed into ${ROOT}usr/share/php5/apc/." + _install_funcs = ( + 'docinto|do(compress|dir|hard)' + '|exeinto|fowners|fperms|insinto|into') + _quoted_vars = 'D|ROOT|ED|EROOT|EPREFIX' + re = re.compile( + r'^[^#"\']*\b(%s)\s+"?\$\{?(%s)\b.*' % + (_install_funcs, _quoted_vars)) + error = 'NO_OFFSET_WITH_HELPERS'
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/phases/
commit: 1f71fd1c7ddb9e0a05db678e8b127716f00432ff Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:03:33 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:27 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=1f71fd1c repoman: New linechecks module, phases .../repoman/modules/linechecks/phases/__init__.py | 34 +++ .../pym/repoman/modules/linechecks/phases/phase.py | 71 ++ 2 files changed, 105 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/phases/__init__.py b/repoman/pym/repoman/modules/linechecks/phases/__init__.py new file mode 100644 index 0..476443b25 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/phases/__init__.py @@ -0,0 +1,34 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Phases plug-in module for repoman LineChecks. +Performs phase dependant checks on ebuilds using a PhaseCheck base class. +""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'emakeparallel-check': { + 'name': "emakeparallel", + 'sourcefile': "phase", + 'class': "EMakeParallelDisabled", + 'description': doc, + }, + 'srccompileeconf-check': { + 'name': "srccompileeconf", + 'sourcefile': "phase", + 'class': "SrcCompileEconf", + 'description': doc, + }, + 'srcunpackpatches-check': { + 'name': "srcunpackpatches", + 'sourcefile': "phase", + 'class': "SrcUnpackPatches", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/phases/phase.py b/repoman/pym/repoman/modules/linechecks/phases/phase.py new file mode 100644 index 0..acc3a1e1d --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/phases/phase.py @@ -0,0 +1,71 @@ + +import re + +from portage.eapi import eapi_has_src_prepare_and_src_configure +from repoman.modules.linechecks.base import LineCheck + + +class PhaseCheck(LineCheck): + """ basic class for function detection """ + + func_end_re = re.compile(r'^\}$') + phases_re = re.compile('(%s)' % '|'.join(( + 'pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare', + 'src_configure', 'src_compile', 'src_test', 'src_install', + 'pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm', + 'pkg_config'))) + in_phase = '' + + def check(self, num, line): + m = self.phases_re.match(line) + if m is not None: + self.in_phase = m.group(1) + if self.in_phase != '' and self.func_end_re.match(line) is not None: + self.in_phase = '' + + return self.phase_check(num, line) + + def phase_check(self, num, line): + """ override this function for your checks """ + pass + + +class EMakeParallelDisabled(PhaseCheck): + """Check for emake -j1 calls which disable parallelization.""" + repoman_check_name = 'upstream.workaround' + re = re.compile(r'^\s*emake\s+.*-j\s*1\b') + + def phase_check(self, num, line): + if self.in_phase == 'src_compile' or self.in_phase == 'src_install': + if self.re.match(line): + return self.errors['EMAKE_PARALLEL_DISABLED'] + + +class SrcCompileEconf(PhaseCheck): + repoman_check_name = 'ebuild.minorsyn' + configure_re = re.compile(r'\s(econf|./configure)') + + def check_eapi(self, eapi): + return eapi_has_src_prepare_and_src_configure(eapi) + + def phase_check(self, num, line): + if self.in_phase == 'src_compile': + m = self.configure_re.match(line) + if m is not None: + return ("'%s'" % m.group(1)) + \ + " call should be moved to src_configure from line: %d" + + +class SrcUnpackPatches(PhaseCheck): + repoman_check_name = 'ebuild.minorsyn' + src_prepare_tools_re = re.compile(r'\s(e?patch|sed)\s') + + def check_eapi(self, eapi): + return eapi_has_src_prepare_and_src_configure(eapi) + + def phase_check(self, num, line): + if self.in_phase == 'src_unpack': + m = self.src_prepare_tools_re.search(line) + if m is not None: + return ("'%s'" % m.group(1)) + \ + " call should be moved to src_prepare from line: %d"
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/tests/
commit: f78eb978cd14d5a5ea5657e48edd3f15a27158e2 Author: El Acheche Anis ubuntu com> AuthorDate: Mon Jul 24 04:49:26 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:28 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=f78eb978 repoman: repoman/pym/repoman/tests/runTests.py: Fix PEP8 E261 repoman/pym/repoman/tests/runTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repoman/pym/repoman/tests/runTests.py b/repoman/pym/repoman/tests/runTests.py index 1795aa487..ca37b14b3 100644 --- a/repoman/pym/repoman/tests/runTests.py +++ b/repoman/pym/repoman/tests/runTests.py @@ -17,7 +17,7 @@ def debug_signal(signum, frame): pdb.set_trace() if platform.python_implementation() == 'Jython': - debug_signum = signal.SIGUSR2 # bug #424259 + debug_signum = signal.SIGUSR2 # bug #424259 else: debug_signum = signal.SIGUSR1
[gentoo-commits] proj/portage:repoman commit in: repoman/
commit: 3c0b08d8a42038bba777d831057e6936a27ba76e Author: Brian Dolbec gentoo org> AuthorDate: Tue Dec 5 18:22:33 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:28 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=3c0b08d8 repoman setup.py: Add the new cnf/qa_data cnf/linechecks items repoman/setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/repoman/setup.py b/repoman/setup.py index c22a5c305..a667b8a6b 100755 --- a/repoman/setup.py +++ b/repoman/setup.py @@ -479,6 +479,8 @@ setup( data_files = list(get_manpages()) + [ ['$docdir', ['NEWS', 'RELEASE-NOTES']], + ['share/repoman/qa_data', ['cnf/qa_data/qa_data.yaml']], + ['share/repoman/linechecks', ['cnf/linechecks/linechecks.yaml']], ], cmdclass = {
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/tests/
commit: d3193aa183fc6c621011251776f086c4f82baa9c Author: El Acheche Anis ubuntu com> AuthorDate: Mon Jul 24 04:46:28 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:28 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d3193aa1 repoman: repoman/pym/repoman/tests/runTests.py: Fix PEP8 E401 repoman/pym/repoman/tests/runTests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/repoman/pym/repoman/tests/runTests.py b/repoman/pym/repoman/tests/runTests.py index 759abdd82..3125ff058 100644 --- a/repoman/pym/repoman/tests/runTests.py +++ b/repoman/pym/repoman/tests/runTests.py @@ -3,7 +3,8 @@ # Copyright 2006-2017 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -import os, sys +import os +import sys import os.path as osp import grp import platform
[gentoo-commits] proj/portage:repoman commit in: repoman/cnf/linechecks/, repoman/pym/repoman/modules/linechecks/
commit: 4ad8650172a071de1a3778f10680f74bd191dec9 Author: Brian Dolbec gentoo org> AuthorDate: Tue Dec 5 18:17:15 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:28 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=4ad86501 repoman linechecks/config.py: Move the errors loading to a new /usr/share/repoman/linechecks directory This new directory can be installed to by third party add on modules that extend the checks. We can also in future use these file to get loaclized translations. repoman/cnf/linechecks/linechecks.yaml | 35 repoman/pym/repoman/modules/linechecks/config.py | 19 +++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/repoman/cnf/linechecks/linechecks.yaml b/repoman/cnf/linechecks/linechecks.yaml new file mode 100644 index 0..634381e80 --- /dev/null +++ b/repoman/cnf/linechecks/linechecks.yaml @@ -0,0 +1,35 @@ +--- +# linecheck_help.yaml + +# Repoman API version (do not edit) +version: 1 +# minimum +repoman_version: 2.3.3 + +# configuration file for the LineCheck plugins run via the multicheck +# scan module +errors: +COPYRIGHT_ERROR: 'Invalid Gentoo Copyright on line: %d' +LICENSE_ERROR: 'Invalid Gentoo/GPL License on line: %d' +ID_HEADER_ERROR: 'Stale CVS header on line: %d' +NO_BLANK_LINE_ERROR: 'Non-blank line after header on line: %d' +LEADING_SPACES_ERROR: 'Ebuild contains leading spaces on line: %d' +TRAILING_WHITESPACE_ERROR: 'Trailing whitespace error on line: %d' +READONLY_ASSIGNMENT_ERROR: 'Ebuild contains assignment to read-only variable on line: %d' +MISSING_QUOTES_ERROR: 'Unquoted Variable on line: %d' +NESTED_DIE_ERROR: 'Ebuild calls die in a subshell on line: %d' +PATCHES_ERROR: 'PATCHES is not a bash array on line: %d' +REDUNDANT_CD_S_ERROR: 'Ebuild has redundant cd ${S} statement on line: %d' +EMAKE_PARALLEL_DISABLED: 'Upstream parallel compilation bug (ebuild calls emake -j1 on line: %d)' +EMAKE_PARALLEL_DISABLED_VIA_MAKEOPTS: 'Upstream parallel compilation bug (MAKEOPTS=-j1 on line: %d)' +DEPRECATED_BINDNOW_FLAGS: 'Deprecated bindnow-flags call on line: %d' +EAPI_DEFINED_AFTER_INHERIT: 'EAPI defined after inherit on line: %d' +NO_AS_NEEDED: 'Upstream asneeded linking bug (no-as-needed on line: %d)' +PRESERVE_OLD_LIB: 'Ebuild calls deprecated preserve_old_lib on line: %d' +BUILT_WITH_USE: 'built_with_use on line: %d' +NO_OFFSET_WITH_HELPERS: 'Helper function is used with D, ROOT, ED, EROOT or EPREFIX on line: %d' +SANDBOX_ADDPREDICT: 'Ebuild calls addpredict on line: %d' +USEQ_ERROR: 'Ebuild calls deprecated useq function on line: %d' +HASQ_ERROR: 'Ebuild calls deprecated hasq function on line: %d' +URI_HTTPS: 'Ebuild uses http:// but should use https:// on line: %d' + diff --git a/repoman/pym/repoman/modules/linechecks/config.py b/repoman/pym/repoman/modules/linechecks/config.py index 9190b18cf..96a27ac49 100644 --- a/repoman/pym/repoman/modules/linechecks/config.py +++ b/repoman/pym/repoman/modules/linechecks/config.py @@ -15,6 +15,7 @@ from copy import deepcopy from repoman._portage import portage from repoman.config import load_config +from repoman import _not_installed # Avoid a circular import issue in py2.7 portage.proxy.lazyimport.lazyimport(globals(), @@ -46,8 +47,7 @@ class LineChecksConfig(object): @param configpaths: ordered list of filepaths to load ''' self.repo_settings = repo_settings - self.infopaths = [os.path.join(path, 'linechecks.yaml') for path in self.repo_settings.masters_list] - logging.debug("LineChecksConfig; configpaths: %s", self.infopaths) + self.infopaths = None self.info_config = None self._config = None self.usex_supported_eapis = None @@ -58,8 +58,22 @@ class LineChecksConfig(object): self.eclass_info = {} self.eclass_info_experimental_inherit = {} self.errors = {} + self.set_infopaths() self.load_checks_info() + def set_infopaths(self): + if _not_installed: + cnfdir = os.path.realpath(os.path.join(os.path.dirname( + os.path.dirname(os.path.dirname(os.path.dirname( + os.path.dirname(__file__), 'cnf/linechecks')) + else: + cnfdir = os.path.join(portage.const.EPREFIX or '/', 'usr/share/repoman/linechecks') + repomanpaths = [os.path.join(cnfdir, _file_) for _file_ in os.listdir(cnfdir)] + logging.debug("LineChecksConfig; repomanpaths: %s", repomanpaths) + repopaths = [os.path.join(path, 'linechecks.yaml') for path in self.repo_settings.masters_list] + self.infopaths = repomanpaths +
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/whitespace/
commit: 2b82ca71f0d297a375ff257f3bb18dcd14fc063c Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:07:13 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:28 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=2b82ca71 repoman: New linechecks module, whitespace .../modules/linechecks/whitespace/__init__.py | 27 ++ .../repoman/modules/linechecks/whitespace/blank.py | 25 .../modules/linechecks/whitespace/whitespace.py| 21 + 3 files changed, 73 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/whitespace/__init__.py b/repoman/pym/repoman/modules/linechecks/whitespace/__init__.py new file mode 100644 index 0..ded690ed7 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/whitespace/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Whitespace plug-in module for repoman LineChecks. +Performs checks for useless whitespace in ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'whitespace-check': { + 'name': "whitespace", + 'sourcefile': "whitespace", + 'class': "EbuildWhitespace", + 'description': doc, + }, + 'blankline-check': { + 'name': "blankline", + 'sourcefile': "blank", + 'class': "EbuildBlankLine", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/whitespace/blank.py b/repoman/pym/repoman/modules/linechecks/whitespace/blank.py new file mode 100644 index 0..2ab4097a3 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/whitespace/blank.py @@ -0,0 +1,25 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildBlankLine(LineCheck): + repoman_check_name = 'ebuild.minorsyn' + ignore_comment = False + blank_line = re.compile(r'^$') + + def new(self, pkg): + self.line_is_blank = False + + def check(self, num, line): + if self.line_is_blank and self.blank_line.match(line): + return 'Useless blank line on line: %d' + if self.blank_line.match(line): + self.line_is_blank = True + else: + self.line_is_blank = False + + def end(self): + if self.line_is_blank: + yield 'Useless blank line on last line' diff --git a/repoman/pym/repoman/modules/linechecks/whitespace/whitespace.py b/repoman/pym/repoman/modules/linechecks/whitespace/whitespace.py new file mode 100644 index 0..556b2ab81 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/whitespace/whitespace.py @@ -0,0 +1,21 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildWhitespace(LineCheck): + """Ensure ebuilds have proper whitespacing""" + + repoman_check_name = 'ebuild.minorsyn' + + ignore_line = re.compile(r'(^$)|(^(\t)*#)') + ignore_comment = False + leading_spaces = re.compile(r'^[\S\t]') + trailing_whitespace = re.compile(r'.*([\S]$)') + + def check(self, num, line): + if self.leading_spaces.match(line) is None: + return self.errors['LEADING_SPACES_ERROR'] + if self.trailing_whitespace.match(line) is None: + return self.errors['TRAILING_WHITESPACE_ERROR']
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/tests/
commit: 9ef45aaf273708049fc5ee1c8f65968b47bab039 Author: El Acheche Anis ubuntu com> AuthorDate: Mon Jul 24 04:47:42 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:28 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=9ef45aaf repoman: repoman/pym/repoman/tests/runTests.py: Fix PEP8 E302 repoman/pym/repoman/tests/runTests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/repoman/pym/repoman/tests/runTests.py b/repoman/pym/repoman/tests/runTests.py index 3125ff058..1795aa487 100644 --- a/repoman/pym/repoman/tests/runTests.py +++ b/repoman/pym/repoman/tests/runTests.py @@ -11,6 +11,7 @@ import platform import pwd import signal + def debug_signal(signum, frame): import pdb pdb.set_trace()
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/uri/
commit: 816fddfef045b9507fb076c6465f9cd08b79a3a6 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:05:03 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:27 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=816fddfe repoman: New linechecks module, uri .../pym/repoman/modules/linechecks/uri/__init__.py | 21 +++ repoman/pym/repoman/modules/linechecks/uri/uri.py | 30 ++ 2 files changed, 51 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/uri/__init__.py b/repoman/pym/repoman/modules/linechecks/uri/__init__.py new file mode 100644 index 0..a7731e3cc --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/uri/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Uri plug-in module for repoman LineChecks. +Performs HOMEPAGE variable checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'httpsuri-check': { + 'name': "httpsuri", + 'sourcefile': "uri", + 'class': "UriUseHttps", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/uri/uri.py b/repoman/pym/repoman/modules/linechecks/uri/uri.py new file mode 100644 index 0..1a0afe682 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/uri/uri.py @@ -0,0 +1,30 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class UriUseHttps(LineCheck): + """Check that we use https:// for known good sites.""" + repoman_check_name = 'uri.https' + _SITES = ( + '([-._a-zA-Z0-9]*\.)?apache\.org', + '((alioth|packages(\.qa)?|people|www)\.)?debian\.org', + # Most FDO sites support https, but not all (like tango). + # List the most common ones here for now. + '((anongit|bugs|cgit|dri|patchwork|people|specifications|www|xcb|xorg)\.)?freedesktop\.org', + '((bugs|dev|wiki|www)\.)?gentoo\.org', + '((wiki)\.)?github\.(io|com)', + 'savannah\.(non)?gnu\.org', + '((gcc|www)\.)?gnu\.org', + 'curl\.haxx\.se', + '((bugzilla|git|mirrors|patchwork|planet|www(\.wiki)?)\.)?kernel\.org', + '((bugs|wiki|www)\.)?linuxfoundation\.org', + '((docs|pypi|www)\.)?python\.org', + '(sf|sourceforge)\.net', + '(www\.)?(enlightenment|sourceware|x)\.org', + ) + # Try to anchor the end of the URL so we don't get false positives + # with http://github.com.foo.bar.com/. Unlikely, but possible. + re = re.compile(r'.*\bhttp://(%s)(\s|["\'/]|$)' % r'|'.join(_SITES)) + error = 'URI_HTTPS'
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/, repoman/pym/repoman/modules/scan/ebuild/
commit: 0e6a9c7e274d9eba6ca98aedb239bf9e7cc8e7f5 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:09:03 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:28 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=0e6a9c7e repoman: Convert multicheck module to the new linechecks sub-module repoman/pym/repoman/modules/scan/ebuild/__init__.py | 2 +- repoman/pym/repoman/modules/scan/ebuild/multicheck.py | 10 +++--- repoman/pym/repoman/scanner.py| 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/repoman/pym/repoman/modules/scan/ebuild/__init__.py b/repoman/pym/repoman/modules/scan/ebuild/__init__.py index 3e1d31951..1d8ec1941 100644 --- a/repoman/pym/repoman/modules/scan/ebuild/__init__.py +++ b/repoman/pym/repoman/modules/scan/ebuild/__init__.py @@ -47,7 +47,7 @@ module_spec = { 'functions': ['check'], 'func_kwargs': { }, - 'mod_kwargs': ['qatracker', 'options' + 'mod_kwargs': ['qatracker', 'options', 'repo_settings', 'linechecks', ], 'func_kwargs': { 'ebuild': (None, None), diff --git a/repoman/pym/repoman/modules/scan/ebuild/multicheck.py b/repoman/pym/repoman/modules/scan/ebuild/multicheck.py index 9e36e2a68..94526ae9e 100644 --- a/repoman/pym/repoman/modules/scan/ebuild/multicheck.py +++ b/repoman/pym/repoman/modules/scan/ebuild/multicheck.py @@ -8,7 +8,7 @@ import io from portage import _encodings, _unicode_encode from repoman.modules.scan.scanbase import ScanBase -from .checks import run_checks, checks_init +from repoman.modules.linechecks.controller import LineCheckController class MultiCheck(ScanBase): @@ -22,7 +22,11 @@ class MultiCheck(ScanBase): ''' self.qatracker = kwargs.get('qatracker') self.options = kwargs.get('options') - checks_init(self.options.experimental_inherit == 'y') + self.controller = LineCheckController( + kwargs.get('repo_settings'), + kwargs.get('linechecks') + ) + self.controller.checks_init(self.options.experimental_inherit == 'y') def check(self, **kwargs): '''Check the ebuild for utf-8 encoding @@ -40,7 +44,7 @@ class MultiCheck(ScanBase): errors='strict'), mode='r', encoding=_encodings['repo.content']) try: - for check_name, e in run_checks(f, pkg): + for check_name, e in self.controller.run_checks(f, pkg): self.qatracker.add_error( check_name, ebuild.relative_path + ': %s' % e) finally: diff --git a/repoman/pym/repoman/scanner.py b/repoman/pym/repoman/scanner.py index b3d030570..d61e50131 100644 --- a/repoman/pym/repoman/scanner.py +++ b/repoman/pym/repoman/scanner.py @@ -193,6 +193,7 @@ class Scanner(object): "env": self.env, "have": self.have, "dev_keywords": self.dev_keywords, + "linechecks": self.moduleconfig.linechecks, } # initialize the plugin checks here self.modules = {}
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/scan/ebuild/
commit: 6b501c4c9e2fd759d8b4a0b15ff1a47a0d7b0f9d Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:10:13 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:28 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=6b501c4c repoman: Remove the no longer used modules/scan/ebuild/checks.py repoman/pym/repoman/modules/scan/ebuild/checks.py | 1044 - 1 file changed, 1044 deletions(-) diff --git a/repoman/pym/repoman/modules/scan/ebuild/checks.py b/repoman/pym/repoman/modules/scan/ebuild/checks.py deleted file mode 100644 index de03bedd2..0 --- a/repoman/pym/repoman/modules/scan/ebuild/checks.py +++ /dev/null @@ -1,1044 +0,0 @@ -# -*- coding:utf-8 -*- -# repoman: Checks -# Copyright 2007-2017 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -"""This module contains functions used in Repoman to ascertain the quality -and correctness of an ebuild.""" - -from __future__ import unicode_literals - -from itertools import chain -import operator -import re -import time - -# import our initialized portage instance -from repoman._portage import portage - -from portage.eapi import ( - eapi_supports_prefix, eapi_has_implicit_rdepend, - eapi_has_src_prepare_and_src_configure, eapi_has_dosed_dohard, - eapi_exports_AA, eapi_has_pkg_pretend) - -from . import errors - - -class LineCheck(object): - """Run a check on a line of an ebuild.""" - """A regular expression to determine whether to ignore the line""" - ignore_line = False - """True if lines containing nothing more than comments with optional - leading whitespace should be ignored""" - ignore_comment = True - - def new(self, pkg): - pass - - def check_eapi(self, eapi): - """Returns if check should be run in the given EAPI (default: True)""" - return True - - 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 PhaseCheck(LineCheck): - """ basic class for function detection """ - - func_end_re = re.compile(r'^\}$') - phases_re = re.compile('(%s)' % '|'.join(( - 'pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare', - 'src_configure', 'src_compile', 'src_test', 'src_install', - 'pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm', - 'pkg_config'))) - in_phase = '' - - def check(self, num, line): - m = self.phases_re.match(line) - if m is not None: - self.in_phase = m.group(1) - if self.in_phase != '' and self.func_end_re.match(line) is not None: - self.in_phase = '' - - return self.phase_check(num, line) - - def phase_check(self, num, line): - """ override this function for your checks """ - pass - - -class EbuildHeader(LineCheck): - """Ensure ebuilds have proper headers - Copyright header errors - CVS header errors - License header errors - - Args: - modification_year - Year the ebuild was last modified - """ - - repoman_check_name = 'ebuild.badheader' - - gentoo_copyright = r'^# Copyright ((1999|2\d\d\d)-)?%s Gentoo Foundation$' - gentoo_license = ( - '# Distributed under the terms' - ' of the GNU General Public License v2') - id_header_re = re.compile(r'.*\$(Id|Header)(:.*)?\$.*') - blank_line_re = re.compile(r'^$') - ignore_comment = False - - def new(self, pkg): - if pkg.mtime is None: - self.modification_year = r'2\d\d\d' - else: - self.modification_year = str(time.gmtime(pkg.mtime)[0]) - self.gentoo_copyright_re = re.compile( - self.gentoo_copyright % self.modification_year) - - def check(self, num, line): - if num > 2: - return - elif num == 0: - if not self.gentoo_copyright_re.match(line): - return errors.COPYRIGHT_ERROR - elif num == 1 and line.rstrip('\n') != self.gentoo_license: - return errors.LICENSE_ERROR - elif num == 2 and self.id_header_re.match(line): - return errors.ID_HEADER_ERROR - elif num == 2 and not self.blank_line_re.match(line): - return errors.NO_BLANK_LINE_ERROR - - -class EbuildWhitespace(LineCheck): - """Ensure ebuilds have proper whitespacing""" - - repoman_check_name = 'ebuild.minorsyn' - - ignore_line
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/patches/
commit: 377fe2c7b207e6efe9c669a2f581b544dd882622 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:02:58 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:27 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=377fe2c7 repoman: New linechecks module, patches .../repoman/modules/linechecks/patches/__init__.py | 21 + .../repoman/modules/linechecks/patches/patches.py | 16 2 files changed, 37 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/patches/__init__.py b/repoman/pym/repoman/modules/linechecks/patches/__init__.py new file mode 100644 index 0..67434f911 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/patches/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Patches plug-in module for repoman LineChecks. +Performs PATCHES variable checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'patches-check': { + 'name': "patches", + 'sourcefile': "patches", + 'class': "EbuildPatches", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/patches/patches.py b/repoman/pym/repoman/modules/linechecks/patches/patches.py new file mode 100644 index 0..63651cd7c --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/patches/patches.py @@ -0,0 +1,16 @@ + + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildPatches(LineCheck): + """Ensure ebuilds use bash arrays for PATCHES to ensure white space safety""" + repoman_check_name = 'ebuild.patches' + re = re.compile(r'^\s*PATCHES=[^\(]') + error = 'PATCHES_ERROR' + + def check_eapi(self, eapi): + return eapi in ("0", "1", "2", "3", "4", "4-python", + "4-slot-abi", "5", "5-hdepend", "5-progress")
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/tests/
commit: 021dccdac2ab5d98361b743a8b4542965547158a Author: El Acheche Anis ubuntu com> AuthorDate: Mon Jul 24 04:50:07 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:28 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=021dccda repoman: repoman/pym/repoman/tests/runTests.py: Fix PEP8 E226 repoman/pym/repoman/tests/runTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repoman/pym/repoman/tests/runTests.py b/repoman/pym/repoman/tests/runTests.py index ca37b14b3..b0e715ec6 100644 --- a/repoman/pym/repoman/tests/runTests.py +++ b/repoman/pym/repoman/tests/runTests.py @@ -35,7 +35,7 @@ repoman_pym = osp.dirname(osp.dirname(osp.dirname(osp.realpath(__file__ sys.path.insert(0, repoman_pym) # Add in the parent portage python modules -portage_pym = osp.dirname(osp.dirname(repoman_pym))+'/pym' +portage_pym = osp.dirname(osp.dirname(repoman_pym)) + '/pym' sys.path.insert(0, portage_pym) # import our centrally initialized portage instance
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/nested/
commit: bb73fc01b5bd6788fce52f80633dbd34cb535fd3 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:02:24 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:27 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=bb73fc01 repoman: New linechecks module, nested .../repoman/modules/linechecks/nested/__init__.py | 21 + .../pym/repoman/modules/linechecks/nested/nested.py | 15 +++ .../repoman/modules/linechecks/nested/nesteddie.py | 11 +++ 3 files changed, 47 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/nested/__init__.py b/repoman/pym/repoman/modules/linechecks/nested/__init__.py new file mode 100644 index 0..8eeeccbac --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/nested/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Nested plug-in module for repoman LineChecks. +Performs nested subshell checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'nesteddie-check': { + 'name': "nesteddie", + 'sourcefile': "nested", + 'class': "EbuildNestedDie", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/nested/nested.py b/repoman/pym/repoman/modules/linechecks/nested/nested.py new file mode 100644 index 0..06b272772 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/nested/nested.py @@ -0,0 +1,15 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildNestedDie(LineCheck): + """Check ebuild for nested die statements (die statements in subshells)""" + + repoman_check_name = 'ebuild.nesteddie' + nesteddie_re = re.compile(r'^[^#]*\s\(\s[^)]*\bdie\b') + + def check(self, num, line): + if self.nesteddie_re.match(line): + return self.errors['NESTED_DIE_ERROR'] diff --git a/repoman/pym/repoman/modules/linechecks/nested/nesteddie.py b/repoman/pym/repoman/modules/linechecks/nested/nesteddie.py new file mode 100644 index 0..6c1e4be9f --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/nested/nesteddie.py @@ -0,0 +1,11 @@ + + +class EbuildNestedDie(LineCheck): + """Check ebuild for nested die statements (die statements in subshells)""" + + repoman_check_name = 'ebuild.nesteddie' + nesteddie_re = re.compile(r'^[^#]*\s\(\s[^)]*\bdie\b') + + def check(self, num, line): + if self.nesteddie_re.match(line): + return errors.NESTED_DIE_ERROR
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/use/
commit: d0cdfbcb3b576299f11597d3f8eb04a8b7d4285b Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:05:56 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:27 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d0cdfbcb repoman: New linechecks module, use .../pym/repoman/modules/linechecks/use/__init__.py | 21 + .../pym/repoman/modules/linechecks/use/builtwith.py | 10 ++ 2 files changed, 31 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/use/__init__.py b/repoman/pym/repoman/modules/linechecks/use/__init__.py new file mode 100644 index 0..e5665d2d8 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/use/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Use plug-in module for repoman LineChecks. +Performs Built-With-Use checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'builtwith-check': { + 'name': "builtwith", + 'sourcefile': "builtwith", + 'class': "BuiltWithUse", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/use/builtwith.py b/repoman/pym/repoman/modules/linechecks/use/builtwith.py new file mode 100644 index 0..0ec4fae21 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/use/builtwith.py @@ -0,0 +1,10 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class BuiltWithUse(LineCheck): + repoman_check_name = 'ebuild.minorsyn' + re = re.compile(r'(^|.*\b)built_with_use\b') + error = 'BUILT_WITH_USE'
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/scan/
commit: 43981e36a7f0f49ecd25c89a341ffe69ff4dd09c Author: Brian Dolbec gentoo org> AuthorDate: Tue Dec 5 19:29:26 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:29 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=43981e36 repoman scan/module.py: fix typo repoman/pym/repoman/modules/scan/module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repoman/pym/repoman/modules/scan/module.py b/repoman/pym/repoman/modules/scan/module.py index fc0c66ccb..cebc0e708 100644 --- a/repoman/pym/repoman/modules/scan/module.py +++ b/repoman/pym/repoman/modules/scan/module.py @@ -85,7 +85,7 @@ class ModuleConfig(object): if loop in self.controller.get_spec(mod, 'module_runsIn'): mlist.append(mod) except InvalidModuleName: - logging.error("ModuleConfig; unkown module: %s, skipping", mod) + logging.error("ModuleConfig; unknown module: %s, skipping", mod) logging.debug("ModuleConfig; mlist: %s", mlist) return mlist
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/quotes/, ...
commit: 75ec4970a364fb555405c29dd60a79a18414fc9a Author: Brian Dolbec gentoo org> AuthorDate: Wed Aug 16 23:24:24 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:28 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=75ec4970 repoman: Initial adding file/module/API version repoman/pym/repoman/config.py| 7 +-- repoman/pym/repoman/main.py | 3 +++ repoman/pym/repoman/modules/linechecks/assignment/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/config.py | 2 +- repoman/pym/repoman/modules/linechecks/depend/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/deprecated/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/do/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/eapi/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/emake/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/helpers/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/nested/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/patches/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/phases/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/portage/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/quotes/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/uri/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/use/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/useless/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/whitespace/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/workaround/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/depend/__init__.py | 3 ++- repoman/pym/repoman/modules/scan/directories/__init__.py | 3 ++- repoman/pym/repoman/modules/scan/eapi/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/ebuild/__init__.py | 3 ++- repoman/pym/repoman/modules/scan/eclasses/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/fetch/__init__.py | 3 ++- repoman/pym/repoman/modules/scan/keywords/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/manifest/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/metadata/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/module.py | 9 ++--- repoman/pym/repoman/modules/scan/options/__init__.py | 3 ++- repoman/pym/repoman/qa_data.py | 4 ++-- repoman/pym/repoman/repos.py | 2 +- repoman/pym/repoman/scanner.py | 3 ++- 35 files changed, 76 insertions(+), 38 deletions(-) diff --git a/repoman/pym/repoman/config.py b/repoman/pym/repoman/config.py index 3329f0e7e..6facf5cc8 100644 --- a/repoman/pym/repoman/config.py +++ b/repoman/pym/repoman/config.py @@ -144,8 +144,11 @@ def load_config(conf_dirs, file_extensions=None, valid_versions=None): if config: if config['version'] not in valid_versions: - raise ConfigError("Invalid file version: %s in: %s\nPlease upgrade repoman: current valid versions: %s" - % (config['version'], filename, valid_versions)) + raise ConfigError( + "Invalid file version: %s in: %s\nPlease upgrade to " + ">=app-portage/repoman-%s, current valid API versions: %s" + % (config['version'], filename, + config['repoman_version'], valid_versions)) result = merge_config(result, config) return result diff --git a/repoman/pym/repoman/main.py b/repoman/pym/repoman/main.py index c1e3b99fe..81e2ff61e 100755 --- a/repoman/pym/repoman/main.py +++ b/repoman/pym/repoman/main.py @@ -47,10 +47,12 @@ os.umask(0o22) LOGLEVEL = logging.WARNING portage.util.initialize_logger(LOGLEVEL) +VALID_VERSIONS = [1,] def repoman_main(argv): config_root = os.environ.get("PORTAGE_CONFIGROOT") repoman_settings = portage.config(config_root=config_root, local_config=False) + repoman_settings.valid_versions = VALID_VERSIONS if repoman_settings.get("NOCOLOR", "").lower() in ("yes", "true") or \ repoman_settings.get('TERM') == 'dumb' or \ @@ -92,6 +94,7 @@ def repoman_main(argv): config_root, portdir, portdir_overlay, repoman_settings, vcs_settings, options, qadata) repoman_settings = repo_settings.repoman_settings +
[gentoo-commits] proj/portage:repoman commit in: /
commit: 74fd23b21875a1be628f0ddb17b9bc6430cb0df0 Author: El Acheche Anis ubuntu com> AuthorDate: Wed Jul 26 22:20:56 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:28 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=74fd23b2 repoman: .travis.yml: pyyaml python module is needed for builds .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index ebcfbeab9..94ed2dcb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,8 @@ install: - "[[ ${TRAVIS_PYTHON_VERSION} == 3.[6789] ]] || pip install pyblake2" # always install pygost for Streebog - pip install pygost +# pyyaml is needed for building +- pip install pyyaml script: - printf "[build_ext]\nportage-ext-modules=true" >> setup.cfg
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/useless/
commit: 8fe18fb17a553601a73e0bf0cfdf54d34f3726ba Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:06:38 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Wed Dec 6 00:13:27 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=8fe18fb1 repoman: New linechecks module, useless .../repoman/modules/linechecks/useless/__init__.py | 27 ++ .../pym/repoman/modules/linechecks/useless/cd.py | 24 +++ .../repoman/modules/linechecks/useless/dodoc.py| 16 + 3 files changed, 67 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/useless/__init__.py b/repoman/pym/repoman/modules/linechecks/useless/__init__.py new file mode 100644 index 0..acc4479f5 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/useless/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Useless plug-in module for repoman LineChecks. +Performs checks for useless operations on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'uselesscds-check': { + 'name': "uselesscds", + 'sourcefile': "cd", + 'class': "EbuildUselessCdS", + 'description': doc, + }, + 'uselessdodoc-check': { + 'name': "uselessdodoc", + 'sourcefile': "dodoc", + 'class': "EbuildUselessDodoc", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/useless/cd.py b/repoman/pym/repoman/modules/linechecks/useless/cd.py new file mode 100644 index 0..3daa04451 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/useless/cd.py @@ -0,0 +1,24 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildUselessCdS(LineCheck): + """Check for redundant cd ${S} statements""" + repoman_check_name = 'ebuild.minorsyn' + _src_phases = r'^\s*src_(prepare|configure|compile|install|test)\s*\(\)' + method_re = re.compile(_src_phases) + cds_re = re.compile(r'^\s*cd\s+("\$(\{S\}|S)"|\$(\{S\}|S))\s') + + def __init__(self, errors): + self.errors = errors + self.check_next_line = False + + def check(self, num, line): + if self.check_next_line: + self.check_next_line = False + if self.cds_re.match(line): + return self.errors['REDUNDANT_CD_S_ERROR'] + elif self.method_re.match(line): + self.check_next_line = True diff --git a/repoman/pym/repoman/modules/linechecks/useless/dodoc.py b/repoman/pym/repoman/modules/linechecks/useless/dodoc.py new file mode 100644 index 0..502bfbea8 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/useless/dodoc.py @@ -0,0 +1,16 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildUselessDodoc(LineCheck): + """Check ebuild for useless files in dodoc arguments.""" + repoman_check_name = 'ebuild.minorsyn' + uselessdodoc_re = re.compile( + r'^\s*dodoc(\s+|\s+.*\s+)(ABOUT-NLS|COPYING|LICENCE|LICENSE)($|\s)') + + def check(self, num, line): + match = self.uselessdodoc_re.match(line) + if match: + return "Useless dodoc '%s'" % (match.group(2), ) + " on line: %d"
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/scan/keywords/, repoman/pym/repoman/modules/scan/, ...
commit: 970476a56456e2ac3613a51056b71e581ceba27d Author: Brian Dolbec gentoo org> AuthorDate: Wed Aug 16 23:24:24 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:49 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=970476a5 repoman: Initial adding file/module/API version repoman/pym/repoman/config.py| 7 +-- repoman/pym/repoman/main.py | 3 +++ repoman/pym/repoman/modules/linechecks/assignment/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/config.py | 2 +- repoman/pym/repoman/modules/linechecks/depend/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/deprecated/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/do/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/eapi/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/emake/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/helpers/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/nested/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/patches/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/phases/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/portage/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/quotes/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/uri/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/use/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/useless/__init__.py | 3 ++- repoman/pym/repoman/modules/linechecks/whitespace/__init__.py| 3 ++- repoman/pym/repoman/modules/linechecks/workaround/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/depend/__init__.py | 3 ++- repoman/pym/repoman/modules/scan/directories/__init__.py | 3 ++- repoman/pym/repoman/modules/scan/eapi/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/ebuild/__init__.py | 3 ++- repoman/pym/repoman/modules/scan/eclasses/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/fetch/__init__.py | 3 ++- repoman/pym/repoman/modules/scan/keywords/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/manifest/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/metadata/__init__.py| 3 ++- repoman/pym/repoman/modules/scan/module.py | 9 ++--- repoman/pym/repoman/modules/scan/options/__init__.py | 3 ++- repoman/pym/repoman/qa_data.py | 4 ++-- repoman/pym/repoman/repos.py | 2 +- repoman/pym/repoman/scanner.py | 3 ++- 35 files changed, 76 insertions(+), 38 deletions(-) diff --git a/repoman/pym/repoman/config.py b/repoman/pym/repoman/config.py index f98130db3..dbf75237c 100644 --- a/repoman/pym/repoman/config.py +++ b/repoman/pym/repoman/config.py @@ -142,8 +142,11 @@ def load_config(conf_dirs, file_extensions=None, valid_versions=None): if config: if config['version'] not in valid_versions: - raise ConfigError("Invalid file version: %s in: %s\nPlease upgrade repoman: current valid versions: %s" - % (config['version'], filename, valid_versions)) + raise ConfigError( + "Invalid file version: %s in: %s\nPlease upgrade to " + ">=app-portage/repoman-%s, current valid API versions: %s" + % (config['version'], filename, + config['repoman_version'], valid_versions)) result = merge_config(result, config) return result diff --git a/repoman/pym/repoman/main.py b/repoman/pym/repoman/main.py index c1e3b99fe..81e2ff61e 100755 --- a/repoman/pym/repoman/main.py +++ b/repoman/pym/repoman/main.py @@ -47,10 +47,12 @@ os.umask(0o22) LOGLEVEL = logging.WARNING portage.util.initialize_logger(LOGLEVEL) +VALID_VERSIONS = [1,] def repoman_main(argv): config_root = os.environ.get("PORTAGE_CONFIGROOT") repoman_settings = portage.config(config_root=config_root, local_config=False) + repoman_settings.valid_versions = VALID_VERSIONS if repoman_settings.get("NOCOLOR", "").lower() in ("yes", "true") or \ repoman_settings.get('TERM') == 'dumb' or \ @@ -92,6 +94,7 @@ def repoman_main(argv): config_root, portdir, portdir_overlay, repoman_settings, vcs_settings, options, qadata) repoman_settings = repo_settings.repoman_settings +
[gentoo-commits] proj/portage:repoman commit in: repoman/
commit: 768c2d545d53c945e86796cd683c5d033d08d7a7 Author: Brian Dolbec gentoo org> AuthorDate: Tue Dec 5 18:22:33 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:28:39 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=768c2d54 srepoman setup.py: Add the new cnf/qa_data cnf/linechecks items repoman/setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/repoman/setup.py b/repoman/setup.py index c22a5c305..d2539f38c 100755 --- a/repoman/setup.py +++ b/repoman/setup.py @@ -479,6 +479,8 @@ setup( data_files = list(get_manpages()) + [ ['$docdir', ['NEWS', 'RELEASE-NOTES']], + ['share/repoman/qa_data', ['cnf/qa_data/qa_data.yaml']], + ['share/repoman/linechecks', ['cnf/linechecks.yaml']], ], cmdclass = {
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/useless/
commit: 463d5a7c33f8639e38b48c1947ca1b1f9ae9480e Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:06:38 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:49 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=463d5a7c repoman: New linechecks module, useless .../repoman/modules/linechecks/useless/__init__.py | 27 ++ .../pym/repoman/modules/linechecks/useless/cd.py | 24 +++ .../repoman/modules/linechecks/useless/dodoc.py| 16 + 3 files changed, 67 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/useless/__init__.py b/repoman/pym/repoman/modules/linechecks/useless/__init__.py new file mode 100644 index 0..acc4479f5 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/useless/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Useless plug-in module for repoman LineChecks. +Performs checks for useless operations on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'uselesscds-check': { + 'name': "uselesscds", + 'sourcefile': "cd", + 'class': "EbuildUselessCdS", + 'description': doc, + }, + 'uselessdodoc-check': { + 'name': "uselessdodoc", + 'sourcefile': "dodoc", + 'class': "EbuildUselessDodoc", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/useless/cd.py b/repoman/pym/repoman/modules/linechecks/useless/cd.py new file mode 100644 index 0..3daa04451 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/useless/cd.py @@ -0,0 +1,24 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildUselessCdS(LineCheck): + """Check for redundant cd ${S} statements""" + repoman_check_name = 'ebuild.minorsyn' + _src_phases = r'^\s*src_(prepare|configure|compile|install|test)\s*\(\)' + method_re = re.compile(_src_phases) + cds_re = re.compile(r'^\s*cd\s+("\$(\{S\}|S)"|\$(\{S\}|S))\s') + + def __init__(self, errors): + self.errors = errors + self.check_next_line = False + + def check(self, num, line): + if self.check_next_line: + self.check_next_line = False + if self.cds_re.match(line): + return self.errors['REDUNDANT_CD_S_ERROR'] + elif self.method_re.match(line): + self.check_next_line = True diff --git a/repoman/pym/repoman/modules/linechecks/useless/dodoc.py b/repoman/pym/repoman/modules/linechecks/useless/dodoc.py new file mode 100644 index 0..502bfbea8 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/useless/dodoc.py @@ -0,0 +1,16 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildUselessDodoc(LineCheck): + """Check ebuild for useless files in dodoc arguments.""" + repoman_check_name = 'ebuild.minorsyn' + uselessdodoc_re = re.compile( + r'^\s*dodoc(\s+|\s+.*\s+)(ABOUT-NLS|COPYING|LICENCE|LICENSE)($|\s)') + + def check(self, num, line): + match = self.uselessdodoc_re.match(line) + if match: + return "Useless dodoc '%s'" % (match.group(2), ) + " on line: %d"
[gentoo-commits] proj/portage:repoman commit in: /
commit: 79f19998e2b5a2f14cf2b48f1665dffc23e33a87 Author: El Acheche Anis ubuntu com> AuthorDate: Wed Jul 26 22:20:56 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:50 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=79f19998 repoman: .travis.yml: pyyaml python module is needed for builds .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index ebcfbeab9..94ed2dcb1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,8 @@ install: - "[[ ${TRAVIS_PYTHON_VERSION} == 3.[6789] ]] || pip install pyblake2" # always install pygost for Streebog - pip install pygost +# pyyaml is needed for building +- pip install pyyaml script: - printf "[build_ext]\nportage-ext-modules=true" >> setup.cfg
[gentoo-commits] proj/portage:repoman commit in: pym/portage/
commit: 687f87be15129b06e761c996478e8ea4a7b6fc82 Author: Brian Dolbec gentoo org> AuthorDate: Thu Aug 17 01:50:21 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:49 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=687f87be module.py: Extend the module loader for API version checking If provided with an iterable of compatibility versions, The controller will check the plugin modules module_spec 'version' variable is compatible with the base application. pym/portage/module.py | 22 -- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/pym/portage/module.py b/pym/portage/module.py index 00f322387..f5116b6f5 100644 --- a/pym/portage/module.py +++ b/pym/portage/module.py @@ -15,6 +15,10 @@ class InvalidModuleName(PortageException): """An invalid or unknown module name.""" +class ModuleVersionError(PortageException): + '''An incompatible module version''' + + class Module(object): """Class to define and hold our plug-in module @@ -87,16 +91,17 @@ class Modules(object): @param namepath: Python import path to the "modules" directory """ - def __init__(self, path, namepath): + def __init__(self, path, namepath, compat_versions=None): self._module_path = path self._namepath = namepath + self.compat_versions = compat_versions self.parents = [] self._modules = self._get_all_modules() self.modules = ProtectedDict(self._modules) self.module_names = sorted(self._modules) def _get_all_modules(self): - """scans the emaint modules dir for loadable modules + """scans the _module_path dir for loadable modules @rtype: dictionary of module_plugins """ @@ -117,6 +122,7 @@ class Modules(object): kids = {} for entry in importables: new_module = Module(entry, self._namepath) + self._check_compat(new_module) for module_name in new_module.kids: kid = new_module.kids[module_name] kid['parent'] = new_module @@ -211,6 +217,8 @@ class Modules(object): @type modname: string @param modname: the module class name + @type var: string + @param var: the base level variable to return @type dictionary @return: the modules class exported options descriptions """ @@ -220,3 +228,13 @@ class Modules(object): raise InvalidModuleName( "Module name '%s' was invalid or not found" % modname) return value + + def _check_compat(self, module): + if self.compat_versions: + if not module.module_spec['version'] in self.compat_versions: + raise ModuleVersionError( + "Error loading '%s' plugin module: %s, version: %s\n" + "Module is not compatible with the current application version\n" + "Compatible module API versions are: %s" + % (self._namepath, module.module_spec['name'], + module.module_spec['version'], self.compat_versions))
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/, repoman/cnf/qa_data/
commit: 94b603624c4018e085c4c0683d7ebac75ef362f2 Author: Brian Dolbec gentoo org> AuthorDate: Tue Dec 5 18:16:44 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:27:20 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=94b60362 repoman qa_data.py: Move the qahelp loading to a new /usr/share/repoman/qa_data directory This new directory can be installed to by third party add on modules that extend the checks. We can also in future use these file to get loaclized translations. repoman/cnf/qa_data/qa_data.yaml | 138 +++ repoman/pym/repoman/qa_data.py | 19 +- 2 files changed, 154 insertions(+), 3 deletions(-) diff --git a/repoman/cnf/qa_data/qa_data.yaml b/repoman/cnf/qa_data/qa_data.yaml new file mode 100644 index 0..c3ce8a4f9 --- /dev/null +++ b/repoman/cnf/qa_data/qa_data.yaml @@ -0,0 +1,138 @@ +--- +# qa_help.yaml + +# configuration file for the LineCheck plugins run via the multicheck +# scan module + +# Repoman API version (do not edit) +version: 1 +# minimum +repoman_version: 2.3.3 + +# qahelp: Primary QA help messages to describe the errors or warnings +# Dictionary +qahelp: +Entries: +IO_error: "Attempting to commit, and an IO error was encountered access the Entries file" +ebuild: +invalidname: "Ebuild files with a non-parseable or syntactically incorrect name (or using 2.1 versioning extensions)" +namenomatch: "Ebuild files that do not have the same name as their parent directory" +notadded: "Ebuilds that exist but have not been added to the vcs" +patches: "PATCHES variable should be a bash array to ensure white space safety" +changelog: +ebuildadded: "An ebuild was added but the ChangeLog was not modified" +missing: "Missing ChangeLog files" +notadded: "ChangeLogs that exist but have not been added to cvs" +dependency: +bad: "User-visible ebuilds with unsatisfied dependencies (matched against *visible* ebuilds)" +badmasked: "Masked ebuilds with unsatisfied dependencies (matched against *all* ebuilds)" +badindev: "User-visible ebuilds with unsatisfied dependencies (matched against *visible* ebuilds) in developing arch" +badmaskedindev: Masked ebuilds with unsatisfied dependencies (matched against *all* ebuilds) in developing arch" +badtilde: "Uses the ~ dep operator with a non-zero revision part, which is useless (the revision is ignored)" +missingslot: "RDEPEND matches more than one SLOT but does not specify a slot and/or use the := or :* slot operator" +perlcore: "This ebuild directly depends on a package in perl-core; it should use the corresponding virtual instead." +syntax: "Syntax error in dependency string (usually an extra/missing space/parenthesis)" +unknown: "Ebuild has a dependency that refers to an unknown package (which may be valid if it is a blocker for a renamed/removed package, or is an alternative choice provided by an overlay)" +badslotop: "RDEPEND contains ':=' slot operator under '||' dependency." +DESCRIPTION: +missing: "Ebuilds that have a missing or empty DESCRIPTION variable" +toolong: "DESCRIPTION is over %d characters" +digest: +assumed: "Existing digest must be assumed correct (Package level only)" +missing: "Some files listed in SRC_URI aren't referenced in the Manifest" +unused: "Some files listed in the Manifest aren't referenced in SRC_URI" +EAPI: +definition: "EAPI definition does not conform to PMS section 7.3.1 (first non-comment, non-blank line)" +deprecated: "Ebuilds that use features that are deprecated in the current EAPI" +incompatible: "Ebuilds that use features that are only available with a different EAPI" +unsupported: "Ebuilds that have an unsupported EAPI version (you must upgrade portage)" +ebuild: +absdosym: "This ebuild uses absolute target to dosym where relative symlink could be used instead" +badheader: "This ebuild has a malformed header" +majorsyn: "This ebuild has a major syntax error that may cause the ebuild to fail partially or fully" +minorsyn: "This ebuild has a minor syntax error that contravenes gentoo coding style" +nesteddie: "Placing 'die' inside ( ) prints an error, but doesn't stop the ebuild." +output: "A simple sourcing of the ebuild produces output; this breaks ebuild policy." +syntax: "Error generating cache entry for ebuild; typically caused by ebuild syntax error or digest verification failure" +file: +executable: "Ebuilds, digests, metadata.xml, Manifest, and ChangeLog do not need the executable bit" +size: "Files in the files directory must be under 20 KiB" +size-fatal: "Files in the files directory must be under 60 KiB" +empty: "Empty file in
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/tests/
commit: 5056368e52a249b13cf01b7d69995422e7a0516d Author: El Acheche Anis ubuntu com> AuthorDate: Mon Jul 24 04:49:26 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:49 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=5056368e repoman: repoman/pym/repoman/tests/runTests.py: Fix PEP8 E261 repoman/pym/repoman/tests/runTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repoman/pym/repoman/tests/runTests.py b/repoman/pym/repoman/tests/runTests.py index 1795aa487..ca37b14b3 100644 --- a/repoman/pym/repoman/tests/runTests.py +++ b/repoman/pym/repoman/tests/runTests.py @@ -17,7 +17,7 @@ def debug_signal(signum, frame): pdb.set_trace() if platform.python_implementation() == 'Jython': - debug_signum = signal.SIGUSR2 # bug #424259 + debug_signum = signal.SIGUSR2 # bug #424259 else: debug_signum = signal.SIGUSR1
[gentoo-commits] proj/portage:repoman commit in: repoman/cnf/linechecks/, repoman/pym/repoman/modules/linechecks/
commit: bbe75657cc32aeb402a6ff78eba7bd05a3c87424 Author: Brian Dolbec gentoo org> AuthorDate: Tue Dec 5 18:17:15 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:28:34 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=bbe75657 repoman linechecks/config.py: Move the errors loading to a new /usr/share/repoman/linechecks directory This new directory can be installed to by third party add on modules that extend the checks. We can also in future use these file to get loaclized translations. repoman/cnf/linechecks/linechecks.yaml | 35 repoman/pym/repoman/modules/linechecks/config.py | 21 -- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/repoman/cnf/linechecks/linechecks.yaml b/repoman/cnf/linechecks/linechecks.yaml new file mode 100644 index 0..634381e80 --- /dev/null +++ b/repoman/cnf/linechecks/linechecks.yaml @@ -0,0 +1,35 @@ +--- +# linecheck_help.yaml + +# Repoman API version (do not edit) +version: 1 +# minimum +repoman_version: 2.3.3 + +# configuration file for the LineCheck plugins run via the multicheck +# scan module +errors: +COPYRIGHT_ERROR: 'Invalid Gentoo Copyright on line: %d' +LICENSE_ERROR: 'Invalid Gentoo/GPL License on line: %d' +ID_HEADER_ERROR: 'Stale CVS header on line: %d' +NO_BLANK_LINE_ERROR: 'Non-blank line after header on line: %d' +LEADING_SPACES_ERROR: 'Ebuild contains leading spaces on line: %d' +TRAILING_WHITESPACE_ERROR: 'Trailing whitespace error on line: %d' +READONLY_ASSIGNMENT_ERROR: 'Ebuild contains assignment to read-only variable on line: %d' +MISSING_QUOTES_ERROR: 'Unquoted Variable on line: %d' +NESTED_DIE_ERROR: 'Ebuild calls die in a subshell on line: %d' +PATCHES_ERROR: 'PATCHES is not a bash array on line: %d' +REDUNDANT_CD_S_ERROR: 'Ebuild has redundant cd ${S} statement on line: %d' +EMAKE_PARALLEL_DISABLED: 'Upstream parallel compilation bug (ebuild calls emake -j1 on line: %d)' +EMAKE_PARALLEL_DISABLED_VIA_MAKEOPTS: 'Upstream parallel compilation bug (MAKEOPTS=-j1 on line: %d)' +DEPRECATED_BINDNOW_FLAGS: 'Deprecated bindnow-flags call on line: %d' +EAPI_DEFINED_AFTER_INHERIT: 'EAPI defined after inherit on line: %d' +NO_AS_NEEDED: 'Upstream asneeded linking bug (no-as-needed on line: %d)' +PRESERVE_OLD_LIB: 'Ebuild calls deprecated preserve_old_lib on line: %d' +BUILT_WITH_USE: 'built_with_use on line: %d' +NO_OFFSET_WITH_HELPERS: 'Helper function is used with D, ROOT, ED, EROOT or EPREFIX on line: %d' +SANDBOX_ADDPREDICT: 'Ebuild calls addpredict on line: %d' +USEQ_ERROR: 'Ebuild calls deprecated useq function on line: %d' +HASQ_ERROR: 'Ebuild calls deprecated hasq function on line: %d' +URI_HTTPS: 'Ebuild uses http:// but should use https:// on line: %d' + diff --git a/repoman/pym/repoman/modules/linechecks/config.py b/repoman/pym/repoman/modules/linechecks/config.py index 52a9a786b..be58c799c 100644 --- a/repoman/pym/repoman/modules/linechecks/config.py +++ b/repoman/pym/repoman/modules/linechecks/config.py @@ -14,6 +14,8 @@ import os import yaml from copy import deepcopy +from repoman import _not_installed +from repoman import _portage from portage.util import stack_lists from repoman.config import load_config @@ -42,8 +44,7 @@ class LineChecksConfig(object): @param configpaths: ordered list of filepaths to load ''' self.repo_settings = repo_settings - self.infopaths = [os.path.join(path, 'linechecks.yaml') for path in self.repo_settings.masters_list] - logging.debug("LineChecksConfig; configpaths: %s", self.infopaths) + self.infopaths = None self.info_config = None self._config = None self.usex_supported_eapis = None @@ -54,18 +55,32 @@ class LineChecksConfig(object): self.eclass_info = {} self.eclass_info_experimental_inherit = {} self.errors = {} + self.set_infopaths() self.load_checks_info() + def set_infopaths(self): + if _not_installed: + cnfdir = os.path.realpath(os.path.join(os.path.dirname( + os.path.dirname(os.path.dirname(os.path.dirname( + os.path.dirname(__file__), 'cnf/linechecks')) + else: + cnfdir = os.path.join(_portage.portage.const.EPREFIX, 'usr/share/repoman/linechecks') + repomanpaths = [os.path.join(cnfdir, _file_) for _file_ in os.listdir(cnfdir)] + logging.debug("LineChecksConfig; repomanpaths: %s", repomanpaths) + repopaths = [os.path.join(path, 'linechecks.yaml') for path in self.repo_settings.masters_list] + self.infopaths = repomanpaths + repopaths +
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/quotes/
commit: 3912a7c5b5852bb5011e677e536f9fe9e5440bd6 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:04:31 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:49 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=3912a7c5 repoman: New linechecks module, quotes .../repoman/modules/linechecks/quotes/__init__.py | 27 +++ .../repoman/modules/linechecks/quotes/quoteda.py | 16 .../repoman/modules/linechecks/quotes/quotes.py| 86 ++ 3 files changed, 129 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/quotes/__init__.py b/repoman/pym/repoman/modules/linechecks/quotes/__init__.py new file mode 100644 index 0..6043ab20c --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/quotes/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Nested plug-in module for repoman LineChecks. +Performs nested subshell checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'quote-check': { + 'name': "quote", + 'sourcefile': "quotes", + 'class': "EbuildQuote", + 'description': doc, + }, + 'quoteda-check': { + 'name': "quoteda", + 'sourcefile': "quoteda", + 'class': "EbuildQuotedA", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/quotes/quoteda.py b/repoman/pym/repoman/modules/linechecks/quotes/quoteda.py new file mode 100644 index 0..7fd9ba797 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/quotes/quoteda.py @@ -0,0 +1,16 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildQuotedA(LineCheck): + """Ensure ebuilds have no quoting around ${A}""" + + repoman_check_name = 'ebuild.minorsyn' + a_quoted = re.compile(r'.*\"\$(\{A\}|A)\"') + + def check(self, num, line): + match = self.a_quoted.match(line) + if match: + return "Quoted \"${A}\" on line: %d" diff --git a/repoman/pym/repoman/modules/linechecks/quotes/quotes.py b/repoman/pym/repoman/modules/linechecks/quotes/quotes.py new file mode 100644 index 0..68c594e23 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/quotes/quotes.py @@ -0,0 +1,86 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildQuote(LineCheck): + """Ensure ebuilds have valid quoting around things like D,FILESDIR, etc...""" + + repoman_check_name = 'ebuild.minorsyn' + _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+)') + ignore_comment = False + var_names = ["D", "DISTDIR", "FILESDIR", "S", "T", "ROOT", "WORKDIR"] + + # EAPI=3/Prefix vars + var_names += ["ED", "EPREFIX", "EROOT"] + + # variables for games.eclass + var_names += [ + "Ddir", "GAMES_PREFIX_OPT", "GAMES_DATADIR", + "GAMES_DATADIR_BASE", "GAMES_SYSCONFDIR", "GAMES_STATEDIR", + "GAMES_LOGDIR", "GAMES_BINDIR"] + + # variables for multibuild.eclass + var_names += ["BUILD_DIR"] + + var_names = "(%s)" % "|".join(var_names) + var_reference = re.compile( + r'\$(\{%s\}|%s\W)' % (var_names, var_names)) + missing_quotes = re.compile( + r'(\s|^)[^"\'\s]*\$\{?%s\}?[^"\'\s]*(\s|$)' % var_names) + cond_begin = re.compile(r'(^|\s+)\[\[($|\\$|\s+)') + cond_end = re.compile(r'(^|\s+)\]\]($|\\$|\s+)') + + def check(self, num, line): + if self.var_reference.search(line) is None: + return + # There can be multiple matches / violations on a single line. We + # have to make sure none of the matches are violators. Once we've + # found one violator, any remaining matches on the same line can + # be ignored. + pos = 0 + while pos <= len(line) - 1: + missing_quotes = self.missing_quotes.search(line, pos) + if not missing_quotes: + break + # If the last character of the previous match is a whitespace + # character, that character may be
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/tests/
commit: 91e761f832abede0a60433d0a824b6ab04a541e8 Author: El Acheche Anis ubuntu com> AuthorDate: Mon Jul 24 04:46:28 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:49 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=91e761f8 repoman: repoman/pym/repoman/tests/runTests.py: Fix PEP8 E401 repoman/pym/repoman/tests/runTests.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/repoman/pym/repoman/tests/runTests.py b/repoman/pym/repoman/tests/runTests.py index 759abdd82..3125ff058 100644 --- a/repoman/pym/repoman/tests/runTests.py +++ b/repoman/pym/repoman/tests/runTests.py @@ -3,7 +3,8 @@ # Copyright 2006-2017 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -import os, sys +import os +import sys import os.path as osp import grp import platform
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/phases/
commit: 9d15953ea3e4d59dd17d286066df5f9945c0af19 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:03:33 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:48 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=9d15953e repoman: New linechecks module, phases .../repoman/modules/linechecks/phases/__init__.py | 34 +++ .../pym/repoman/modules/linechecks/phases/phase.py | 71 ++ 2 files changed, 105 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/phases/__init__.py b/repoman/pym/repoman/modules/linechecks/phases/__init__.py new file mode 100644 index 0..476443b25 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/phases/__init__.py @@ -0,0 +1,34 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Phases plug-in module for repoman LineChecks. +Performs phase dependant checks on ebuilds using a PhaseCheck base class. +""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'emakeparallel-check': { + 'name': "emakeparallel", + 'sourcefile': "phase", + 'class': "EMakeParallelDisabled", + 'description': doc, + }, + 'srccompileeconf-check': { + 'name': "srccompileeconf", + 'sourcefile': "phase", + 'class': "SrcCompileEconf", + 'description': doc, + }, + 'srcunpackpatches-check': { + 'name': "srcunpackpatches", + 'sourcefile': "phase", + 'class': "SrcUnpackPatches", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/phases/phase.py b/repoman/pym/repoman/modules/linechecks/phases/phase.py new file mode 100644 index 0..acc3a1e1d --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/phases/phase.py @@ -0,0 +1,71 @@ + +import re + +from portage.eapi import eapi_has_src_prepare_and_src_configure +from repoman.modules.linechecks.base import LineCheck + + +class PhaseCheck(LineCheck): + """ basic class for function detection """ + + func_end_re = re.compile(r'^\}$') + phases_re = re.compile('(%s)' % '|'.join(( + 'pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare', + 'src_configure', 'src_compile', 'src_test', 'src_install', + 'pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm', + 'pkg_config'))) + in_phase = '' + + def check(self, num, line): + m = self.phases_re.match(line) + if m is not None: + self.in_phase = m.group(1) + if self.in_phase != '' and self.func_end_re.match(line) is not None: + self.in_phase = '' + + return self.phase_check(num, line) + + def phase_check(self, num, line): + """ override this function for your checks """ + pass + + +class EMakeParallelDisabled(PhaseCheck): + """Check for emake -j1 calls which disable parallelization.""" + repoman_check_name = 'upstream.workaround' + re = re.compile(r'^\s*emake\s+.*-j\s*1\b') + + def phase_check(self, num, line): + if self.in_phase == 'src_compile' or self.in_phase == 'src_install': + if self.re.match(line): + return self.errors['EMAKE_PARALLEL_DISABLED'] + + +class SrcCompileEconf(PhaseCheck): + repoman_check_name = 'ebuild.minorsyn' + configure_re = re.compile(r'\s(econf|./configure)') + + def check_eapi(self, eapi): + return eapi_has_src_prepare_and_src_configure(eapi) + + def phase_check(self, num, line): + if self.in_phase == 'src_compile': + m = self.configure_re.match(line) + if m is not None: + return ("'%s'" % m.group(1)) + \ + " call should be moved to src_configure from line: %d" + + +class SrcUnpackPatches(PhaseCheck): + repoman_check_name = 'ebuild.minorsyn' + src_prepare_tools_re = re.compile(r'\s(e?patch|sed)\s') + + def check_eapi(self, eapi): + return eapi_has_src_prepare_and_src_configure(eapi) + + def phase_check(self, num, line): + if self.in_phase == 'src_unpack': + m = self.src_prepare_tools_re.search(line) + if m is not None: + return ("'%s'" % m.group(1)) + \ + " call should be moved to src_prepare from line: %d"
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/emake/
commit: 085ac9fefcdd9ec28a9edbbcc86167a5dbfe78ea Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:00:30 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:48 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=085ac9fe repoman: New linechecks module, emake .../repoman/modules/linechecks/emake/__init__.py | 27 ++ .../pym/repoman/modules/linechecks/emake/emake.py | 23 ++ 2 files changed, 50 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/emake/__init__.py b/repoman/pym/repoman/modules/linechecks/emake/__init__.py new file mode 100644 index 0..2e930dae8 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/emake/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Emake plug-in module for repoman LineChecks. +Performs emake checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'paralleldisabled-check': { + 'name': "paralleldisabled", + 'sourcefile': "emake", + 'class': "EMakeParallelDisabledViaMAKEOPTS", + 'description': doc, + }, + 'autodefault-check': { + 'name': "autodefault", + 'sourcefile': "emake", + 'class': "WantAutoDefaultValue", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/emake/emake.py b/repoman/pym/repoman/modules/linechecks/emake/emake.py new file mode 100644 index 0..e1e3e638e --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/emake/emake.py @@ -0,0 +1,23 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EMakeParallelDisabledViaMAKEOPTS(LineCheck): + """Check for MAKEOPTS=-j1 that disables parallelization.""" + repoman_check_name = 'upstream.workaround' + re = re.compile(r'^\s*MAKEOPTS=(\'|")?.*-j\s*1\b') + error = 'EMAKE_PARALLEL_DISABLED_VIA_MAKEOPTS' + + +class WantAutoDefaultValue(LineCheck): + """Check setting WANT_AUTO* to latest (default value).""" + repoman_check_name = 'ebuild.minorsyn' + _re = re.compile(r'^WANT_AUTO(CONF|MAKE)=(\'|")?latest') + + def check(self, num, line): + m = self._re.match(line) + if m is not None: + return 'WANT_AUTO' + m.group(1) + \ + ' redundantly set to default value "latest" on line: %d'
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/whitespace/
commit: 58486c7f12b971460e0efc1a037fe7cd1a9904ac Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:07:13 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:49 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=58486c7f repoman: New linechecks module, whitespace .../modules/linechecks/whitespace/__init__.py | 27 ++ .../repoman/modules/linechecks/whitespace/blank.py | 25 .../modules/linechecks/whitespace/whitespace.py| 21 + 3 files changed, 73 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/whitespace/__init__.py b/repoman/pym/repoman/modules/linechecks/whitespace/__init__.py new file mode 100644 index 0..ded690ed7 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/whitespace/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Whitespace plug-in module for repoman LineChecks. +Performs checks for useless whitespace in ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'whitespace-check': { + 'name': "whitespace", + 'sourcefile': "whitespace", + 'class': "EbuildWhitespace", + 'description': doc, + }, + 'blankline-check': { + 'name': "blankline", + 'sourcefile': "blank", + 'class': "EbuildBlankLine", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/whitespace/blank.py b/repoman/pym/repoman/modules/linechecks/whitespace/blank.py new file mode 100644 index 0..2ab4097a3 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/whitespace/blank.py @@ -0,0 +1,25 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildBlankLine(LineCheck): + repoman_check_name = 'ebuild.minorsyn' + ignore_comment = False + blank_line = re.compile(r'^$') + + def new(self, pkg): + self.line_is_blank = False + + def check(self, num, line): + if self.line_is_blank and self.blank_line.match(line): + return 'Useless blank line on line: %d' + if self.blank_line.match(line): + self.line_is_blank = True + else: + self.line_is_blank = False + + def end(self): + if self.line_is_blank: + yield 'Useless blank line on last line' diff --git a/repoman/pym/repoman/modules/linechecks/whitespace/whitespace.py b/repoman/pym/repoman/modules/linechecks/whitespace/whitespace.py new file mode 100644 index 0..556b2ab81 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/whitespace/whitespace.py @@ -0,0 +1,21 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildWhitespace(LineCheck): + """Ensure ebuilds have proper whitespacing""" + + repoman_check_name = 'ebuild.minorsyn' + + ignore_line = re.compile(r'(^$)|(^(\t)*#)') + ignore_comment = False + leading_spaces = re.compile(r'^[\S\t]') + trailing_whitespace = re.compile(r'.*([\S]$)') + + def check(self, num, line): + if self.leading_spaces.match(line) is None: + return self.errors['LEADING_SPACES_ERROR'] + if self.trailing_whitespace.match(line) is None: + return self.errors['TRAILING_WHITESPACE_ERROR']
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/workaround/
commit: d16e905704065e46f3eeab12dcbb9845937752b0 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:07:59 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:49 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d16e9057 repoman: New linechecks module, workaround .../modules/linechecks/workaround/__init__.py | 27 ++ .../modules/linechecks/workaround/workarounds.py | 18 +++ 2 files changed, 45 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/workaround/__init__.py b/repoman/pym/repoman/modules/linechecks/workaround/__init__.py new file mode 100644 index 0..0b5aa70c8 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/workaround/__init__.py @@ -0,0 +1,27 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Workaround plug-in module for repoman LineChecks. +Performs checks for upstream workarounds in ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'addpredict-check': { + 'name': "addpredict", + 'sourcefile': "workarounds", + 'class': "SandboxAddpredict", + 'description': doc, + }, + 'noasneeded-check': { + 'name': "noasneeded", + 'sourcefile': "workarounds", + 'class': "NoAsNeeded", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/workaround/workarounds.py b/repoman/pym/repoman/modules/linechecks/workaround/workarounds.py new file mode 100644 index 0..37cb54314 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/workaround/workarounds.py @@ -0,0 +1,18 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class NoAsNeeded(LineCheck): + """Check for calls to the no-as-needed function.""" + repoman_check_name = 'upstream.workaround' + re = re.compile(r'.*\$\(no-as-needed\)') + error = 'NO_AS_NEEDED' + + +class SandboxAddpredict(LineCheck): + """Check for calls to the addpredict function.""" + repoman_check_name = 'upstream.workaround' + re = re.compile(r'(^|\s)addpredict\b') + error = 'SANDBOX_ADDPREDICT'
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/tests/
commit: 57f922648264d2a03ec89d5617b9cd4f7ce00507 Author: El Acheche Anis ubuntu com> AuthorDate: Mon Jul 24 04:47:42 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:49 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=57f92264 repoman: repoman/pym/repoman/tests/runTests.py: Fix PEP8 E302 repoman/pym/repoman/tests/runTests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/repoman/pym/repoman/tests/runTests.py b/repoman/pym/repoman/tests/runTests.py index 3125ff058..1795aa487 100644 --- a/repoman/pym/repoman/tests/runTests.py +++ b/repoman/pym/repoman/tests/runTests.py @@ -11,6 +11,7 @@ import platform import pwd import signal + def debug_signal(signum, frame): import pdb pdb.set_trace()
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/tests/
commit: f0264cefabe1d1b684808b6e84f99fa8869d28c1 Author: El Acheche Anis ubuntu com> AuthorDate: Mon Jul 24 04:50:07 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:49 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=f0264cef repoman: repoman/pym/repoman/tests/runTests.py: Fix PEP8 E226 repoman/pym/repoman/tests/runTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repoman/pym/repoman/tests/runTests.py b/repoman/pym/repoman/tests/runTests.py index ca37b14b3..b0e715ec6 100644 --- a/repoman/pym/repoman/tests/runTests.py +++ b/repoman/pym/repoman/tests/runTests.py @@ -35,7 +35,7 @@ repoman_pym = osp.dirname(osp.dirname(osp.dirname(osp.realpath(__file__ sys.path.insert(0, repoman_pym) # Add in the parent portage python modules -portage_pym = osp.dirname(osp.dirname(repoman_pym))+'/pym' +portage_pym = osp.dirname(osp.dirname(repoman_pym)) + '/pym' sys.path.insert(0, portage_pym) # import our centrally initialized portage instance
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/use/
commit: 8d9362457bd7b14158dd7d877e08dd782a9a311f Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:05:56 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:49 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=8d936245 repoman: New linechecks module, use .../pym/repoman/modules/linechecks/use/__init__.py | 21 + .../pym/repoman/modules/linechecks/use/builtwith.py | 10 ++ 2 files changed, 31 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/use/__init__.py b/repoman/pym/repoman/modules/linechecks/use/__init__.py new file mode 100644 index 0..e5665d2d8 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/use/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Use plug-in module for repoman LineChecks. +Performs Built-With-Use checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'builtwith-check': { + 'name': "builtwith", + 'sourcefile': "builtwith", + 'class': "BuiltWithUse", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/use/builtwith.py b/repoman/pym/repoman/modules/linechecks/use/builtwith.py new file mode 100644 index 0..0ec4fae21 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/use/builtwith.py @@ -0,0 +1,10 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class BuiltWithUse(LineCheck): + repoman_check_name = 'ebuild.minorsyn' + re = re.compile(r'(^|.*\b)built_with_use\b') + error = 'BUILT_WITH_USE'
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/helpers/
commit: 4157d8495b10aae37f3c0e1ae73e854066453ba3 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:01:52 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:48 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=4157d849 repoman: New linechecks module, helpers .../repoman/modules/linechecks/helpers/__init__.py | 21 + .../repoman/modules/linechecks/helpers/offset.py | 22 ++ 2 files changed, 43 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/helpers/__init__.py b/repoman/pym/repoman/modules/linechecks/helpers/__init__.py new file mode 100644 index 0..e2d12afe4 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/helpers/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Helpers plug-in module for repoman LineChecks. +Performs variable helpers checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'nooffset-check': { + 'name': "nooffset", + 'sourcefile': "offset", + 'class': "NoOffsetWithHelpers", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/helpers/offset.py b/repoman/pym/repoman/modules/linechecks/helpers/offset.py new file mode 100644 index 0..5d7624a68 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/helpers/offset.py @@ -0,0 +1,22 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class NoOffsetWithHelpers(LineCheck): + """ Check that the image location, the alternate root offset, and the + offset prefix (D, ROOT, ED, EROOT and EPREFIX) are not used with + helpers """ + + repoman_check_name = 'variable.usedwithhelpers' + # Ignore matches in quoted strings like this: + # elog "installed into ${ROOT}usr/share/php5/apc/." + _install_funcs = ( + 'docinto|do(compress|dir|hard)' + '|exeinto|fowners|fperms|insinto|into') + _quoted_vars = 'D|ROOT|ED|EROOT|EPREFIX' + re = re.compile( + r'^[^#"\']*\b(%s)\s+"?\$\{?(%s)\b.*' % + (_install_funcs, _quoted_vars)) + error = 'NO_OFFSET_WITH_HELPERS'
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/gentoo_header/
commit: caafb53fc81e17ce08b833f71b25ae9a8906afa8 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:01:04 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:48 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=caafb53f repoman: New linechecks module, gentoo_header .../modules/linechecks/gentoo_header/__init__.py | 21 ++ .../modules/linechecks/gentoo_header/header.py | 49 ++ 2 files changed, 70 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py b/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py new file mode 100644 index 0..b80a83ecf --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/gentoo_header/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Gentoo-header plug-in module for repoman LineChecks. +Performs header checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'header-check': { + 'name': "gentooheader", + 'sourcefile': "header", + 'class': "EbuildHeader", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py b/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py new file mode 100644 index 0..4b75fc4b5 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/gentoo_header/header.py @@ -0,0 +1,49 @@ + +import re +import time + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildHeader(LineCheck): + """Ensure ebuilds have proper headers + Copyright header errors + CVS header errors + License header errors + + Args: + modification_year - Year the ebuild was last modified + """ + + repoman_check_name = 'ebuild.badheader' + + gentoo_copyright = r'^# Copyright ((1999|2\d\d\d)-)?%s Gentoo Foundation$' + gentoo_license = ( + '# Distributed under the terms' + ' of the GNU General Public License v2') + id_header_re = re.compile(r'.*\$(Id|Header)(:.*)?\$.*') + blank_line_re = re.compile(r'^$') + ignore_comment = False + + def new(self, pkg): + if pkg.mtime is None: + self.modification_year = r'2\d\d\d' + else: + self.modification_year = str(time.gmtime(pkg.mtime)[0]) + self.gentoo_copyright_re = re.compile( + self.gentoo_copyright % self.modification_year) + + def check(self, num, line): + if num > 2: + return + elif num == 0: + if not self.gentoo_copyright_re.match(line): + return self.errors['COPYRIGHT_ERROR'] + elif num == 1 and line.rstrip('\n') != self.gentoo_license: + return self.errors['LICENSE_ERROR'] + elif num == 2 and self.id_header_re.match(line): + return self.errors['ID_HEADER_ERROR'] + elif num == 2 and not self.blank_line_re.match(line): + return self.errors['NO_BLANK_LINE_ERROR'] + +
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/scan/ebuild/
commit: dbae0587378b86266955f16849280d4674590063 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:10:13 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:49 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=dbae0587 repoman: Remove the no longer used modules/scan/ebuild/checks.py repoman/pym/repoman/modules/scan/ebuild/checks.py | 1044 - 1 file changed, 1044 deletions(-) diff --git a/repoman/pym/repoman/modules/scan/ebuild/checks.py b/repoman/pym/repoman/modules/scan/ebuild/checks.py deleted file mode 100644 index de03bedd2..0 --- a/repoman/pym/repoman/modules/scan/ebuild/checks.py +++ /dev/null @@ -1,1044 +0,0 @@ -# -*- coding:utf-8 -*- -# repoman: Checks -# Copyright 2007-2017 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -"""This module contains functions used in Repoman to ascertain the quality -and correctness of an ebuild.""" - -from __future__ import unicode_literals - -from itertools import chain -import operator -import re -import time - -# import our initialized portage instance -from repoman._portage import portage - -from portage.eapi import ( - eapi_supports_prefix, eapi_has_implicit_rdepend, - eapi_has_src_prepare_and_src_configure, eapi_has_dosed_dohard, - eapi_exports_AA, eapi_has_pkg_pretend) - -from . import errors - - -class LineCheck(object): - """Run a check on a line of an ebuild.""" - """A regular expression to determine whether to ignore the line""" - ignore_line = False - """True if lines containing nothing more than comments with optional - leading whitespace should be ignored""" - ignore_comment = True - - def new(self, pkg): - pass - - def check_eapi(self, eapi): - """Returns if check should be run in the given EAPI (default: True)""" - return True - - 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 PhaseCheck(LineCheck): - """ basic class for function detection """ - - func_end_re = re.compile(r'^\}$') - phases_re = re.compile('(%s)' % '|'.join(( - 'pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare', - 'src_configure', 'src_compile', 'src_test', 'src_install', - 'pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm', - 'pkg_config'))) - in_phase = '' - - def check(self, num, line): - m = self.phases_re.match(line) - if m is not None: - self.in_phase = m.group(1) - if self.in_phase != '' and self.func_end_re.match(line) is not None: - self.in_phase = '' - - return self.phase_check(num, line) - - def phase_check(self, num, line): - """ override this function for your checks """ - pass - - -class EbuildHeader(LineCheck): - """Ensure ebuilds have proper headers - Copyright header errors - CVS header errors - License header errors - - Args: - modification_year - Year the ebuild was last modified - """ - - repoman_check_name = 'ebuild.badheader' - - gentoo_copyright = r'^# Copyright ((1999|2\d\d\d)-)?%s Gentoo Foundation$' - gentoo_license = ( - '# Distributed under the terms' - ' of the GNU General Public License v2') - id_header_re = re.compile(r'.*\$(Id|Header)(:.*)?\$.*') - blank_line_re = re.compile(r'^$') - ignore_comment = False - - def new(self, pkg): - if pkg.mtime is None: - self.modification_year = r'2\d\d\d' - else: - self.modification_year = str(time.gmtime(pkg.mtime)[0]) - self.gentoo_copyright_re = re.compile( - self.gentoo_copyright % self.modification_year) - - def check(self, num, line): - if num > 2: - return - elif num == 0: - if not self.gentoo_copyright_re.match(line): - return errors.COPYRIGHT_ERROR - elif num == 1 and line.rstrip('\n') != self.gentoo_license: - return errors.LICENSE_ERROR - elif num == 2 and self.id_header_re.match(line): - return errors.ID_HEADER_ERROR - elif num == 2 and not self.blank_line_re.match(line): - return errors.NO_BLANK_LINE_ERROR - - -class EbuildWhitespace(LineCheck): - """Ensure ebuilds have proper whitespacing""" - - repoman_check_name = 'ebuild.minorsyn' - - ignore_line
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/portage/
commit: cfcba8722c375e4402069882b89cf4bab384812a Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:04:00 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:49 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=cfcba872 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 0..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 0..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
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/modules/linechecks/nested/
commit: d559bddac84ff9e14db7730890be751e124d5340 Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:02:24 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:48 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=d559bdda repoman: New linechecks module, nested .../repoman/modules/linechecks/nested/__init__.py | 21 + .../pym/repoman/modules/linechecks/nested/nested.py | 15 +++ .../repoman/modules/linechecks/nested/nesteddie.py | 11 +++ 3 files changed, 47 insertions(+) diff --git a/repoman/pym/repoman/modules/linechecks/nested/__init__.py b/repoman/pym/repoman/modules/linechecks/nested/__init__.py new file mode 100644 index 0..8eeeccbac --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/nested/__init__.py @@ -0,0 +1,21 @@ +# Copyright 2015-2016 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +doc = """Nested plug-in module for repoman LineChecks. +Performs nested subshell checks on ebuilds.""" +__doc__ = doc[:] + + +module_spec = { + 'name': 'do', + 'description': doc, + 'provides':{ + 'nesteddie-check': { + 'name': "nesteddie", + 'sourcefile': "nested", + 'class': "EbuildNestedDie", + 'description': doc, + }, + } +} + diff --git a/repoman/pym/repoman/modules/linechecks/nested/nested.py b/repoman/pym/repoman/modules/linechecks/nested/nested.py new file mode 100644 index 0..06b272772 --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/nested/nested.py @@ -0,0 +1,15 @@ + +import re + +from repoman.modules.linechecks.base import LineCheck + + +class EbuildNestedDie(LineCheck): + """Check ebuild for nested die statements (die statements in subshells)""" + + repoman_check_name = 'ebuild.nesteddie' + nesteddie_re = re.compile(r'^[^#]*\s\(\s[^)]*\bdie\b') + + def check(self, num, line): + if self.nesteddie_re.match(line): + return self.errors['NESTED_DIE_ERROR'] diff --git a/repoman/pym/repoman/modules/linechecks/nested/nesteddie.py b/repoman/pym/repoman/modules/linechecks/nested/nesteddie.py new file mode 100644 index 0..6c1e4be9f --- /dev/null +++ b/repoman/pym/repoman/modules/linechecks/nested/nesteddie.py @@ -0,0 +1,11 @@ + + +class EbuildNestedDie(LineCheck): + """Check ebuild for nested die statements (die statements in subshells)""" + + repoman_check_name = 'ebuild.nesteddie' + nesteddie_re = re.compile(r'^[^#]*\s\(\s[^)]*\bdie\b') + + def check(self, num, line): + if self.nesteddie_re.match(line): + return errors.NESTED_DIE_ERROR
[gentoo-commits] proj/portage:repoman commit in: repoman/pym/repoman/, repoman/pym/repoman/modules/scan/ebuild/
commit: 5bae7afe1bf95a57a4ec135137a66a4f3047143e Author: Brian Dolbec gentoo org> AuthorDate: Sat Jul 15 01:09:03 2017 + Commit: Brian Dolbec gentoo org> CommitDate: Tue Dec 5 18:24:49 2017 + URL:https://gitweb.gentoo.org/proj/portage.git/commit/?id=5bae7afe repoman: Convert multicheck module to the new linechecks sub-module repoman/pym/repoman/modules/scan/ebuild/__init__.py | 2 +- repoman/pym/repoman/modules/scan/ebuild/multicheck.py | 10 +++--- repoman/pym/repoman/scanner.py| 1 + 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/repoman/pym/repoman/modules/scan/ebuild/__init__.py b/repoman/pym/repoman/modules/scan/ebuild/__init__.py index 3e1d31951..1d8ec1941 100644 --- a/repoman/pym/repoman/modules/scan/ebuild/__init__.py +++ b/repoman/pym/repoman/modules/scan/ebuild/__init__.py @@ -47,7 +47,7 @@ module_spec = { 'functions': ['check'], 'func_kwargs': { }, - 'mod_kwargs': ['qatracker', 'options' + 'mod_kwargs': ['qatracker', 'options', 'repo_settings', 'linechecks', ], 'func_kwargs': { 'ebuild': (None, None), diff --git a/repoman/pym/repoman/modules/scan/ebuild/multicheck.py b/repoman/pym/repoman/modules/scan/ebuild/multicheck.py index 9e36e2a68..94526ae9e 100644 --- a/repoman/pym/repoman/modules/scan/ebuild/multicheck.py +++ b/repoman/pym/repoman/modules/scan/ebuild/multicheck.py @@ -8,7 +8,7 @@ import io from portage import _encodings, _unicode_encode from repoman.modules.scan.scanbase import ScanBase -from .checks import run_checks, checks_init +from repoman.modules.linechecks.controller import LineCheckController class MultiCheck(ScanBase): @@ -22,7 +22,11 @@ class MultiCheck(ScanBase): ''' self.qatracker = kwargs.get('qatracker') self.options = kwargs.get('options') - checks_init(self.options.experimental_inherit == 'y') + self.controller = LineCheckController( + kwargs.get('repo_settings'), + kwargs.get('linechecks') + ) + self.controller.checks_init(self.options.experimental_inherit == 'y') def check(self, **kwargs): '''Check the ebuild for utf-8 encoding @@ -40,7 +44,7 @@ class MultiCheck(ScanBase): errors='strict'), mode='r', encoding=_encodings['repo.content']) try: - for check_name, e in run_checks(f, pkg): + for check_name, e in self.controller.run_checks(f, pkg): self.qatracker.add_error( check_name, ebuild.relative_path + ': %s' % e) finally: diff --git a/repoman/pym/repoman/scanner.py b/repoman/pym/repoman/scanner.py index b3d030570..d61e50131 100644 --- a/repoman/pym/repoman/scanner.py +++ b/repoman/pym/repoman/scanner.py @@ -193,6 +193,7 @@ class Scanner(object): "env": self.env, "have": self.have, "dev_keywords": self.dev_keywords, + "linechecks": self.moduleconfig.linechecks, } # initialize the plugin checks here self.modules = {}