Gentoo Archives: gentoo-commits

From: Zac Medico <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: repoman/cnf/linechecks/, repoman/pym/repoman/modules/linechecks/
Date: Fri, 30 Mar 2018 04:23:58
Message-Id: 1522381881.4d8602ba2f21b3b0a1ad9385fc3c8b8d05276ba7.zmedico@gentoo
1 commit: 4d8602ba2f21b3b0a1ad9385fc3c8b8d05276ba7
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Tue Dec 5 18:17:15 2017 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Fri Mar 30 03:51:21 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=4d8602ba
7
8 repoman linechecks/config.py: Move the errors loading to a new /usr/share/repoman/linechecks directory
9
10 This new directory can be installed to by third party add on modules that extend the checks.
11 We can also in future use these file to get loaclized translations.
12
13 repoman/cnf/linechecks/linechecks.yaml | 35 ++++++++++++++++++++++++
14 repoman/pym/repoman/modules/linechecks/config.py | 19 +++++++++++--
15 2 files changed, 52 insertions(+), 2 deletions(-)
16
17 diff --git a/repoman/cnf/linechecks/linechecks.yaml b/repoman/cnf/linechecks/linechecks.yaml
18 new file mode 100644
19 index 000000000..634381e80
20 --- /dev/null
21 +++ b/repoman/cnf/linechecks/linechecks.yaml
22 @@ -0,0 +1,35 @@
23 +---
24 +# linecheck_help.yaml
25 +
26 +# Repoman API version (do not edit)
27 +version: 1
28 +# minimum
29 +repoman_version: 2.3.3
30 +
31 +# configuration file for the LineCheck plugins run via the multicheck
32 +# scan module
33 +errors:
34 + COPYRIGHT_ERROR: 'Invalid Gentoo Copyright on line: %d'
35 + LICENSE_ERROR: 'Invalid Gentoo/GPL License on line: %d'
36 + ID_HEADER_ERROR: 'Stale CVS header on line: %d'
37 + NO_BLANK_LINE_ERROR: 'Non-blank line after header on line: %d'
38 + LEADING_SPACES_ERROR: 'Ebuild contains leading spaces on line: %d'
39 + TRAILING_WHITESPACE_ERROR: 'Trailing whitespace error on line: %d'
40 + READONLY_ASSIGNMENT_ERROR: 'Ebuild contains assignment to read-only variable on line: %d'
41 + MISSING_QUOTES_ERROR: 'Unquoted Variable on line: %d'
42 + NESTED_DIE_ERROR: 'Ebuild calls die in a subshell on line: %d'
43 + PATCHES_ERROR: 'PATCHES is not a bash array on line: %d'
44 + REDUNDANT_CD_S_ERROR: 'Ebuild has redundant cd ${S} statement on line: %d'
45 + EMAKE_PARALLEL_DISABLED: 'Upstream parallel compilation bug (ebuild calls emake -j1 on line: %d)'
46 + EMAKE_PARALLEL_DISABLED_VIA_MAKEOPTS: 'Upstream parallel compilation bug (MAKEOPTS=-j1 on line: %d)'
47 + DEPRECATED_BINDNOW_FLAGS: 'Deprecated bindnow-flags call on line: %d'
48 + EAPI_DEFINED_AFTER_INHERIT: 'EAPI defined after inherit on line: %d'
49 + NO_AS_NEEDED: 'Upstream asneeded linking bug (no-as-needed on line: %d)'
50 + PRESERVE_OLD_LIB: 'Ebuild calls deprecated preserve_old_lib on line: %d'
51 + BUILT_WITH_USE: 'built_with_use on line: %d'
52 + NO_OFFSET_WITH_HELPERS: 'Helper function is used with D, ROOT, ED, EROOT or EPREFIX on line: %d'
53 + SANDBOX_ADDPREDICT: 'Ebuild calls addpredict on line: %d'
54 + USEQ_ERROR: 'Ebuild calls deprecated useq function on line: %d'
55 + HASQ_ERROR: 'Ebuild calls deprecated hasq function on line: %d'
56 + URI_HTTPS: 'Ebuild uses http:// but should use https:// on line: %d'
57 +
58
59 diff --git a/repoman/pym/repoman/modules/linechecks/config.py b/repoman/pym/repoman/modules/linechecks/config.py
60 index bde2e587f..6e4c5314e 100644
61 --- a/repoman/pym/repoman/modules/linechecks/config.py
62 +++ b/repoman/pym/repoman/modules/linechecks/config.py
63 @@ -15,6 +15,7 @@ from copy import deepcopy
64
65 from repoman._portage import portage
66 from repoman.config import load_config
67 +from repoman import _not_installed
68
69 # Avoid a circular import issue in py2.7
70 portage.proxy.lazyimport.lazyimport(globals(),
71 @@ -46,8 +47,7 @@ class LineChecksConfig(object):
72 @param configpaths: ordered list of filepaths to load
73 '''
74 self.repo_settings = repo_settings
75 - self.infopaths = [os.path.join(path, 'linechecks.yaml') for path in self.repo_settings.masters_list]
76 - logging.debug("LineChecksConfig; configpaths: %s", self.infopaths)
77 + self.infopaths = None
78 self.info_config = None
79 self._config = None
80 self.usex_supported_eapis = None
81 @@ -58,8 +58,22 @@ class LineChecksConfig(object):
82 self.eclass_info = {}
83 self.eclass_info_experimental_inherit = {}
84 self.errors = {}
85 + self.set_infopaths()
86 self.load_checks_info()
87
88 + def set_infopaths(self):
89 + if _not_installed:
90 + cnfdir = os.path.realpath(os.path.join(os.path.dirname(
91 + os.path.dirname(os.path.dirname(os.path.dirname(
92 + os.path.dirname(__file__))))), 'cnf/linechecks'))
93 + else:
94 + cnfdir = os.path.join(portage.const.EPREFIX or '/', 'usr/share/repoman/linechecks')
95 + repomanpaths = [os.path.join(cnfdir, _file_) for _file_ in os.listdir(cnfdir)]
96 + logging.debug("LineChecksConfig; repomanpaths: %s", repomanpaths)
97 + repopaths = [os.path.join(path, 'linechecks.yaml') for path in self.repo_settings.masters_list]
98 + self.infopaths = repomanpaths + repopaths
99 + logging.debug("LineChecksConfig; configpaths: %s", self.infopaths)
100 +
101 def load_checks_info(self, infopaths=None):
102 '''load the config files in order
103
104 @@ -69,6 +83,7 @@ class LineChecksConfig(object):
105 self.infopaths = infopaths
106 elif not self.infopaths:
107 logging.error("LineChecksConfig; Error: No linechecks.yaml files defined")
108 +
109 configs = load_config(self.infopaths, 'yaml', self.repo_settings.repoman_settings.valid_versions)
110 if configs == {}:
111 logging.error("LineChecksConfig: Failed to load a valid 'linechecks.yaml' file at paths: %s", self.infopaths)