1 |
commit: 703691cd611e29c810de08e6452f14454376125a |
2 |
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Sep 27 05:05:01 2014 +0000 |
4 |
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> |
5 |
CommitDate: Mon Sep 29 17:20:22 2014 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=703691cd |
7 |
|
8 |
Sync: Implement native postsync.d hook code |
9 |
|
10 |
As per bug 522032, pass the repo.name and repo.sync_uri to the hooks. |
11 |
With this information, the hooks can be taylored to operate for only certain repos, or only when all repos have been synced. |
12 |
|
13 |
--- |
14 |
pym/portage/sync/controller.py | 36 +++++++++++++++++++++++++----------- |
15 |
1 file changed, 25 insertions(+), 11 deletions(-) |
16 |
|
17 |
diff --git a/pym/portage/sync/controller.py b/pym/portage/sync/controller.py |
18 |
index 21b57f4..a88d4c5 100644 |
19 |
--- a/pym/portage/sync/controller.py |
20 |
+++ b/pym/portage/sync/controller.py |
21 |
@@ -87,6 +87,19 @@ class SyncManager(object): |
22 |
|
23 |
self.module_controller = portage.sync.module_controller |
24 |
self.module_names = self.module_controller.module_names |
25 |
+ postsync_dir = os.path.join(self.settings["PORTAGE_CONFIGROOT"], |
26 |
+ portage.USER_CONFIG_PATH, "postsync.d") |
27 |
+ hooks = [] |
28 |
+ for root, dirs, names in os.walk(postsync_dir, topdown=True): |
29 |
+ #print("root:", root, "dirs:", dirs, "names:", names) |
30 |
+ for name in names: |
31 |
+ filepath = os.path.join(root, name) |
32 |
+ if os.access(filepath, os.X_OK): |
33 |
+ hooks.append((filepath, name)) |
34 |
+ else: |
35 |
+ writemsg_level(" %s postsync.d hook: '%s' is not executable\n" |
36 |
+ % (warn("*"), name,), level=logging.WARN, noiselevel=2) |
37 |
+ self.hooks = hooks |
38 |
|
39 |
|
40 |
def get_module_descriptions(self, mod): |
41 |
@@ -129,7 +142,7 @@ class SyncManager(object): |
42 |
taskmaster = TaskHandler(callback=self.do_callback) |
43 |
taskmaster.run_tasks(tasks, func, status, options=task_opts) |
44 |
|
45 |
- self.perform_post_sync_hook(repo.sync_uri) |
46 |
+ self.perform_post_sync_hook(repo.name, repo.sync_uri) |
47 |
|
48 |
return self.exitcode, None |
49 |
|
50 |
@@ -142,17 +155,18 @@ class SyncManager(object): |
51 |
return |
52 |
|
53 |
|
54 |
- def perform_post_sync_hook(self, dosyncuri): |
55 |
- postsync = os.path.join(self.settings["PORTAGE_CONFIGROOT"], |
56 |
- portage.USER_CONFIG_PATH, "bin", "post_sync") |
57 |
- if os.access(postsync, os.X_OK): |
58 |
- retval = portage.process.spawn([postsync, dosyncuri], |
59 |
- env=self.settings.environ()) |
60 |
+ def perform_post_sync_hook(self, reponame, dosyncuri='None'): |
61 |
+ succeeded = os.EX_OK |
62 |
+ for filepath, hook in self.hooks: |
63 |
+ writemsg_level("Spawning post_sync hook: %s\n" % (hook,), |
64 |
+ level=logging.ERROR, noiselevel=4) |
65 |
+ retval = portage.process.spawn([filepath, |
66 |
+ reponame, dosyncuri], env=self.settings.environ()) |
67 |
if retval != os.EX_OK: |
68 |
- writemsg_level(" %s spawn failed of %s\n" % (bad("*"), |
69 |
- postsync,), level=logging.ERROR, noiselevel=-1) |
70 |
- return retval |
71 |
- return os.EX_OK |
72 |
+ writemsg_level(" %s Spawn failed for: %s, %s\n" % (bad("*"), |
73 |
+ hook, filepath), level=logging.ERROR, noiselevel=-1) |
74 |
+ succeeded = retval |
75 |
+ return succeeded |
76 |
|
77 |
|
78 |
def pre_sync(self, repo): |