* [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/fetch/, pym/repoman/, pym/repoman/modules/scan/mirrors/
@ 2016-04-25 17:17 Brian Dolbec
2016-04-29 17:24 ` [gentoo-commits] proj/portage:master commit in: pym/repoman/, pym/repoman/modules/scan/fetch/, pym/repoman/modules/scan/mirrors/ Brian Dolbec
0 siblings, 1 reply; 2+ messages in thread
From: Brian Dolbec @ 2016-04-25 17:17 UTC (permalink / raw
To: gentoo-commits
commit: 64b58270e5dc1c9f4aa2267a6bf3ab8117d0d44c
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 25 17:14:16 2016 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Apr 25 17:15:11 2016 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=64b58270
repoman: Move thirdpartymirror check to the fetches module
This check should be part of the FetchChecks class.
This removes 'src_uri_error' Future need.
pym/repoman/modules/scan/fetch/__init__.py | 2 +-
pym/repoman/modules/scan/fetch/fetches.py | 45 ++++++++++++++--
pym/repoman/modules/scan/mirrors/__init__.py | 30 -----------
.../modules/scan/mirrors/thirdpartymirrors.py | 61 ----------------------
pym/repoman/scanner.py | 2 +-
5 files changed, 43 insertions(+), 97 deletions(-)
diff --git a/pym/repoman/modules/scan/fetch/__init__.py b/pym/repoman/modules/scan/fetch/__init__.py
index 1228435..3c8e600 100644
--- a/pym/repoman/modules/scan/fetch/__init__.py
+++ b/pym/repoman/modules/scan/fetch/__init__.py
@@ -24,7 +24,7 @@ module_spec = {
'changed': (None, None),
'checkdir': (None, None),
'checkdir_relative': (None, None),
- 'src_uri_error': ('Future', 'UNSET'),
+ 'ebuild': (None, None),
'xpkg': (None, None),
},
},
diff --git a/pym/repoman/modules/scan/fetch/fetches.py b/pym/repoman/modules/scan/fetch/fetches.py
index ddbf6bd..555f34f 100644
--- a/pym/repoman/modules/scan/fetch/fetches.py
+++ b/pym/repoman/modules/scan/fetch/fetches.py
@@ -32,13 +32,22 @@ class FetchChecks(ScanBase):
self.vcs_settings = kwargs.get('vcs_settings')
self._src_uri_error = False
+ # TODO: Build a regex instead here, for the SRC_URI.mirror check.
+ self.thirdpartymirrors = {}
+ profile_thirdpartymirrors = self.repo_settings.repoman_settings.thirdpartymirrors().items()
+ for mirror_alias, mirrors in profile_thirdpartymirrors:
+ for mirror in mirrors:
+ if not mirror.endswith("/"):
+ mirror += "/"
+ self.thirdpartymirrors[mirror] = mirror_alias
+
def check(self, **kwargs):
'''Checks the ebuild sources and files for errors
@param xpkg: the pacakge being checked
@param checkdir: string, directory path
@param checkdir_relative: repolevel determined path
- @returns: dictionary, including {src_uri_error}
+ @returns: boolean
'''
xpkg = kwargs.get('xpkg')
checkdir = kwargs.get('checkdir')
@@ -130,9 +139,6 @@ class FetchChecks(ScanBase):
self.qatracker.add_error(
"file.name",
"%s/files/%s: char '%s'" % (checkdir, y, y[index]))
- # update the dynamic data
- dyn_src_uri_error = kwargs.get('src_uri_error')
- dyn_src_uri_error.set(self._src_uri_error)
return False
def digests(self, checkdir):
@@ -147,7 +153,38 @@ class FetchChecks(ScanBase):
del mf
return _digests
+ def check_mirrors(self, **kwargs):
+ '''Check that URIs don't reference a server from thirdpartymirrors
+
+ @param ebuild: Ebuild which we check (object).
+ @returns: boolean
+ '''
+ ebuild = kwargs.get('ebuild').get()
+
+ for uri in portage.dep.use_reduce(
+ ebuild.metadata["SRC_URI"], matchall=True, is_src_uri=True,
+ eapi=ebuild.eapi, flat=True):
+ contains_mirror = False
+ for mirror, mirror_alias in self.thirdpartymirrors.items():
+ if uri.startswith(mirror):
+ contains_mirror = True
+ break
+ if not contains_mirror:
+ continue
+
+ new_uri = "mirror://%s/%s" % (mirror_alias, uri[len(mirror):])
+ self.qatracker.add_error(
+ "SRC_URI.mirror",
+ "%s: '%s' found in thirdpartymirrors, use '%s'" % (
+ ebuild.relative_path, mirror, new_uri))
+ return False
+
@property
def runInPkgs(self):
'''Package level scans'''
return (True, [self.check])
+
+ @property
+ def runInEbuilds(self):
+ '''Ebuild level scans'''
+ return (True, [self.check_mirrors])
diff --git a/pym/repoman/modules/scan/mirrors/__init__.py b/pym/repoman/modules/scan/mirrors/__init__.py
deleted file mode 100644
index 94ded6d..0000000
--- a/pym/repoman/modules/scan/mirrors/__init__.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright 2015-2016 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-doc = """Mirrors plug-in module for repoman.
-Performs third party mirrors checks on ebuilds."""
-__doc__ = doc[:]
-
-
-module_spec = {
- 'name': 'mirrors',
- 'description': doc,
- 'provides':{
- 'mirrors-module': {
- 'name': "thirdpartymirrors",
- 'sourcefile': "thirdpartymirrors",
- 'class': "ThirdPartyMirrors",
- 'description': doc,
- 'functions': ['check'],
- 'func_desc': {
- },
- 'mod_kwargs': ['repo_settings', 'qatracker',
- ],
- 'func_kwargs': {
- 'ebuild': (None, None),
- 'src_uri_error': (None, None),
- },
- },
- }
-}
-
diff --git a/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py b/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py
deleted file mode 100644
index 9118d59..0000000
--- a/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# -*- coding:utf-8 -*-
-
-# import our initialized portage instance
-from repoman._portage import portage
-from repoman.modules.scan.scanbase import ScanBase
-
-
-class ThirdPartyMirrors(ScanBase):
-
- def __init__(self, **kwargs):
- '''Class init
-
- @param repo_settings: settings instance
- @param qatracker: QATracker instance
- '''
- super(ThirdPartyMirrors, self).__init__(**kwargs)
- repo_settings = kwargs.get('repo_settings')
- self.qatracker = kwargs.get('qatracker')
-
- # TODO: Build a regex instead here, for the SRC_URI.mirror check.
- self.thirdpartymirrors = {}
- profile_thirdpartymirrors = repo_settings.repoman_settings.thirdpartymirrors().items()
- for mirror_alias, mirrors in profile_thirdpartymirrors:
- for mirror in mirrors:
- if not mirror.endswith("/"):
- mirror += "/"
- self.thirdpartymirrors[mirror] = mirror_alias
-
- def check(self, **kwargs):
- '''Check that URIs don't reference a server from thirdpartymirrors
-
- @param ebuild: Ebuild which we check (object).
- @param src_uri_error: boolean
- @returns: dictionary
- '''
- ebuild = kwargs.get('ebuild').get()
- src_uri_error = kwargs.get('src_uri_error').get()
- if src_uri_error:
- return True
- for uri in portage.dep.use_reduce(
- ebuild.metadata["SRC_URI"], matchall=True, is_src_uri=True,
- eapi=ebuild.eapi, flat=True):
- contains_mirror = False
- for mirror, mirror_alias in self.thirdpartymirrors.items():
- if uri.startswith(mirror):
- contains_mirror = True
- break
- if not contains_mirror:
- continue
-
- new_uri = "mirror://%s/%s" % (mirror_alias, uri[len(mirror):])
- self.qatracker.add_error(
- "SRC_URI.mirror",
- "%s: '%s' found in thirdpartymirrors, use '%s'" % (
- ebuild.relative_path, mirror, new_uri))
- return False
-
- @property
- def runInEbuilds(self):
- '''Ebuild level scans'''
- return (True, [self.check])
diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index f6dcc1b..1fd5b77 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -377,7 +377,7 @@ class Scanner(object):
# need to set it up for ==> self.modules_list or some other ordered list
for mod in [('ebuild', 'Ebuild'), ('live', 'LiveEclassChecks'),
('eapi', 'EAPIChecks'), ('ebuild_metadata', 'EbuildMetadata'),
- ('thirdpartymirrors', 'ThirdPartyMirrors'),
+ ('fetches', 'FetchChecks'),
('description', 'DescriptionChecks'),
('keywords', 'KeywordChecks'),
('use_flags', 'USEFlagChecks'), ('ruby', 'RubyEclassChecks'),
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] proj/portage:master commit in: pym/repoman/, pym/repoman/modules/scan/fetch/, pym/repoman/modules/scan/mirrors/
2016-04-25 17:17 [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/fetch/, pym/repoman/, pym/repoman/modules/scan/mirrors/ Brian Dolbec
@ 2016-04-29 17:24 ` Brian Dolbec
0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2016-04-29 17:24 UTC (permalink / raw
To: gentoo-commits
commit: 64b58270e5dc1c9f4aa2267a6bf3ab8117d0d44c
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 25 17:14:16 2016 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Apr 25 17:15:11 2016 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=64b58270
repoman: Move thirdpartymirror check to the fetches module
This check should be part of the FetchChecks class.
This removes 'src_uri_error' Future need.
pym/repoman/modules/scan/fetch/__init__.py | 2 +-
pym/repoman/modules/scan/fetch/fetches.py | 45 ++++++++++++++--
pym/repoman/modules/scan/mirrors/__init__.py | 30 -----------
.../modules/scan/mirrors/thirdpartymirrors.py | 61 ----------------------
pym/repoman/scanner.py | 2 +-
5 files changed, 43 insertions(+), 97 deletions(-)
diff --git a/pym/repoman/modules/scan/fetch/__init__.py b/pym/repoman/modules/scan/fetch/__init__.py
index 1228435..3c8e600 100644
--- a/pym/repoman/modules/scan/fetch/__init__.py
+++ b/pym/repoman/modules/scan/fetch/__init__.py
@@ -24,7 +24,7 @@ module_spec = {
'changed': (None, None),
'checkdir': (None, None),
'checkdir_relative': (None, None),
- 'src_uri_error': ('Future', 'UNSET'),
+ 'ebuild': (None, None),
'xpkg': (None, None),
},
},
diff --git a/pym/repoman/modules/scan/fetch/fetches.py b/pym/repoman/modules/scan/fetch/fetches.py
index ddbf6bd..555f34f 100644
--- a/pym/repoman/modules/scan/fetch/fetches.py
+++ b/pym/repoman/modules/scan/fetch/fetches.py
@@ -32,13 +32,22 @@ class FetchChecks(ScanBase):
self.vcs_settings = kwargs.get('vcs_settings')
self._src_uri_error = False
+ # TODO: Build a regex instead here, for the SRC_URI.mirror check.
+ self.thirdpartymirrors = {}
+ profile_thirdpartymirrors = self.repo_settings.repoman_settings.thirdpartymirrors().items()
+ for mirror_alias, mirrors in profile_thirdpartymirrors:
+ for mirror in mirrors:
+ if not mirror.endswith("/"):
+ mirror += "/"
+ self.thirdpartymirrors[mirror] = mirror_alias
+
def check(self, **kwargs):
'''Checks the ebuild sources and files for errors
@param xpkg: the pacakge being checked
@param checkdir: string, directory path
@param checkdir_relative: repolevel determined path
- @returns: dictionary, including {src_uri_error}
+ @returns: boolean
'''
xpkg = kwargs.get('xpkg')
checkdir = kwargs.get('checkdir')
@@ -130,9 +139,6 @@ class FetchChecks(ScanBase):
self.qatracker.add_error(
"file.name",
"%s/files/%s: char '%s'" % (checkdir, y, y[index]))
- # update the dynamic data
- dyn_src_uri_error = kwargs.get('src_uri_error')
- dyn_src_uri_error.set(self._src_uri_error)
return False
def digests(self, checkdir):
@@ -147,7 +153,38 @@ class FetchChecks(ScanBase):
del mf
return _digests
+ def check_mirrors(self, **kwargs):
+ '''Check that URIs don't reference a server from thirdpartymirrors
+
+ @param ebuild: Ebuild which we check (object).
+ @returns: boolean
+ '''
+ ebuild = kwargs.get('ebuild').get()
+
+ for uri in portage.dep.use_reduce(
+ ebuild.metadata["SRC_URI"], matchall=True, is_src_uri=True,
+ eapi=ebuild.eapi, flat=True):
+ contains_mirror = False
+ for mirror, mirror_alias in self.thirdpartymirrors.items():
+ if uri.startswith(mirror):
+ contains_mirror = True
+ break
+ if not contains_mirror:
+ continue
+
+ new_uri = "mirror://%s/%s" % (mirror_alias, uri[len(mirror):])
+ self.qatracker.add_error(
+ "SRC_URI.mirror",
+ "%s: '%s' found in thirdpartymirrors, use '%s'" % (
+ ebuild.relative_path, mirror, new_uri))
+ return False
+
@property
def runInPkgs(self):
'''Package level scans'''
return (True, [self.check])
+
+ @property
+ def runInEbuilds(self):
+ '''Ebuild level scans'''
+ return (True, [self.check_mirrors])
diff --git a/pym/repoman/modules/scan/mirrors/__init__.py b/pym/repoman/modules/scan/mirrors/__init__.py
deleted file mode 100644
index 94ded6d..0000000
--- a/pym/repoman/modules/scan/mirrors/__init__.py
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright 2015-2016 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-doc = """Mirrors plug-in module for repoman.
-Performs third party mirrors checks on ebuilds."""
-__doc__ = doc[:]
-
-
-module_spec = {
- 'name': 'mirrors',
- 'description': doc,
- 'provides':{
- 'mirrors-module': {
- 'name': "thirdpartymirrors",
- 'sourcefile': "thirdpartymirrors",
- 'class': "ThirdPartyMirrors",
- 'description': doc,
- 'functions': ['check'],
- 'func_desc': {
- },
- 'mod_kwargs': ['repo_settings', 'qatracker',
- ],
- 'func_kwargs': {
- 'ebuild': (None, None),
- 'src_uri_error': (None, None),
- },
- },
- }
-}
-
diff --git a/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py b/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py
deleted file mode 100644
index 9118d59..0000000
--- a/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py
+++ /dev/null
@@ -1,61 +0,0 @@
-# -*- coding:utf-8 -*-
-
-# import our initialized portage instance
-from repoman._portage import portage
-from repoman.modules.scan.scanbase import ScanBase
-
-
-class ThirdPartyMirrors(ScanBase):
-
- def __init__(self, **kwargs):
- '''Class init
-
- @param repo_settings: settings instance
- @param qatracker: QATracker instance
- '''
- super(ThirdPartyMirrors, self).__init__(**kwargs)
- repo_settings = kwargs.get('repo_settings')
- self.qatracker = kwargs.get('qatracker')
-
- # TODO: Build a regex instead here, for the SRC_URI.mirror check.
- self.thirdpartymirrors = {}
- profile_thirdpartymirrors = repo_settings.repoman_settings.thirdpartymirrors().items()
- for mirror_alias, mirrors in profile_thirdpartymirrors:
- for mirror in mirrors:
- if not mirror.endswith("/"):
- mirror += "/"
- self.thirdpartymirrors[mirror] = mirror_alias
-
- def check(self, **kwargs):
- '''Check that URIs don't reference a server from thirdpartymirrors
-
- @param ebuild: Ebuild which we check (object).
- @param src_uri_error: boolean
- @returns: dictionary
- '''
- ebuild = kwargs.get('ebuild').get()
- src_uri_error = kwargs.get('src_uri_error').get()
- if src_uri_error:
- return True
- for uri in portage.dep.use_reduce(
- ebuild.metadata["SRC_URI"], matchall=True, is_src_uri=True,
- eapi=ebuild.eapi, flat=True):
- contains_mirror = False
- for mirror, mirror_alias in self.thirdpartymirrors.items():
- if uri.startswith(mirror):
- contains_mirror = True
- break
- if not contains_mirror:
- continue
-
- new_uri = "mirror://%s/%s" % (mirror_alias, uri[len(mirror):])
- self.qatracker.add_error(
- "SRC_URI.mirror",
- "%s: '%s' found in thirdpartymirrors, use '%s'" % (
- ebuild.relative_path, mirror, new_uri))
- return False
-
- @property
- def runInEbuilds(self):
- '''Ebuild level scans'''
- return (True, [self.check])
diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index f6dcc1b..1fd5b77 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -377,7 +377,7 @@ class Scanner(object):
# need to set it up for ==> self.modules_list or some other ordered list
for mod in [('ebuild', 'Ebuild'), ('live', 'LiveEclassChecks'),
('eapi', 'EAPIChecks'), ('ebuild_metadata', 'EbuildMetadata'),
- ('thirdpartymirrors', 'ThirdPartyMirrors'),
+ ('fetches', 'FetchChecks'),
('description', 'DescriptionChecks'),
('keywords', 'KeywordChecks'),
('use_flags', 'USEFlagChecks'), ('ruby', 'RubyEclassChecks'),
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-29 17:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-25 17:17 [gentoo-commits] proj/portage:repoman commit in: pym/repoman/modules/scan/fetch/, pym/repoman/, pym/repoman/modules/scan/mirrors/ Brian Dolbec
2016-04-29 17:24 ` [gentoo-commits] proj/portage:master commit in: pym/repoman/, pym/repoman/modules/scan/fetch/, pym/repoman/modules/scan/mirrors/ Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox