Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH 2/2] portage/sync/controller.py: Make a per-repo postsync.d subdir
Date: Sun, 07 Dec 2014 01:54:59
Message-Id: 20141206175429.270b90f6.dolsen@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH 2/2] portage/sync/controller.py: Make a per-repo postsync.d subdir by Zac Medico
1 On Sat, 06 Dec 2014 17:39:45 -0800
2 Zac Medico <zmedico@g.o> wrote:
3
4 > On 12/06/2014 04:53 PM, Brian Dolbec wrote:
5 > >
6 > > From cd6ef521f930578763ae043a4bc43281bba3bf0e Mon Sep 17 00:00:00
7 > > 2001 From: Brian Dolbec <dolsen@g.o>
8 > > Date: Sat, 6 Dec 2014 14:54:36 -0800
9 > > Subject: [PATCH 2/2] portage/sync/controller.py: Make a per-repo
10 > > postsync.d subdir
11 > >
12 > > This then runs per-repo postsync hooks only on scripts in the
13 > > per-repo subdir. This also maintains compatibility with existing
14 > > scripts in the postsync.d dir or other sub-directories.
15 >
16 > I think a separate repo.postsync.d directory would be a nicer way to
17 > organize things.
18
19 your wish is my...
20
21 From b02b4dff30a7930d5308e400a46c3e59bbee0350 Mon Sep 17 00:00:00 2001
22 From: Brian Dolbec <dolsen@g.o>
23 Date: Sat, 6 Dec 2014 14:54:36 -0800
24 Subject: [PATCH] portage/sync/controller.py: Make a repo.postsync.d directory
25
26 This then runs per-repo postsync hooks only on scripts in the repo.postsync.d directory.
27 This also maintains compatibility with existing scripts in the postsync.d dir or other
28 sub-directories.
29 Both postsync.d directories support subdirectories.
30 Scripts are run in sorted order.
31 ---
32 pym/portage/sync/controller.py | 35 +++++++++++++++++++++--------------
33 1 file changed, 21 insertions(+), 14 deletions(-)
34
35 diff --git a/pym/portage/sync/controller.py b/pym/portage/sync/controller.py
36 index 21aa7a7..1127b75 100644
37 --- a/pym/portage/sync/controller.py
38 +++ b/pym/portage/sync/controller.py
39 @@ -88,19 +88,22 @@ class SyncManager(object):
40
41 self.module_controller = portage.sync.module_controller
42 self.module_names = self.module_controller.module_names
43 - postsync_dir = os.path.join(self.settings["PORTAGE_CONFIGROOT"],
44 - portage.USER_CONFIG_PATH, "postsync.d")
45 - hooks = []
46 - for root, dirs, names in os.walk(postsync_dir, topdown=True):
47 - #print("root:", root, "dirs:", dirs, "names:", names)
48 - for name in names:
49 - filepath = os.path.join(root, name)
50 - if os.access(filepath, os.X_OK):
51 - hooks.append((filepath, name))
52 - else:
53 - writemsg_level(" %s postsync.d hook: '%s' is not executable\n"
54 - % (warn("*"), _unicode_decode(name),), level=logging.WARN, noiselevel=2)
55 - self.hooks = hooks
56 + self.hooks = {}
57 + for _dir in ["repo.postsync.d", "postsync.d"]:
58 + postsync_dir = os.path.join(self.settings["PORTAGE_CONFIGROOT"],
59 + portage.USER_CONFIG_PATH, _dir)
60 + hooks = {}
61 + for root, dirs, names in os.walk(postsync_dir, topdown=True):
62 + #print("root:", root, "dirs:", dirs, "names:", names)
63 + for name in names:
64 + filepath = os.path.join(root, name)
65 + if os.access(filepath, os.X_OK):
66 + hooks[filepath] = name
67 + else:
68 + writemsg_level(" %s %s hook: '%s' is not executable\n"
69 + % (warn("*"), _dir, _unicode_decode(name),),
70 + level=logging.WARN, noiselevel=2)
71 + self.hooks[_dir] = hooks
72
73
74 def get_module_descriptions(self, mod):
75 @@ -159,7 +162,11 @@ class SyncManager(object):
76
77 def perform_post_sync_hook(self, reponame, dosyncuri='', repolocation=''):
78 succeeded = os.EX_OK
79 - for filepath, hook in self.hooks:
80 + if reponame:
81 + _hooks = self.hooks["repo.postsync.d"]
82 + else:
83 + _hooks = self.hooks["postsync.d"]
84 + for filepath, hook in [(f,_hooks[f]) for f in sorted(_hooks)]:
85 writemsg_level("Spawning post_sync hook: %s\n"
86 % (_unicode_decode(hook)),
87 level=logging.ERROR, noiselevel=4)
88 --
89 2.1.2
90
91
92
93 --
94 Brian Dolbec <dolsen>

Replies