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 ACA0F1389E2 for ; Sun, 7 Dec 2014 05:42:23 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 9CE29E07E0; Sun, 7 Dec 2014 05:42:21 +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 02162E07E0 for ; Sun, 7 Dec 2014 05:42:20 +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 C6ECA3404EA for ; Sun, 7 Dec 2014 05:42:19 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id DF0AEBBDB for ; Sun, 7 Dec 2014 05:42: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: <1417929771.a3991f7727be0eb973aad1b120d248a0739be453.dol-sen@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/sync/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/sync/controller.py X-VCS-Directories: pym/portage/sync/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: a3991f7727be0eb973aad1b120d248a0739be453 X-VCS-Branch: master Date: Sun, 7 Dec 2014 05:42: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: be232951-441d-41f7-b374-38684eab6f54 X-Archives-Hash: 881776cddbe4976af98d1f629d331dc5 commit: a3991f7727be0eb973aad1b120d248a0739be453 Author: Brian Dolbec gentoo org> AuthorDate: Sat Dec 6 22:54:36 2014 +0000 Commit: Brian Dolbec gmail com> CommitDate: Sun Dec 7 05:22:51 2014 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a3991f77 portage/sync/controller.py: Make a repo.postsync.d directory This then runs per-repo postsync hooks only on scripts in the repo.postsync.d directory. This also maintains compatibility with existing scripts in the postsync.d dir or other sub-directories. Both postsync.d directories support subdirectories. Scripts are run in sorted order. --- pym/portage/sync/controller.py | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/pym/portage/sync/controller.py b/pym/portage/sync/controller.py index 21aa7a7..41f3830 100644 --- a/pym/portage/sync/controller.py +++ b/pym/portage/sync/controller.py @@ -20,7 +20,9 @@ bad = create_color_func("BAD") warn = create_color_func("WARN") from portage.package.ebuild.doebuild import _check_temp_dir from portage.metadata import action_metadata +from portage import OrderedDict from portage import _unicode_decode +from portage import util class TaskHandler(object): @@ -88,19 +90,21 @@ class SyncManager(object): self.module_controller = portage.sync.module_controller self.module_names = self.module_controller.module_names - postsync_dir = os.path.join(self.settings["PORTAGE_CONFIGROOT"], - portage.USER_CONFIG_PATH, "postsync.d") - hooks = [] - for root, dirs, names in os.walk(postsync_dir, topdown=True): - #print("root:", root, "dirs:", dirs, "names:", names) - for name in names: - filepath = os.path.join(root, name) + self.hooks = {} + for _dir in ["repo.postsync.d", "postsync.d"]: + postsync_dir = os.path.join(self.settings["PORTAGE_CONFIGROOT"], + portage.USER_CONFIG_PATH, _dir) + hooks = OrderedDict() + for filepath in util._recursive_file_list(postsync_dir): + name = filepath.split(postsync_dir)[1].lstrip(os.sep) if os.access(filepath, os.X_OK): - hooks.append((filepath, name)) + hooks[filepath] = name else: - writemsg_level(" %s postsync.d hook: '%s' is not executable\n" - % (warn("*"), _unicode_decode(name),), level=logging.WARN, noiselevel=2) - self.hooks = hooks + writemsg_level(" %s %s hook: '%s' is not executable\n" + % (warn("*"), _dir, _unicode_decode(name),), + level=logging.WARN, noiselevel=2) + self.hooks[_dir] = hooks + print(self.hooks) def get_module_descriptions(self, mod): @@ -159,15 +163,19 @@ class SyncManager(object): def perform_post_sync_hook(self, reponame, dosyncuri='', repolocation=''): succeeded = os.EX_OK - for filepath, hook in self.hooks: + if reponame: + _hooks = self.hooks["repo.postsync.d"] + else: + _hooks = self.hooks["postsync.d"] + for filepath in _hooks: writemsg_level("Spawning post_sync hook: %s\n" - % (_unicode_decode(hook)), + % (_unicode_decode(_hooks[filepath])), level=logging.ERROR, noiselevel=4) retval = portage.process.spawn([filepath, reponame, dosyncuri, repolocation], env=self.settings.environ()) if retval != os.EX_OK: writemsg_level(" %s Spawn failed for: %s, %s\n" % (bad("*"), - _unicode_decode(hook), filepath), + _unicode_decode(_hooks[filepath]), filepath), level=logging.ERROR, noiselevel=-1) succeeded = retval return succeeded