1 |
commit: a67a1444d90a8d764200063461d7c5dd37d53c1a |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Jan 8 01:29:42 2016 +0000 |
4 |
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Jan 27 22:44:21 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=a67a1444 |
7 |
|
8 |
repoman: Create the ThirdPartyMirrors class plugin |
9 |
|
10 |
pym/repoman/checks/ebuilds/thirdpartymirrors.py | 39 -------------- |
11 |
pym/repoman/modules/scan/mirrors/__init__.py | 24 +++++++++ |
12 |
.../modules/scan/mirrors/thirdpartymirrors.py | 59 ++++++++++++++++++++++ |
13 |
pym/repoman/scanner.py | 6 +-- |
14 |
4 files changed, 86 insertions(+), 42 deletions(-) |
15 |
|
16 |
diff --git a/pym/repoman/checks/ebuilds/thirdpartymirrors.py b/pym/repoman/checks/ebuilds/thirdpartymirrors.py |
17 |
deleted file mode 100644 |
18 |
index 848dfb9..0000000 |
19 |
--- a/pym/repoman/checks/ebuilds/thirdpartymirrors.py |
20 |
+++ /dev/null |
21 |
@@ -1,39 +0,0 @@ |
22 |
-# -*- coding:utf-8 -*- |
23 |
- |
24 |
-# import our initialized portage instance |
25 |
-from repoman._portage import portage |
26 |
- |
27 |
- |
28 |
-class ThirdPartyMirrors(object): |
29 |
- |
30 |
- def __init__(self, repoman_settings, qatracker): |
31 |
- # TODO: Build a regex instead here, for the SRC_URI.mirror check. |
32 |
- self.thirdpartymirrors = {} |
33 |
- profile_thirdpartymirrors = repoman_settings.thirdpartymirrors().items() |
34 |
- for mirror_alias, mirrors in profile_thirdpartymirrors: |
35 |
- for mirror in mirrors: |
36 |
- if not mirror.endswith("/"): |
37 |
- mirror += "/" |
38 |
- self.thirdpartymirrors[mirror] = mirror_alias |
39 |
- |
40 |
- self.qatracker = qatracker |
41 |
- |
42 |
- def check(self, myaux, relative_path): |
43 |
- # Check that URIs don't reference a server from thirdpartymirrors. |
44 |
- for uri in portage.dep.use_reduce( |
45 |
- myaux["SRC_URI"], matchall=True, is_src_uri=True, |
46 |
- eapi=myaux["EAPI"], flat=True): |
47 |
- contains_mirror = False |
48 |
- for mirror, mirror_alias in self.thirdpartymirrors.items(): |
49 |
- if uri.startswith(mirror): |
50 |
- contains_mirror = True |
51 |
- break |
52 |
- if not contains_mirror: |
53 |
- continue |
54 |
- |
55 |
- new_uri = "mirror://%s/%s" % (mirror_alias, uri[len(mirror):]) |
56 |
- self.qatracker.add_error( |
57 |
- "SRC_URI.mirror", |
58 |
- "%s: '%s' found in thirdpartymirrors, use '%s'" % ( |
59 |
- relative_path, mirror, new_uri)) |
60 |
- return |
61 |
|
62 |
diff --git a/pym/repoman/modules/scan/mirrors/__init__.py b/pym/repoman/modules/scan/mirrors/__init__.py |
63 |
new file mode 100644 |
64 |
index 0000000..6bf7d2d |
65 |
--- /dev/null |
66 |
+++ b/pym/repoman/modules/scan/mirrors/__init__.py |
67 |
@@ -0,0 +1,24 @@ |
68 |
+# Copyright 2015-2016 Gentoo Foundation |
69 |
+# Distributed under the terms of the GNU General Public License v2 |
70 |
+ |
71 |
+doc = """Mirrors plug-in module for repoman. |
72 |
+Performs third party mirrors checks on ebuilds.""" |
73 |
+__doc__ = doc[:] |
74 |
+ |
75 |
+ |
76 |
+module_spec = { |
77 |
+ 'name': 'mirrors', |
78 |
+ 'description': doc, |
79 |
+ 'provides':{ |
80 |
+ 'mirrors-module': { |
81 |
+ 'name': "thirdpartymirrors", |
82 |
+ 'sourcefile': "thirdpartymirrors", |
83 |
+ 'class': "ThirdPartyMirrors", |
84 |
+ 'description': doc, |
85 |
+ 'functions': ['check'], |
86 |
+ 'func_desc': { |
87 |
+ }, |
88 |
+ }, |
89 |
+ } |
90 |
+} |
91 |
+ |
92 |
|
93 |
diff --git a/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py b/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py |
94 |
new file mode 100644 |
95 |
index 0000000..9404e28 |
96 |
--- /dev/null |
97 |
+++ b/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py |
98 |
@@ -0,0 +1,59 @@ |
99 |
+# -*- coding:utf-8 -*- |
100 |
+ |
101 |
+# import our initialized portage instance |
102 |
+from repoman._portage import portage |
103 |
+from repoman.modules.scan.scanbase import ScanBase |
104 |
+ |
105 |
+ |
106 |
+class ThirdPartyMirrors(ScanBase): |
107 |
+ |
108 |
+ def __init__(self, **kwargs): |
109 |
+ '''Class init |
110 |
+ |
111 |
+ @param repo_settings: settings instance |
112 |
+ @param qatracker: QATracker instance |
113 |
+ ''' |
114 |
+ super(ThirdPartyMirrors, self).__init__(**kwargs) |
115 |
+ repo_settings = kwargs.get('repo_settings') |
116 |
+ self.qatracker = kwargs.get('qatracker') |
117 |
+ |
118 |
+ # TODO: Build a regex instead here, for the SRC_URI.mirror check. |
119 |
+ self.thirdpartymirrors = {} |
120 |
+ profile_thirdpartymirrors = repo_settings.repoman_settings.thirdpartymirrors().items() |
121 |
+ for mirror_alias, mirrors in profile_thirdpartymirrors: |
122 |
+ for mirror in mirrors: |
123 |
+ if not mirror.endswith("/"): |
124 |
+ mirror += "/" |
125 |
+ self.thirdpartymirrors[mirror] = mirror_alias |
126 |
+ |
127 |
+ def check(self, **kwargs): |
128 |
+ '''Check that URIs don't reference a server from thirdpartymirrors |
129 |
+ |
130 |
+ @param ebuild: Ebuild which we check (object). |
131 |
+ @param src_uri_error: boolean |
132 |
+ ''' |
133 |
+ ebuild = kwargs.get('ebuild') |
134 |
+ if kwargs.get('src_uri_error'): |
135 |
+ return {'continue': True} |
136 |
+ for uri in portage.dep.use_reduce( |
137 |
+ ebuild.metadata["SRC_URI"], matchall=True, is_src_uri=True, |
138 |
+ eapi=ebuild.eapi, flat=True): |
139 |
+ contains_mirror = False |
140 |
+ for mirror, mirror_alias in self.thirdpartymirrors.items(): |
141 |
+ if uri.startswith(mirror): |
142 |
+ contains_mirror = True |
143 |
+ break |
144 |
+ if not contains_mirror: |
145 |
+ continue |
146 |
+ |
147 |
+ new_uri = "mirror://%s/%s" % (mirror_alias, uri[len(mirror):]) |
148 |
+ self.qatracker.add_error( |
149 |
+ "SRC_URI.mirror", |
150 |
+ "%s: '%s' found in thirdpartymirrors, use '%s'" % ( |
151 |
+ ebuild.relative_path, mirror, new_uri)) |
152 |
+ return {'continue': False} |
153 |
+ |
154 |
+ @property |
155 |
+ def runInEbuilds(self): |
156 |
+ '''Ebuild level scans''' |
157 |
+ return (True, [self.check]) |
158 |
|
159 |
diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py |
160 |
index abff1af..29edcd8 100644 |
161 |
--- a/pym/repoman/scanner.py |
162 |
+++ b/pym/repoman/scanner.py |
163 |
@@ -19,7 +19,6 @@ from portage.dep import Atom |
164 |
from portage.output import green |
165 |
from repoman.checks.ebuilds.checks import run_checks |
166 |
from repoman.checks.ebuilds.eclasses.ruby import RubyEclassChecks |
167 |
-from repoman.checks.ebuilds.thirdpartymirrors import ThirdPartyMirrors |
168 |
from repoman.check_missingslot import check_missingslot |
169 |
from repoman.checks.ebuilds.use_flags import USEFlagChecks |
170 |
from repoman.checks.ebuilds.variables.description import DescriptionChecks |
171 |
@@ -218,7 +217,6 @@ class Scanner(object): |
172 |
self.modules[mod_class.__name__] = mod_class(**self.kwargs) |
173 |
|
174 |
# initialize our checks classes here before the big xpkg loop |
175 |
- self.thirdparty = ThirdPartyMirrors(self.repo_settings.repoman_settings, self.qatracker) |
176 |
self.use_flag_checks = USEFlagChecks(self.qatracker, uselist) |
177 |
self.rubyeclasscheck = RubyEclassChecks(self.qatracker) |
178 |
self.descriptioncheck = DescriptionChecks(self.qatracker) |
179 |
@@ -304,7 +302,9 @@ class Scanner(object): |
180 |
# initialize per ebuild plugin checks here |
181 |
# need to set it up for ==> self.modules_list or some other ordered list |
182 |
for mod in [('ebuild', 'Ebuild'), ('live', 'LiveEclassChecks'), |
183 |
- ('eapi', 'EAPIChecks'), ('ebuild_metadata', 'EbuildMetadata')]: |
184 |
+ ('eapi', 'EAPIChecks'), ('ebuild_metadata', 'EbuildMetadata'), |
185 |
+ ('thirdpartymirrors', 'ThirdPartyMirrors'), |
186 |
+ ]: |
187 |
if mod[0]: |
188 |
mod_class = MODULE_CONTROLLER.get_class(mod[0]) |
189 |
logging.debug("Initializing class name: %s", mod_class.__name__) |