Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/repoman/, pym/repoman/modules/scan/fetch/, pym/repoman/modules/scan/mirrors/
Date: Fri, 29 Apr 2016 17:25:23
Message-Id: 1461604511.64b58270e5dc1c9f4aa2267a6bf3ab8117d0d44c.dolsen@gentoo
1 commit: 64b58270e5dc1c9f4aa2267a6bf3ab8117d0d44c
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Mon Apr 25 17:14:16 2016 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Mon Apr 25 17:15:11 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=64b58270
7
8 repoman: Move thirdpartymirror check to the fetches module
9
10 This check should be part of the FetchChecks class.
11 This removes 'src_uri_error' Future need.
12
13 pym/repoman/modules/scan/fetch/__init__.py | 2 +-
14 pym/repoman/modules/scan/fetch/fetches.py | 45 ++++++++++++++--
15 pym/repoman/modules/scan/mirrors/__init__.py | 30 -----------
16 .../modules/scan/mirrors/thirdpartymirrors.py | 61 ----------------------
17 pym/repoman/scanner.py | 2 +-
18 5 files changed, 43 insertions(+), 97 deletions(-)
19
20 diff --git a/pym/repoman/modules/scan/fetch/__init__.py b/pym/repoman/modules/scan/fetch/__init__.py
21 index 1228435..3c8e600 100644
22 --- a/pym/repoman/modules/scan/fetch/__init__.py
23 +++ b/pym/repoman/modules/scan/fetch/__init__.py
24 @@ -24,7 +24,7 @@ module_spec = {
25 'changed': (None, None),
26 'checkdir': (None, None),
27 'checkdir_relative': (None, None),
28 - 'src_uri_error': ('Future', 'UNSET'),
29 + 'ebuild': (None, None),
30 'xpkg': (None, None),
31 },
32 },
33
34 diff --git a/pym/repoman/modules/scan/fetch/fetches.py b/pym/repoman/modules/scan/fetch/fetches.py
35 index ddbf6bd..555f34f 100644
36 --- a/pym/repoman/modules/scan/fetch/fetches.py
37 +++ b/pym/repoman/modules/scan/fetch/fetches.py
38 @@ -32,13 +32,22 @@ class FetchChecks(ScanBase):
39 self.vcs_settings = kwargs.get('vcs_settings')
40 self._src_uri_error = False
41
42 + # TODO: Build a regex instead here, for the SRC_URI.mirror check.
43 + self.thirdpartymirrors = {}
44 + profile_thirdpartymirrors = self.repo_settings.repoman_settings.thirdpartymirrors().items()
45 + for mirror_alias, mirrors in profile_thirdpartymirrors:
46 + for mirror in mirrors:
47 + if not mirror.endswith("/"):
48 + mirror += "/"
49 + self.thirdpartymirrors[mirror] = mirror_alias
50 +
51 def check(self, **kwargs):
52 '''Checks the ebuild sources and files for errors
53
54 @param xpkg: the pacakge being checked
55 @param checkdir: string, directory path
56 @param checkdir_relative: repolevel determined path
57 - @returns: dictionary, including {src_uri_error}
58 + @returns: boolean
59 '''
60 xpkg = kwargs.get('xpkg')
61 checkdir = kwargs.get('checkdir')
62 @@ -130,9 +139,6 @@ class FetchChecks(ScanBase):
63 self.qatracker.add_error(
64 "file.name",
65 "%s/files/%s: char '%s'" % (checkdir, y, y[index]))
66 - # update the dynamic data
67 - dyn_src_uri_error = kwargs.get('src_uri_error')
68 - dyn_src_uri_error.set(self._src_uri_error)
69 return False
70
71 def digests(self, checkdir):
72 @@ -147,7 +153,38 @@ class FetchChecks(ScanBase):
73 del mf
74 return _digests
75
76 + def check_mirrors(self, **kwargs):
77 + '''Check that URIs don't reference a server from thirdpartymirrors
78 +
79 + @param ebuild: Ebuild which we check (object).
80 + @returns: boolean
81 + '''
82 + ebuild = kwargs.get('ebuild').get()
83 +
84 + for uri in portage.dep.use_reduce(
85 + ebuild.metadata["SRC_URI"], matchall=True, is_src_uri=True,
86 + eapi=ebuild.eapi, flat=True):
87 + contains_mirror = False
88 + for mirror, mirror_alias in self.thirdpartymirrors.items():
89 + if uri.startswith(mirror):
90 + contains_mirror = True
91 + break
92 + if not contains_mirror:
93 + continue
94 +
95 + new_uri = "mirror://%s/%s" % (mirror_alias, uri[len(mirror):])
96 + self.qatracker.add_error(
97 + "SRC_URI.mirror",
98 + "%s: '%s' found in thirdpartymirrors, use '%s'" % (
99 + ebuild.relative_path, mirror, new_uri))
100 + return False
101 +
102 @property
103 def runInPkgs(self):
104 '''Package level scans'''
105 return (True, [self.check])
106 +
107 + @property
108 + def runInEbuilds(self):
109 + '''Ebuild level scans'''
110 + return (True, [self.check_mirrors])
111
112 diff --git a/pym/repoman/modules/scan/mirrors/__init__.py b/pym/repoman/modules/scan/mirrors/__init__.py
113 deleted file mode 100644
114 index 94ded6d..0000000
115 --- a/pym/repoman/modules/scan/mirrors/__init__.py
116 +++ /dev/null
117 @@ -1,30 +0,0 @@
118 -# Copyright 2015-2016 Gentoo Foundation
119 -# Distributed under the terms of the GNU General Public License v2
120 -
121 -doc = """Mirrors plug-in module for repoman.
122 -Performs third party mirrors checks on ebuilds."""
123 -__doc__ = doc[:]
124 -
125 -
126 -module_spec = {
127 - 'name': 'mirrors',
128 - 'description': doc,
129 - 'provides':{
130 - 'mirrors-module': {
131 - 'name': "thirdpartymirrors",
132 - 'sourcefile': "thirdpartymirrors",
133 - 'class': "ThirdPartyMirrors",
134 - 'description': doc,
135 - 'functions': ['check'],
136 - 'func_desc': {
137 - },
138 - 'mod_kwargs': ['repo_settings', 'qatracker',
139 - ],
140 - 'func_kwargs': {
141 - 'ebuild': (None, None),
142 - 'src_uri_error': (None, None),
143 - },
144 - },
145 - }
146 -}
147 -
148
149 diff --git a/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py b/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py
150 deleted file mode 100644
151 index 9118d59..0000000
152 --- a/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py
153 +++ /dev/null
154 @@ -1,61 +0,0 @@
155 -# -*- coding:utf-8 -*-
156 -
157 -# import our initialized portage instance
158 -from repoman._portage import portage
159 -from repoman.modules.scan.scanbase import ScanBase
160 -
161 -
162 -class ThirdPartyMirrors(ScanBase):
163 -
164 - def __init__(self, **kwargs):
165 - '''Class init
166 -
167 - @param repo_settings: settings instance
168 - @param qatracker: QATracker instance
169 - '''
170 - super(ThirdPartyMirrors, self).__init__(**kwargs)
171 - repo_settings = kwargs.get('repo_settings')
172 - self.qatracker = kwargs.get('qatracker')
173 -
174 - # TODO: Build a regex instead here, for the SRC_URI.mirror check.
175 - self.thirdpartymirrors = {}
176 - profile_thirdpartymirrors = repo_settings.repoman_settings.thirdpartymirrors().items()
177 - for mirror_alias, mirrors in profile_thirdpartymirrors:
178 - for mirror in mirrors:
179 - if not mirror.endswith("/"):
180 - mirror += "/"
181 - self.thirdpartymirrors[mirror] = mirror_alias
182 -
183 - def check(self, **kwargs):
184 - '''Check that URIs don't reference a server from thirdpartymirrors
185 -
186 - @param ebuild: Ebuild which we check (object).
187 - @param src_uri_error: boolean
188 - @returns: dictionary
189 - '''
190 - ebuild = kwargs.get('ebuild').get()
191 - src_uri_error = kwargs.get('src_uri_error').get()
192 - if src_uri_error:
193 - return True
194 - for uri in portage.dep.use_reduce(
195 - ebuild.metadata["SRC_URI"], matchall=True, is_src_uri=True,
196 - eapi=ebuild.eapi, flat=True):
197 - contains_mirror = False
198 - for mirror, mirror_alias in self.thirdpartymirrors.items():
199 - if uri.startswith(mirror):
200 - contains_mirror = True
201 - break
202 - if not contains_mirror:
203 - continue
204 -
205 - new_uri = "mirror://%s/%s" % (mirror_alias, uri[len(mirror):])
206 - self.qatracker.add_error(
207 - "SRC_URI.mirror",
208 - "%s: '%s' found in thirdpartymirrors, use '%s'" % (
209 - ebuild.relative_path, mirror, new_uri))
210 - return False
211 -
212 - @property
213 - def runInEbuilds(self):
214 - '''Ebuild level scans'''
215 - return (True, [self.check])
216
217 diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
218 index f6dcc1b..1fd5b77 100644
219 --- a/pym/repoman/scanner.py
220 +++ b/pym/repoman/scanner.py
221 @@ -377,7 +377,7 @@ class Scanner(object):
222 # need to set it up for ==> self.modules_list or some other ordered list
223 for mod in [('ebuild', 'Ebuild'), ('live', 'LiveEclassChecks'),
224 ('eapi', 'EAPIChecks'), ('ebuild_metadata', 'EbuildMetadata'),
225 - ('thirdpartymirrors', 'ThirdPartyMirrors'),
226 + ('fetches', 'FetchChecks'),
227 ('description', 'DescriptionChecks'),
228 ('keywords', 'KeywordChecks'),
229 ('use_flags', 'USEFlagChecks'), ('ruby', 'RubyEclassChecks'),