1 |
From cd6ef521f930578763ae043a4bc43281bba3bf0e Mon Sep 17 00:00:00 2001 |
2 |
From: Brian Dolbec <dolsen@g.o> |
3 |
Date: Sat, 6 Dec 2014 14:54:36 -0800 |
4 |
Subject: [PATCH 2/2] portage/sync/controller.py: Make a per-repo postsync.d subdir |
5 |
|
6 |
This then runs per-repo postsync hooks only on scripts in the per-repo subdir. |
7 |
This also maintains compatibility with existing scripts in the postsync.d dir or other |
8 |
sub-directories. |
9 |
--- |
10 |
pym/portage/sync/controller.py | 14 +++++++++----- |
11 |
1 file changed, 9 insertions(+), 5 deletions(-) |
12 |
|
13 |
diff --git a/pym/portage/sync/controller.py b/pym/portage/sync/controller.py |
14 |
index 21aa7a7..c9ae5b4 100644 |
15 |
--- a/pym/portage/sync/controller.py |
16 |
+++ b/pym/portage/sync/controller.py |
17 |
@@ -88,15 +88,15 @@ class SyncManager(object): |
18 |
|
19 |
self.module_controller = portage.sync.module_controller |
20 |
self.module_names = self.module_controller.module_names |
21 |
- postsync_dir = os.path.join(self.settings["PORTAGE_CONFIGROOT"], |
22 |
+ self.postsync_dir = os.path.join(self.settings["PORTAGE_CONFIGROOT"], |
23 |
portage.USER_CONFIG_PATH, "postsync.d") |
24 |
- hooks = [] |
25 |
- for root, dirs, names in os.walk(postsync_dir, topdown=True): |
26 |
+ hooks = {} |
27 |
+ for root, dirs, names in os.walk(self.postsync_dir, topdown=True): |
28 |
#print("root:", root, "dirs:", dirs, "names:", names) |
29 |
for name in names: |
30 |
filepath = os.path.join(root, name) |
31 |
if os.access(filepath, os.X_OK): |
32 |
- hooks.append((filepath, name)) |
33 |
+ hooks[filepath] = name |
34 |
else: |
35 |
writemsg_level(" %s postsync.d hook: '%s' is not executable\n" |
36 |
% (warn("*"), _unicode_decode(name),), level=logging.WARN, noiselevel=2) |
37 |
@@ -159,7 +159,11 @@ class SyncManager(object): |
38 |
|
39 |
def perform_post_sync_hook(self, reponame, dosyncuri='', repolocation=''): |
40 |
succeeded = os.EX_OK |
41 |
- for filepath, hook in self.hooks: |
42 |
+ if reponame: |
43 |
+ hooks = [(f,self.hooks[f]) for f in sorted(self.hooks) if 'per-repo' in f] |
44 |
+ else: |
45 |
+ hooks = [(f,self.hooks[f]) for f in sorted(self.hooks) if 'per-repo' not in f] |
46 |
+ for filepath, hook in hooks: |
47 |
writemsg_level("Spawning post_sync hook: %s\n" |
48 |
% (_unicode_decode(hook)), |
49 |
level=logging.ERROR, noiselevel=4) |
50 |
-- |
51 |
2.1.2 |
52 |
|
53 |
|
54 |
-- |
55 |
Brian Dolbec <dolsen> |