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 F1AF3138CC5 for ; Thu, 26 Mar 2015 18:13:31 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 731DEE089F; Thu, 26 Mar 2015 18:13:29 +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 02D58E089F for ; Thu, 26 Mar 2015 18:13:28 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8FDFE340AD9 for ; Thu, 26 Mar 2015 18:13:27 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 370481496E for ; Thu, 26 Mar 2015 18:13:23 +0000 (UTC) From: "Devan Franchini" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Devan Franchini" Message-ID: <1427393625.f581549abe1d807c9d6d84d76978a08c8394ee3b.twitch153@gentoo> Subject: [gentoo-commits] proj/layman:master commit in: layman/overlays/ X-VCS-Repository: proj/layman X-VCS-Files: layman/overlays/overlay.py X-VCS-Directories: layman/overlays/ X-VCS-Committer: twitch153 X-VCS-Committer-Name: Devan Franchini X-VCS-Revision: f581549abe1d807c9d6d84d76978a08c8394ee3b X-VCS-Branch: master Date: Thu, 26 Mar 2015 18:13:23 +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: c03121fe-ceb3-4420-bd1f-4abef652906c X-Archives-Hash: 7d8465c190173b1d650b3b4fb93db17b commit: f581549abe1d807c9d6d84d76978a08c8394ee3b Author: Devan Franchini gentoo org> AuthorDate: Thu Mar 26 18:13:45 2015 +0000 Commit: Devan Franchini gentoo org> CommitDate: Thu Mar 26 18:13:45 2015 +0000 URL: https://gitweb.gentoo.org/proj/layman.git/commit/?id=f581549a overlay.py: Adds overlay source protocol filtering layman/overlays/overlay.py | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py index 55ef8a8..59aa74b 100755 --- a/layman/overlays/overlay.py +++ b/layman/overlays/overlay.py @@ -69,6 +69,29 @@ class Overlay(object): self.from_dict(ovl_dict, ignore) + def filter_protocols(self, sources, create_source_func): + ''' + Filters any protocols not specified in self.config['protocol_order'] + from the overlay's sources. + ''' + _sources = [] + if not 'protocol_order' in self.config.keys(): + return [create_source_func(e) for e in sources] + + for e in sources: + source = create_source_func(e) + for protocol in self.config['protocol_order']: + protocol = protocol.lower() + #re.search considers "\+" as the literal "+". + if protocol == 'git+ssh': + protocol = 'git\+ssh' + protocol += '://' + if re.search('^' + protocol, source.src): + _sources.append(source) + + return _sources + + def from_xml(self, xml, ignore): """Process an xml overlay definition """ @@ -121,7 +144,7 @@ class Overlay(object): raise Exception('Overlay from_xml(), "' + self.name + \ '" is missing a "source" entry!') - self.sources = [create_overlay_source(e) for e in _sources] + self.sources = self.filter_protocols(_sources, create_overlay_source) _owner = xml.find('owner') if _owner == None: @@ -231,7 +254,7 @@ class Overlay(object): return _class(parent=self, config=self.config, _location=_location, ignore=ignore) - self.sources = [create_dict_overlay_source(e) for e in _sources] + self.sources = self.filter_protocols(_sources, create_dict_overlay_source) if 'owner_name' in overlay: _owner = overlay['owner_name'] @@ -379,6 +402,14 @@ class Overlay(object): def add(self, base): res = 1 first_s = True + + if 'protocol_order' in self.config.keys() and not self.sources: + msg = 'Overlay.add() error: overlay "%s" does not support any of'\ + ' the given\nprotocols %s and cannot be installed.'\ + % (self.name, str(self.config['protocol_order'])) + self.output.error(msg) + return 1 + for s in self.sources: if not first_s: self.output.info("\nTrying next source of listed sources...", 4)