From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id B907858973 for ; Thu, 21 Jan 2016 18:31:08 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2E8D021C028; Thu, 21 Jan 2016 18:31:03 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3BFF821C058 for ; Thu, 21 Jan 2016 18:31:01 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DBDAC34094F for ; Thu, 21 Jan 2016 18:30:59 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 71389105C for ; Thu, 21 Jan 2016 18:30:57 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1453336522.6acb2eb0c2adabdd99fcfd8186a2cca71771d276.dolsen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/checks/ebuilds/, pym/repoman/, pym/repoman/modules/scan/mirrors/ X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/checks/ebuilds/thirdpartymirrors.py pym/repoman/modules/scan/mirrors/__init__.py pym/repoman/modules/scan/mirrors/thirdpartymirrors.py pym/repoman/scanner.py X-VCS-Directories: pym/repoman/checks/ebuilds/ pym/repoman/ pym/repoman/modules/scan/mirrors/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 6acb2eb0c2adabdd99fcfd8186a2cca71771d276 X-VCS-Branch: repoman Date: Thu, 21 Jan 2016 18:30:57 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 42f41c70-98a3-42dd-93fc-88e66200424e X-Archives-Hash: e7ece098371f3a0864ac89b16bc732ad commit: 6acb2eb0c2adabdd99fcfd8186a2cca71771d276 Author: Brian Dolbec gentoo org> AuthorDate: Fri Jan 8 01:29:42 2016 +0000 Commit: Brian Dolbec gentoo 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__)