From fa9ea7414547a3ccc262cf91e471971c75968014 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Mon, 12 Aug 2013 13:54:12 -0700 Subject: [PATCH] repoman: add --experimental-inherit= option Enable experimental inherit.missing checks which may misbehave when the internal eclass database becomes outdated. --- bin/repoman | 15 ++++++++--- man/repoman.1 | 4 +++ pym/portage/const.py | 1 - pym/repoman/checks.py | 63 ++++++++++++++++++++++++------------------- 4 files changed, 50 insertions(+), 33 deletions(-) diff --git a/bin/repoman b/bin/repoman index 2f489341b..731509db3 100755 --- a/bin/repoman +++ b/bin/repoman @@ -56,6 +56,7 @@ except (ImportError, SystemError, RuntimeError, Exception): from portage import os from portage import _encodings from portage import _unicode_encode +import repoman.checks from repoman.checks import run_checks from repoman import utilities from repoman.herdbase import make_herd_base @@ -174,6 +175,11 @@ def ParseArgs(argv, qahelp): help='for commit mode, call echangelog if ChangeLog is unmodified (or ' 'regardless of modification if \'force\' is specified)') + parser.add_argument('--experimental-inherit', choices=('y', 'n'), + metavar="", default='n', + help='Enable experimental inherit.missing checks which may misbehave' + ' when the internal eclass database becomes outdated') + parser.add_argument('-f', '--force', dest='force', default=False, action='store_true', help='Commit with QA violations') @@ -396,10 +402,6 @@ qawarnings = set(( "IUSE.rubydeprecated", )) -if portage.const._ENABLE_INHERIT_CHECK: - # This is experimental, so it's non-fatal. - qawarnings.add("inherit.missing") - non_ascii_re = re.compile(r'[^\x00-\x7f]') missingvars = ["KEYWORDS", "LICENSE", "DESCRIPTION", "HOMEPAGE"] @@ -499,6 +501,11 @@ if options.version: print("Portage", portage.VERSION) sys.exit(0) +if options.experimental_inherit == 'y': + # This is experimental, so it's non-fatal. + qawarnings.add("inherit.missing") + repoman.checks._init(experimental_inherit=True) + # Set this to False when an extraordinary issue (generally # something other than a QA issue) makes it impossible to # commit (like if Manifest generation fails). diff --git a/man/repoman.1 b/man/repoman.1 index d4ced1dfb..3a0477145 100644 --- a/man/repoman.1 +++ b/man/repoman.1 @@ -65,6 +65,10 @@ can be enabled by default for a particular repository by setting "update\-changelog = true" in metadata/layout.conf (see \fBportage(5)\fR). .TP +\fB\-\-experimental\-inherit=\fR +Enable experimental inherit.missing checks which may misbehave when the +internal eclass database becomes outdated. +.TP \fB\-\-if\-modified=\fR Only check packages that have uncommitted modifications .TP diff --git a/pym/portage/const.py b/pym/portage/const.py index 1f660a1f2..0638170f3 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -182,4 +182,3 @@ SUPPORTED_BINPKG_FORMATS = ("tar", "rpm") _DEPCLEAN_LIB_CHECK_DEFAULT = True _ENABLE_REPO_NAME_WARN = True _ENABLE_SET_CONFIG = True -_ENABLE_INHERIT_CHECK = True diff --git a/pym/repoman/checks.py b/pym/repoman/checks.py index c60db3d02..85aa065cb 100644 --- a/pym/repoman/checks.py +++ b/pym/repoman/checks.py @@ -16,7 +16,6 @@ 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 -from portage.const import _ENABLE_INHERIT_CHECK class LineCheck(object): """Run a check on a line of an ebuild.""" @@ -635,29 +634,6 @@ _eclass_info = { } } -if not _ENABLE_INHERIT_CHECK: - # Since the InheritEclass check is experimental, in the stable branch - # we emulate the old eprefixify.defined and inherit.autotools checks. - _eclass_info = { - 'autotools': { - 'funcs': ( - 'eaclocal', 'eautoconf', 'eautoheader', - 'eautomake', 'eautoreconf', '_elibtoolize', - 'eautopoint' - ), - 'comprehensive': True, - 'ignore_missing': True, - 'exempt_eclasses': ('git', 'git-2', 'subversion', 'autotools-utils') - }, - - 'prefix': { - 'funcs': ( - 'eprefixify', - ), - 'comprehensive': False - } - } - class EMakeParallelDisabled(PhaseCheck): """Check for emake -j1 calls which disable parallelization.""" repoman_check_name = 'upstream.workaround' @@ -824,10 +800,39 @@ class PortageInternalVariableAssignment(LineCheck): return e _base_check_classes = (InheritEclass, LineCheck, PhaseCheck) -_constant_checks = tuple(chain((v() for k, v in globals().items() - if isinstance(v, type) and issubclass(v, LineCheck) and v not in _base_check_classes), - (InheritEclass(k, **portage._native_kwargs(kwargs)) - for k, kwargs in _eclass_info.items()))) +_constant_checks = None + +def _init(experimental_inherit=False): + + global _constant_checks, _eclass_info + + if not experimental_inherit: + # Emulate the old eprefixify.defined and inherit.autotools checks. + _eclass_info = { + 'autotools': { + 'funcs': ( + 'eaclocal', 'eautoconf', 'eautoheader', + 'eautomake', 'eautoreconf', '_elibtoolize', + 'eautopoint' + ), + 'comprehensive': True, + 'ignore_missing': True, + 'exempt_eclasses': ('git', 'git-2', 'subversion', 'autotools-utils') + }, + + 'prefix': { + 'funcs': ( + 'eprefixify', + ), + 'comprehensive': False + } + } + + _constant_checks = tuple(chain((v() for k, v in globals().items() + if isinstance(v, type) and issubclass(v, LineCheck) and + v not in _base_check_classes), + (InheritEclass(k, **portage._native_kwargs(kwargs)) + for k, kwargs in _eclass_info.items()))) _here_doc_re = re.compile(r'.*\s<<[-]?(\w+)$') _ignore_comment_re = re.compile(r'^\s*#') @@ -835,6 +840,8 @@ _ignore_comment_re = re.compile(r'^\s*#') def run_checks(contents, pkg): unicode_escape_codec = codecs.lookup('unicode_escape') unicode_escape = lambda x: unicode_escape_codec.decode(x)[0] + if _constant_checks is None: + _init() checks = _constant_checks here_doc_delim = None multiline = None -- 2.26.2