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 291CB1393E9 for ; Mon, 16 Jun 2014 03:40:21 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 95B2AE0B29; Mon, 16 Jun 2014 03:40:20 +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 ACBBCE0B29 for ; Mon, 16 Jun 2014 03:40:19 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id AE0AA33F8BB for ; Mon, 16 Jun 2014 03:40:18 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id 725F6187EB for ; Mon, 16 Jun 2014 03:40:17 +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: <1402607509.0764934ac9670197a051af437f586d5594235c80.dol-sen@gentoo> Subject: [gentoo-commits] proj/layman:master commit in: layman/overlays/, layman/ X-VCS-Repository: proj/layman X-VCS-Files: layman/config.py layman/overlays/overlay.py layman/overlays/source.py X-VCS-Directories: layman/overlays/ layman/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 0764934ac9670197a051af437f586d5594235c80 X-VCS-Branch: master Date: Mon, 16 Jun 2014 03:40:17 +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: 0e77be1e-9a42-4f7e-8f7f-ad4e7fe38cc5 X-Archives-Hash: 5e9ffcddddaf16b5978c69602074716a commit: 0764934ac9670197a051af437f586d5594235c80 Author: Devan Franchini gentoo org> AuthorDate: Fri May 23 21:25:08 2014 +0000 Commit: Brian Dolbec gmail com> CommitDate: Thu Jun 12 21:11:49 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=0764934a overlay.py: adds update() function To update local database and overlay source urls, this function has been created to allow the overlay.type functions to update their source urls in their own methods. source.py: Adds a stub update() function for overlay types that don't have their own update() function. config.py: Adds a list of supported overlay types that have their own update() methods. --- layman/config.py | 1 + layman/overlays/overlay.py | 34 ++++++++++++++++++++++++++++++++++ layman/overlays/source.py | 8 ++++++++ 3 files changed, 43 insertions(+) diff --git a/layman/config.py b/layman/config.py index c8fdf4f..40ee90a 100644 --- a/layman/config.py +++ b/layman/config.py @@ -165,6 +165,7 @@ class BareConfig(object): 'g-sorcery_postsync' : '', 'git_user': 'layman', 'git_email': 'layman@localhost', + 'support_url_updates': ['Bzr', 'cvs', 'Git', 'Mercurial', 'Subversion'], } self._options = { 'config': config if config else self._defaults['config'], diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py index 174518b..d3d81e2 100755 --- a/layman/overlays/overlay.py +++ b/layman/overlays/overlay.py @@ -422,6 +422,40 @@ class Overlay(object): return res + def update(self, base, available_srcs): + res = 1 + first_src = True + result = False + + if isinstance(available_srcs, str): + available_srcs = [available_srcs] + + if self.sources[0].type in self.config.get_option('support_url_updates'): + for src in available_srcs: + if not first_src: + self.output.info("\nTrying next source of listed sources...", 4) + try: + res = self.sources[0].update(base, src) + if res == 0: + # Updating it worked, no need to bother + # checking other sources. + self.sources[0].src = src + result = True + break + except Exception as error: + self.output.warn(str(error), 4) + first_s = False + else: + # Update the overlay source with the remote + # source, assuming that it's telling the truth + # so it can be written to the installed.xml. + self.output.debug("overlay.update(); type: %s does not support"\ + " source URL updating" % self.sources[0].type, 4) + self.sources[0].src = available_srcs.pop() + result = True + return (self.sources, result) + + def sync(self, base): self.output.debug("overlay.sync(); name = %s" % self.name, 4) assert len(self.sources) == 1 diff --git a/layman/overlays/source.py b/layman/overlays/source.py index 5044156..7c9674b 100644 --- a/layman/overlays/source.py +++ b/layman/overlays/source.py @@ -95,6 +95,14 @@ class OverlaySource(object): os.makedirs(mdir) return True + def update(self, src): + ''' + Updates the overlay source url. + + @params src: source URL. + ''' + pass + def sync(self, base): '''Sync the overlay.''' pass 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 DF89C1391DB for ; Mon, 16 Jun 2014 03:37:31 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D6950E0B58; Mon, 16 Jun 2014 03:37:30 +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 DF8C1E0B59 for ; Mon, 16 Jun 2014 03:37:29 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E173333FE8C for ; Mon, 16 Jun 2014 03:37:28 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id AE686187EB for ; Mon, 16 Jun 2014 03:37:27 +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: <1402607509.0764934ac9670197a051af437f586d5594235c80.dol-sen@gentoo> Subject: [gentoo-commits] proj/layman:gsoc2014 commit in: layman/overlays/, layman/ X-VCS-Repository: proj/layman X-VCS-Files: layman/config.py layman/overlays/overlay.py layman/overlays/source.py X-VCS-Directories: layman/overlays/ layman/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 0764934ac9670197a051af437f586d5594235c80 X-VCS-Branch: gsoc2014 Date: Mon, 16 Jun 2014 03:37:27 +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: 6f4ce188-af92-448b-9797-d77d838bcf94 X-Archives-Hash: 248482f7e71226871f2e71a3e7f815d5 Message-ID: <20140616033727.OyhnIBATUMvCS0X-ShdyvZCL1nORiCIR31YEUhPExB4@z> commit: 0764934ac9670197a051af437f586d5594235c80 Author: Devan Franchini gentoo org> AuthorDate: Fri May 23 21:25:08 2014 +0000 Commit: Brian Dolbec gmail com> CommitDate: Thu Jun 12 21:11:49 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=0764934a overlay.py: adds update() function To update local database and overlay source urls, this function has been created to allow the overlay.type functions to update their source urls in their own methods. source.py: Adds a stub update() function for overlay types that don't have their own update() function. config.py: Adds a list of supported overlay types that have their own update() methods. --- layman/config.py | 1 + layman/overlays/overlay.py | 34 ++++++++++++++++++++++++++++++++++ layman/overlays/source.py | 8 ++++++++ 3 files changed, 43 insertions(+) diff --git a/layman/config.py b/layman/config.py index c8fdf4f..40ee90a 100644 --- a/layman/config.py +++ b/layman/config.py @@ -165,6 +165,7 @@ class BareConfig(object): 'g-sorcery_postsync' : '', 'git_user': 'layman', 'git_email': 'layman@localhost', + 'support_url_updates': ['Bzr', 'cvs', 'Git', 'Mercurial', 'Subversion'], } self._options = { 'config': config if config else self._defaults['config'], diff --git a/layman/overlays/overlay.py b/layman/overlays/overlay.py index 174518b..d3d81e2 100755 --- a/layman/overlays/overlay.py +++ b/layman/overlays/overlay.py @@ -422,6 +422,40 @@ class Overlay(object): return res + def update(self, base, available_srcs): + res = 1 + first_src = True + result = False + + if isinstance(available_srcs, str): + available_srcs = [available_srcs] + + if self.sources[0].type in self.config.get_option('support_url_updates'): + for src in available_srcs: + if not first_src: + self.output.info("\nTrying next source of listed sources...", 4) + try: + res = self.sources[0].update(base, src) + if res == 0: + # Updating it worked, no need to bother + # checking other sources. + self.sources[0].src = src + result = True + break + except Exception as error: + self.output.warn(str(error), 4) + first_s = False + else: + # Update the overlay source with the remote + # source, assuming that it's telling the truth + # so it can be written to the installed.xml. + self.output.debug("overlay.update(); type: %s does not support"\ + " source URL updating" % self.sources[0].type, 4) + self.sources[0].src = available_srcs.pop() + result = True + return (self.sources, result) + + def sync(self, base): self.output.debug("overlay.sync(); name = %s" % self.name, 4) assert len(self.sources) == 1 diff --git a/layman/overlays/source.py b/layman/overlays/source.py index 5044156..7c9674b 100644 --- a/layman/overlays/source.py +++ b/layman/overlays/source.py @@ -95,6 +95,14 @@ class OverlaySource(object): os.makedirs(mdir) return True + def update(self, src): + ''' + Updates the overlay source url. + + @params src: source URL. + ''' + pass + def sync(self, base): '''Sync the overlay.''' pass