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 571B713838B for ; Mon, 29 Sep 2014 18:29:40 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 25658E0874; Mon, 29 Sep 2014 18:29:35 +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 82B34E0878 for ; Mon, 29 Sep 2014 18:29:34 +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 859BD34031D for ; Mon, 29 Sep 2014 18:29:33 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id BCC935AE for ; Mon, 29 Sep 2014 18:29:29 +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: <1412011222.703691cd611e29c810de08e6452f14454376125a.dol-sen@gentoo> Subject: [gentoo-commits] proj/portage:plugin-sync 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: 703691cd611e29c810de08e6452f14454376125a X-VCS-Branch: plugin-sync Date: Mon, 29 Sep 2014 18:29:29 +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: ffba4da7-0a2b-4271-994f-f2a717e6e255 X-Archives-Hash: 76a74ef4e1bb53de8cde1355213260b7 commit: 703691cd611e29c810de08e6452f14454376125a Author: Brian Dolbec gentoo org> AuthorDate: Sat Sep 27 05:05:01 2014 +0000 Commit: Brian Dolbec gmail com> CommitDate: Mon Sep 29 17:20:22 2014 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=703691cd Sync: Implement native postsync.d hook code As per bug 522032, pass the repo.name and repo.sync_uri to the hooks. With this information, the hooks can be taylored to operate for only certain repos, or only when all repos have been synced. --- pym/portage/sync/controller.py | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/pym/portage/sync/controller.py b/pym/portage/sync/controller.py index 21b57f4..a88d4c5 100644 --- a/pym/portage/sync/controller.py +++ b/pym/portage/sync/controller.py @@ -87,6 +87,19 @@ 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) + if os.access(filepath, os.X_OK): + hooks.append((filepath, name)) + else: + writemsg_level(" %s postsync.d hook: '%s' is not executable\n" + % (warn("*"), name,), level=logging.WARN, noiselevel=2) + self.hooks = hooks def get_module_descriptions(self, mod): @@ -129,7 +142,7 @@ class SyncManager(object): taskmaster = TaskHandler(callback=self.do_callback) taskmaster.run_tasks(tasks, func, status, options=task_opts) - self.perform_post_sync_hook(repo.sync_uri) + self.perform_post_sync_hook(repo.name, repo.sync_uri) return self.exitcode, None @@ -142,17 +155,18 @@ class SyncManager(object): return - def perform_post_sync_hook(self, dosyncuri): - postsync = os.path.join(self.settings["PORTAGE_CONFIGROOT"], - portage.USER_CONFIG_PATH, "bin", "post_sync") - if os.access(postsync, os.X_OK): - retval = portage.process.spawn([postsync, dosyncuri], - env=self.settings.environ()) + def perform_post_sync_hook(self, reponame, dosyncuri='None'): + succeeded = os.EX_OK + for filepath, hook in self.hooks: + writemsg_level("Spawning post_sync hook: %s\n" % (hook,), + level=logging.ERROR, noiselevel=4) + retval = portage.process.spawn([filepath, + reponame, dosyncuri], env=self.settings.environ()) if retval != os.EX_OK: - writemsg_level(" %s spawn failed of %s\n" % (bad("*"), - postsync,), level=logging.ERROR, noiselevel=-1) - return retval - return os.EX_OK + writemsg_level(" %s Spawn failed for: %s, %s\n" % (bad("*"), + hook, filepath), level=logging.ERROR, noiselevel=-1) + succeeded = retval + return succeeded def pre_sync(self, repo):