From: "Brian Dolbec" <brian.dolbec@gmail.com> To: gentoo-commits@lists.gentoo.org Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/sync/ Date: Thu, 4 Dec 2014 20:16:10 +0000 (UTC) [thread overview] Message-ID: <1417722994.737ccc31d83f73395a22f4a19bb13fbc1e94208a.dol-sen@gentoo> (raw) commit: 737ccc31d83f73395a22f4a19bb13fbc1e94208a Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> AuthorDate: Sat Sep 27 05:05:01 2014 +0000 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> CommitDate: Thu Dec 4 19:56:34 2014 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=737ccc31 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 9e483e9..c860e1a 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 @@ -143,17 +156,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=''): + 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):
WARNING: multiple messages have this Message-ID (diff)
From: "Brian Dolbec" <brian.dolbec@gmail.com> To: gentoo-commits@lists.gentoo.org Subject: [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/ Date: Thu, 4 Dec 2014 20:04:31 +0000 (UTC) [thread overview] Message-ID: <1417722994.737ccc31d83f73395a22f4a19bb13fbc1e94208a.dol-sen@gentoo> (raw) Message-ID: <20141204200431.Cu3Ea2tCA4JAm6s_Q4dYykbH5Wfp5TWPgrIOPP0UyDY@z> (raw) commit: 737ccc31d83f73395a22f4a19bb13fbc1e94208a Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> AuthorDate: Sat Sep 27 05:05:01 2014 +0000 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> CommitDate: Thu Dec 4 19:56:34 2014 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=737ccc31 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 9e483e9..c860e1a 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 @@ -143,17 +156,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=''): + 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):
next reply other threads:[~2014-12-04 20:16 UTC|newest] Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-12-04 20:16 Brian Dolbec [this message] 2014-12-04 20:04 ` [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/ Brian Dolbec -- strict thread matches above, loose matches on Subject: below -- 2017-09-17 23:59 [gentoo-commits] proj/portage:master " Zac Medico 2015-12-12 23:42 Zac Medico 2015-11-24 16:16 Zac Medico 2015-10-06 16:27 Zac Medico 2015-09-23 22:32 Zac Medico 2015-08-30 23:52 Zac Medico 2015-07-14 21:31 Brian Dolbec 2015-04-22 16:59 Brian Dolbec 2015-02-09 20:12 Brian Dolbec 2015-02-09 20:12 Brian Dolbec 2015-01-18 18:04 Michał Górny 2014-12-07 22:57 Michał Górny 2014-12-07 9:15 Brian Dolbec 2014-12-07 5:42 Brian Dolbec 2014-12-04 20:16 Brian Dolbec 2014-12-04 20:16 Brian Dolbec 2014-12-04 20:04 [gentoo-commits] proj/portage:plugin-sync " Brian Dolbec 2014-12-04 20:16 ` [gentoo-commits] proj/portage:master " Brian Dolbec 2014-12-04 20:04 [gentoo-commits] proj/portage:plugin-sync " Brian Dolbec 2014-12-04 20:16 ` [gentoo-commits] proj/portage:master " Brian Dolbec 2014-12-04 20:04 [gentoo-commits] proj/portage:plugin-sync " Brian Dolbec 2014-12-04 20:16 ` [gentoo-commits] proj/portage:master " Brian Dolbec 2014-12-04 20:04 [gentoo-commits] proj/portage:plugin-sync " Brian Dolbec 2014-12-04 20:16 ` [gentoo-commits] proj/portage:master " Brian Dolbec 2014-12-04 20:04 [gentoo-commits] proj/portage:plugin-sync " Brian Dolbec 2014-12-04 20:16 ` [gentoo-commits] proj/portage:master " Brian Dolbec
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1417722994.737ccc31d83f73395a22f4a19bb13fbc1e94208a.dol-sen@gentoo \ --to=brian.dolbec@gmail.com \ --cc=gentoo-commits@lists.gentoo.org \ --cc=gentoo-dev@lists.gentoo.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox