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/pym/repoman/modules/linechecks/deprecated/
Date: Sun, 26 Nov 2017 17:47:18
Message-Id: 1511717538.0db35995f2dec3cf647675b8f46be6f5383af5c1.dolsen@gentoo
1 commit: 0db35995f2dec3cf647675b8f46be6f5383af5c1
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Sat Jul 15 00:19:12 2017 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Sun Nov 26 17:32:18 2017 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=0db35995
7
8 repoman: New linechecks module, deprecated
9
10 .../modules/linechecks/deprecated/__init__.py | 46 +++++++++++++++
11 .../modules/linechecks/deprecated/deprecated.py | 32 +++++++++++
12 .../modules/linechecks/deprecated/inherit.py | 66 ++++++++++++++++++++++
13 3 files changed, 144 insertions(+)
14
15 diff --git a/repoman/pym/repoman/modules/linechecks/deprecated/__init__.py b/repoman/pym/repoman/modules/linechecks/deprecated/__init__.py
16 new file mode 100644
17 index 000000000..8c5f61d49
18 --- /dev/null
19 +++ b/repoman/pym/repoman/modules/linechecks/deprecated/__init__.py
20 @@ -0,0 +1,46 @@
21 +# Copyright 2015-2016 Gentoo Foundation
22 +# Distributed under the terms of the GNU General Public License v2
23 +
24 +doc = """Deprecated plug-in module for repoman LineChecks.
25 +Performs miscelaneous deprecation checks on ebuilds not covered by
26 +specialty modules."""
27 +__doc__ = doc[:]
28 +
29 +
30 +module_spec = {
31 + 'name': 'deprecated',
32 + 'description': doc,
33 + 'provides':{
34 + 'useq-check': {
35 + 'name': "useq",
36 + 'sourcefile': "deprecated",
37 + 'class': "DeprecatedUseq",
38 + 'description': doc,
39 + },
40 + 'hasq-check': {
41 + 'name': "hasq",
42 + 'sourcefile': "deprecated",
43 + 'class': "DeprecatedHasq",
44 + 'description': doc,
45 + },
46 + 'preserve-check': {
47 + 'name': "preservelib",
48 + 'sourcefile': "deprecated",
49 + 'class': "PreserveOldLib",
50 + 'description': doc,
51 + },
52 + 'bindnow-check': {
53 + 'name': "bindnow",
54 + 'sourcefile': "deprecated",
55 + 'class': "DeprecatedBindnowFlags",
56 + 'description': doc,
57 + },
58 + 'inherit-check': {
59 + 'name': "inherit",
60 + 'sourcefile': "inherit",
61 + 'class': "InheritDeprecated",
62 + 'description': doc,
63 + },
64 + }
65 +}
66 +
67
68 diff --git a/repoman/pym/repoman/modules/linechecks/deprecated/deprecated.py b/repoman/pym/repoman/modules/linechecks/deprecated/deprecated.py
69 new file mode 100644
70 index 000000000..b33852e74
71 --- /dev/null
72 +++ b/repoman/pym/repoman/modules/linechecks/deprecated/deprecated.py
73 @@ -0,0 +1,32 @@
74 +
75 +import re
76 +
77 +from repoman.modules.linechecks.base import LineCheck
78 +
79 +
80 +class DeprecatedUseq(LineCheck):
81 + """Checks for use of the deprecated useq function"""
82 + repoman_check_name = 'ebuild.minorsyn'
83 + re = re.compile(r'(^|.*\b)useq\b')
84 + error = 'USEQ_ERROR'
85 +
86 +
87 +class DeprecatedHasq(LineCheck):
88 + """Checks for use of the deprecated hasq function"""
89 + repoman_check_name = 'ebuild.minorsyn'
90 + re = re.compile(r'(^|.*\b)hasq\b')
91 + error = 'HASQ_ERROR'
92 +
93 +
94 +class PreserveOldLib(LineCheck):
95 + """Check for calls to the deprecated preserve_old_lib function."""
96 + repoman_check_name = 'ebuild.minorsyn'
97 + re = re.compile(r'.*preserve_old_lib')
98 + error = 'PRESERVE_OLD_LIB'
99 +
100 +
101 +class DeprecatedBindnowFlags(LineCheck):
102 + """Check for calls to the deprecated bindnow-flags function."""
103 + repoman_check_name = 'ebuild.minorsyn'
104 + re = re.compile(r'.*\$\(bindnow-flags\)')
105 + error = 'DEPRECATED_BINDNOW_FLAGS'
106
107 diff --git a/repoman/pym/repoman/modules/linechecks/deprecated/inherit.py b/repoman/pym/repoman/modules/linechecks/deprecated/inherit.py
108 new file mode 100644
109 index 000000000..8a20f22a4
110 --- /dev/null
111 +++ b/repoman/pym/repoman/modules/linechecks/deprecated/inherit.py
112 @@ -0,0 +1,66 @@
113 +
114 +import re
115 +
116 +from repoman.modules.linechecks.base import LineCheck
117 +
118 +
119 +class InheritDeprecated(LineCheck):
120 + """Check if ebuild directly or indirectly inherits a deprecated eclass."""
121 +
122 + repoman_check_name = 'inherit.deprecated'
123 +
124 + # deprecated eclass : new eclass (False if no new eclass)
125 + deprecated_eclasses = {
126 + "base": False,
127 + "bash-completion": "bash-completion-r1",
128 + "boost-utils": False,
129 + "clutter": "gnome2",
130 + "confutils": False,
131 + "distutils": "distutils-r1",
132 + "games": False,
133 + "gems": "ruby-fakegem",
134 + "gpe": False,
135 + "gst-plugins-bad": "gstreamer",
136 + "gst-plugins-base": "gstreamer",
137 + "gst-plugins-good": "gstreamer",
138 + "gst-plugins-ugly": "gstreamer",
139 + "gst-plugins10": "gstreamer",
140 + "mono": "mono-env",
141 + "python": "python-r1 / python-single-r1 / python-any-r1",
142 + "ruby": "ruby-ng",
143 + "x-modular": "xorg-2",
144 + }
145 +
146 + _inherit_re = re.compile(r'^\s*inherit\s(.*)$')
147 +
148 + def new(self, pkg):
149 + self._errors = []
150 +
151 + def check(self, num, line):
152 + direct_inherits = None
153 + m = self._inherit_re.match(line)
154 + if m is not None:
155 + direct_inherits = m.group(1)
156 + if direct_inherits:
157 + direct_inherits = direct_inherits.split()
158 +
159 + if not direct_inherits:
160 + return
161 +
162 + for eclass in direct_inherits:
163 + replacement = self.deprecated_eclasses.get(eclass)
164 + if replacement is None:
165 + pass
166 + elif replacement is False:
167 + self._errors.append(
168 + "please migrate from "
169 + "'%s' (no replacement) on line: %d" % (eclass, num + 1))
170 + else:
171 + self._errors.append(
172 + "please migrate from "
173 + "'%s' to '%s' on line: %d" % (eclass, replacement, num + 1))
174 +
175 + def end(self):
176 + for error in self._errors:
177 + yield error
178 + del self._errors