From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/, pym/repoman/modules/scan/mirrors/
Date: Thu, 21 Jan 2016 18:30:57 +0000 (UTC) [thread overview]
Message-ID: <1453336522.6acb2eb0c2adabdd99fcfd8186a2cca71771d276.dolsen@gentoo> (raw)
commit: 6acb2eb0c2adabdd99fcfd8186a2cca71771d276
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 8 01:29:42 2016 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Thu Jan 21 00:35:22 2016 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=6acb2eb0
repoman: Create the ThirdPartyMirrors class plugin
pym/repoman/checks/ebuilds/thirdpartymirrors.py | 39 --------------
pym/repoman/modules/scan/mirrors/__init__.py | 23 +++++++++
.../modules/scan/mirrors/thirdpartymirrors.py | 59 ++++++++++++++++++++++
pym/repoman/scanner.py | 6 +--
4 files changed, 85 insertions(+), 42 deletions(-)
diff --git a/pym/repoman/checks/ebuilds/thirdpartymirrors.py b/pym/repoman/checks/ebuilds/thirdpartymirrors.py
deleted file mode 100644
index 848dfb9..0000000
--- a/pym/repoman/checks/ebuilds/thirdpartymirrors.py
+++ /dev/null
@@ -1,39 +0,0 @@
-# -*- coding:utf-8 -*-
-
-# import our initialized portage instance
-from repoman._portage import portage
-
-
-class ThirdPartyMirrors(object):
-
- def __init__(self, repoman_settings, qatracker):
- # TODO: Build a regex instead here, for the SRC_URI.mirror check.
- self.thirdpartymirrors = {}
- profile_thirdpartymirrors = 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
-
- self.qatracker = qatracker
-
- def check(self, myaux, relative_path):
- # Check that URIs don't reference a server from thirdpartymirrors.
- for uri in portage.dep.use_reduce(
- myaux["SRC_URI"], matchall=True, is_src_uri=True,
- eapi=myaux["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'" % (
- relative_path, mirror, new_uri))
- return
diff --git a/pym/repoman/modules/scan/mirrors/__init__.py b/pym/repoman/modules/scan/mirrors/__init__.py
new file mode 100644
index 0000000..37dfc53
--- /dev/null
+++ b/pym/repoman/modules/scan/mirrors/__init__.py
@@ -0,0 +1,23 @@
+# 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",
+ 'class': "ThirdPartyMirrors",
+ 'description': doc,
+ 'functions': ['check'],
+ 'func_desc': {
+ },
+ },
+ }
+}
+
diff --git a/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py b/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py
new file mode 100644
index 0000000..9404e28
--- /dev/null
+++ b/pym/repoman/modules/scan/mirrors/thirdpartymirrors.py
@@ -0,0 +1,59 @@
+# -*- 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
+ '''
+ ebuild = kwargs.get('ebuild')
+ if kwargs.get('src_uri_error'):
+ return {'continue': 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 {'continue': 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 6f3fb53..955440e 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -19,7 +19,6 @@ from portage.dep import Atom
from portage.output import green
from repoman.checks.ebuilds.checks import run_checks
from repoman.checks.ebuilds.eclasses.ruby import RubyEclassChecks
-from repoman.checks.ebuilds.thirdpartymirrors import ThirdPartyMirrors
from repoman.check_missingslot import check_missingslot
from repoman.checks.ebuilds.use_flags import USEFlagChecks
from repoman.checks.ebuilds.variables.description import DescriptionChecks
@@ -215,7 +214,6 @@ class Scanner(object):
self.modules[mod_class.__name__] = mod_class(**self.kwargs)
# initialize our checks classes here before the big xpkg loop
- self.thirdparty = ThirdPartyMirrors(self.repo_settings.repoman_settings, self.qatracker)
self.use_flag_checks = USEFlagChecks(self.qatracker, uselist)
self.rubyeclasscheck = RubyEclassChecks(self.qatracker)
self.descriptioncheck = DescriptionChecks(self.qatracker)
@@ -301,7 +299,9 @@ class Scanner(object):
# initialize per ebuild plugin checks here
# 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')]:
+ ('eapi', 'EAPIChecks'), ('ebuild_metadata', 'EbuildMetadata'),
+ ('thirdpartymirrors', 'ThirdPartyMirrors'),
+ ]:
if mod[0]:
mod_class = MODULE_CONTROLLER.get_class(mod[0])
logging.debug("Initializing class name: %s", mod_class.__name__)
next reply other threads:[~2016-01-21 18:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-21 18:30 Brian Dolbec [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-01-27 23:15 [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/, pym/repoman/modules/scan/mirrors/ Brian Dolbec
2016-01-18 19:23 Brian Dolbec
2016-01-10 3:25 Brian Dolbec
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1453336522.6acb2eb0c2adabdd99fcfd8186a2cca71771d276.dolsen@gentoo \
--to=dolsen@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox