commit:     9fc806a9a29433250fb593c5302874bbef74a0c6
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 15 00:19:12 2017 +0000
Commit:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Sat Jul 15 02:08:27 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=9fc806a9

repoman: New linechecks module, deprecated

 .../modules/linechecks/deprecated/__init__.py      | 46 +++++++++++++++
 .../modules/linechecks/deprecated/deprecated.py    | 32 +++++++++++
 .../modules/linechecks/deprecated/inherit.py       | 66 ++++++++++++++++++++++
 3 files changed, 144 insertions(+)

diff --git a/repoman/pym/repoman/modules/linechecks/deprecated/__init__.py 
b/repoman/pym/repoman/modules/linechecks/deprecated/__init__.py
new file mode 100644
index 000000000..8c5f61d49
--- /dev/null
+++ b/repoman/pym/repoman/modules/linechecks/deprecated/__init__.py
@@ -0,0 +1,46 @@
+# Copyright 2015-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+doc = """Deprecated plug-in module for repoman LineChecks.
+Performs miscelaneous deprecation checks on ebuilds not covered by
+specialty modules."""
+__doc__ = doc[:]
+
+
+module_spec = {
+       'name': 'deprecated',
+       'description': doc,
+       'provides':{
+               'useq-check': {
+                       'name': "useq",
+                       'sourcefile': "deprecated",
+                       'class': "DeprecatedUseq",
+                       'description': doc,
+               },
+               'hasq-check': {
+                       'name': "hasq",
+                       'sourcefile': "deprecated",
+                       'class': "DeprecatedHasq",
+                       'description': doc,
+               },
+               'preserve-check': {
+                       'name': "preservelib",
+                       'sourcefile': "deprecated",
+                       'class': "PreserveOldLib",
+                       'description': doc,
+               },
+               'bindnow-check': {
+                       'name': "bindnow",
+                       'sourcefile': "deprecated",
+                       'class': "DeprecatedBindnowFlags",
+                       'description': doc,
+               },
+               'inherit-check': {
+                       'name': "inherit",
+                       'sourcefile': "inherit",
+                       'class': "InheritDeprecated",
+                       'description': doc,
+               },
+       }
+}
+

diff --git a/repoman/pym/repoman/modules/linechecks/deprecated/deprecated.py 
b/repoman/pym/repoman/modules/linechecks/deprecated/deprecated.py
new file mode 100644
index 000000000..b33852e74
--- /dev/null
+++ b/repoman/pym/repoman/modules/linechecks/deprecated/deprecated.py
@@ -0,0 +1,32 @@
+
+import re
+
+from repoman.modules.linechecks.base import LineCheck
+
+
+class DeprecatedUseq(LineCheck):
+       """Checks for use of the deprecated useq function"""
+       repoman_check_name = 'ebuild.minorsyn'
+       re = re.compile(r'(^|.*\b)useq\b')
+       error = 'USEQ_ERROR'
+
+
+class DeprecatedHasq(LineCheck):
+       """Checks for use of the deprecated hasq function"""
+       repoman_check_name = 'ebuild.minorsyn'
+       re = re.compile(r'(^|.*\b)hasq\b')
+       error = 'HASQ_ERROR'
+
+
+class PreserveOldLib(LineCheck):
+       """Check for calls to the deprecated preserve_old_lib function."""
+       repoman_check_name = 'ebuild.minorsyn'
+       re = re.compile(r'.*preserve_old_lib')
+       error = 'PRESERVE_OLD_LIB'
+
+
+class DeprecatedBindnowFlags(LineCheck):
+       """Check for calls to the deprecated bindnow-flags function."""
+       repoman_check_name = 'ebuild.minorsyn'
+       re = re.compile(r'.*\$\(bindnow-flags\)')
+       error = 'DEPRECATED_BINDNOW_FLAGS'

diff --git a/repoman/pym/repoman/modules/linechecks/deprecated/inherit.py 
b/repoman/pym/repoman/modules/linechecks/deprecated/inherit.py
new file mode 100644
index 000000000..8a20f22a4
--- /dev/null
+++ b/repoman/pym/repoman/modules/linechecks/deprecated/inherit.py
@@ -0,0 +1,66 @@
+
+import re
+
+from repoman.modules.linechecks.base import LineCheck
+
+
+class InheritDeprecated(LineCheck):
+       """Check if ebuild directly or indirectly inherits a deprecated 
eclass."""
+
+       repoman_check_name = 'inherit.deprecated'
+
+       # deprecated eclass : new eclass (False if no new eclass)
+       deprecated_eclasses = {
+               "base": False,
+               "bash-completion": "bash-completion-r1",
+               "boost-utils": False,
+               "clutter": "gnome2",
+               "confutils": False,
+               "distutils": "distutils-r1",
+               "games": False,
+               "gems": "ruby-fakegem",
+               "gpe": False,
+               "gst-plugins-bad": "gstreamer",
+               "gst-plugins-base": "gstreamer",
+               "gst-plugins-good": "gstreamer",
+               "gst-plugins-ugly": "gstreamer",
+               "gst-plugins10": "gstreamer",
+               "mono": "mono-env",
+               "python": "python-r1 / python-single-r1 / python-any-r1",
+               "ruby": "ruby-ng",
+               "x-modular": "xorg-2",
+       }
+
+       _inherit_re = re.compile(r'^\s*inherit\s(.*)$')
+
+       def new(self, pkg):
+               self._errors = []
+
+       def check(self, num, line):
+               direct_inherits = None
+               m = self._inherit_re.match(line)
+               if m is not None:
+                       direct_inherits = m.group(1)
+                       if direct_inherits:
+                               direct_inherits = direct_inherits.split()
+
+               if not direct_inherits:
+                       return
+
+               for eclass in direct_inherits:
+                       replacement = self.deprecated_eclasses.get(eclass)
+                       if replacement is None:
+                               pass
+                       elif replacement is False:
+                               self._errors.append(
+                                       "please migrate from "
+                                       "'%s' (no replacement) on line: %d" % 
(eclass, num + 1))
+                       else:
+                               self._errors.append(
+                                       "please migrate from "
+                                       "'%s' to '%s' on line: %d" % (eclass, 
replacement, num + 1))
+
+       def end(self):
+               for error in self._errors:
+                       yield error
+               del self._errors

Reply via email to