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/pym/repoman/modules/linechecks/phases/
Date: Fri, 30 Mar 2018 04:23:46
Message-Id: 1522381878.e464717923ee7bf37c75a0587a8643a569d65068.zmedico@gentoo
1 commit: e464717923ee7bf37c75a0587a8643a569d65068
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jul 15 01:03:33 2017 +0000
4 Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
5 CommitDate: Fri Mar 30 03:51:18 2018 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e4647179
7
8 repoman: New linechecks module, phases
9
10 .../repoman/modules/linechecks/phases/__init__.py | 34 +++++++++++
11 .../pym/repoman/modules/linechecks/phases/phase.py | 71 ++++++++++++++++++++++
12 2 files changed, 105 insertions(+)
13
14 diff --git a/repoman/pym/repoman/modules/linechecks/phases/__init__.py b/repoman/pym/repoman/modules/linechecks/phases/__init__.py
15 new file mode 100644
16 index 000000000..476443b25
17 --- /dev/null
18 +++ b/repoman/pym/repoman/modules/linechecks/phases/__init__.py
19 @@ -0,0 +1,34 @@
20 +# Copyright 2015-2016 Gentoo Foundation
21 +# Distributed under the terms of the GNU General Public License v2
22 +
23 +doc = """Phases plug-in module for repoman LineChecks.
24 +Performs phase dependant checks on ebuilds using a PhaseCheck base class.
25 +"""
26 +__doc__ = doc[:]
27 +
28 +
29 +module_spec = {
30 + 'name': 'do',
31 + 'description': doc,
32 + 'provides':{
33 + 'emakeparallel-check': {
34 + 'name': "emakeparallel",
35 + 'sourcefile': "phase",
36 + 'class': "EMakeParallelDisabled",
37 + 'description': doc,
38 + },
39 + 'srccompileeconf-check': {
40 + 'name': "srccompileeconf",
41 + 'sourcefile': "phase",
42 + 'class': "SrcCompileEconf",
43 + 'description': doc,
44 + },
45 + 'srcunpackpatches-check': {
46 + 'name': "srcunpackpatches",
47 + 'sourcefile': "phase",
48 + 'class': "SrcUnpackPatches",
49 + 'description': doc,
50 + },
51 + }
52 +}
53 +
54
55 diff --git a/repoman/pym/repoman/modules/linechecks/phases/phase.py b/repoman/pym/repoman/modules/linechecks/phases/phase.py
56 new file mode 100644
57 index 000000000..acc3a1e1d
58 --- /dev/null
59 +++ b/repoman/pym/repoman/modules/linechecks/phases/phase.py
60 @@ -0,0 +1,71 @@
61 +
62 +import re
63 +
64 +from portage.eapi import eapi_has_src_prepare_and_src_configure
65 +from repoman.modules.linechecks.base import LineCheck
66 +
67 +
68 +class PhaseCheck(LineCheck):
69 + """ basic class for function detection """
70 +
71 + func_end_re = re.compile(r'^\}$')
72 + phases_re = re.compile('(%s)' % '|'.join((
73 + 'pkg_pretend', 'pkg_setup', 'src_unpack', 'src_prepare',
74 + 'src_configure', 'src_compile', 'src_test', 'src_install',
75 + 'pkg_preinst', 'pkg_postinst', 'pkg_prerm', 'pkg_postrm',
76 + 'pkg_config')))
77 + in_phase = ''
78 +
79 + def check(self, num, line):
80 + m = self.phases_re.match(line)
81 + if m is not None:
82 + self.in_phase = m.group(1)
83 + if self.in_phase != '' and self.func_end_re.match(line) is not None:
84 + self.in_phase = ''
85 +
86 + return self.phase_check(num, line)
87 +
88 + def phase_check(self, num, line):
89 + """ override this function for your checks """
90 + pass
91 +
92 +
93 +class EMakeParallelDisabled(PhaseCheck):
94 + """Check for emake -j1 calls which disable parallelization."""
95 + repoman_check_name = 'upstream.workaround'
96 + re = re.compile(r'^\s*emake\s+.*-j\s*1\b')
97 +
98 + def phase_check(self, num, line):
99 + if self.in_phase == 'src_compile' or self.in_phase == 'src_install':
100 + if self.re.match(line):
101 + return self.errors['EMAKE_PARALLEL_DISABLED']
102 +
103 +
104 +class SrcCompileEconf(PhaseCheck):
105 + repoman_check_name = 'ebuild.minorsyn'
106 + configure_re = re.compile(r'\s(econf|./configure)')
107 +
108 + def check_eapi(self, eapi):
109 + return eapi_has_src_prepare_and_src_configure(eapi)
110 +
111 + def phase_check(self, num, line):
112 + if self.in_phase == 'src_compile':
113 + m = self.configure_re.match(line)
114 + if m is not None:
115 + return ("'%s'" % m.group(1)) + \
116 + " call should be moved to src_configure from line: %d"
117 +
118 +
119 +class SrcUnpackPatches(PhaseCheck):
120 + repoman_check_name = 'ebuild.minorsyn'
121 + src_prepare_tools_re = re.compile(r'\s(e?patch|sed)\s')
122 +
123 + def check_eapi(self, eapi):
124 + return eapi_has_src_prepare_and_src_configure(eapi)
125 +
126 + def phase_check(self, num, line):
127 + if self.in_phase == 'src_unpack':
128 + m = self.src_prepare_tools_re.search(line)
129 + if m is not None:
130 + return ("'%s'" % m.group(1)) + \
131 + " call should be moved to src_prepare from line: %d"