Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:repoman commit in: repoman/cnf/linechecks/, repoman/pym/repoman/modules/linechecks/
Date: Tue, 05 Dec 2017 18:32:24
Message-Id: 1512498514.bbe75657cc32aeb402a6ff78eba7bd05a3c87424.dolsen@gentoo
1 commit: bbe75657cc32aeb402a6ff78eba7bd05a3c87424
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Tue Dec 5 18:17:15 2017 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Tue Dec 5 18:28:34 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=bbe75657
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 | 21 ++++++++++++--
15 2 files changed, 53 insertions(+), 3 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 52a9a786b..be58c799c 100644
61 --- a/repoman/pym/repoman/modules/linechecks/config.py
62 +++ b/repoman/pym/repoman/modules/linechecks/config.py
63 @@ -14,6 +14,8 @@ import os
64 import yaml
65 from copy import deepcopy
66
67 +from repoman import _not_installed
68 +from repoman import _portage
69 from portage.util import stack_lists
70 from repoman.config import load_config
71
72 @@ -42,8 +44,7 @@ class LineChecksConfig(object):
73 @param configpaths: ordered list of filepaths to load
74 '''
75 self.repo_settings = repo_settings
76 - self.infopaths = [os.path.join(path, 'linechecks.yaml') for path in self.repo_settings.masters_list]
77 - logging.debug("LineChecksConfig; configpaths: %s", self.infopaths)
78 + self.infopaths = None
79 self.info_config = None
80 self._config = None
81 self.usex_supported_eapis = None
82 @@ -54,18 +55,32 @@ class LineChecksConfig(object):
83 self.eclass_info = {}
84 self.eclass_info_experimental_inherit = {}
85 self.errors = {}
86 + self.set_infopaths()
87 self.load_checks_info()
88
89 + def set_infopaths(self):
90 + if _not_installed:
91 + cnfdir = os.path.realpath(os.path.join(os.path.dirname(
92 + os.path.dirname(os.path.dirname(os.path.dirname(
93 + os.path.dirname(__file__))))), 'cnf/linechecks'))
94 + else:
95 + cnfdir = os.path.join(_portage.portage.const.EPREFIX, 'usr/share/repoman/linechecks')
96 + repomanpaths = [os.path.join(cnfdir, _file_) for _file_ in os.listdir(cnfdir)]
97 + logging.debug("LineChecksConfig; repomanpaths: %s", repomanpaths)
98 + repopaths = [os.path.join(path, 'linechecks.yaml') for path in self.repo_settings.masters_list]
99 + self.infopaths = repomanpaths + repopaths
100 + logging.debug("LineChecksConfig; configpaths: %s", self.infopaths)
101
102 def load_checks_info(self, infopaths=None):
103 '''load the config files in order
104
105 - @param configpaths: ordered list of filepaths to load
106 + @param infopaths: ordered list of filepaths to load
107 '''
108 if infopaths:
109 self.infopaths = infopaths
110 elif not self.infopaths:
111 logging.error("LineChecksConfig; Error: No linechecks.yaml files defined")
112 +
113 configs = load_config(self.infopaths, 'yaml', self.repo_settings.repoman_settings.valid_versions)
114 if configs == {}:
115 logging.error("LineChecksConfig: Failed to load a valid 'linechecks.yaml' file at paths: %s", self.infopaths)