public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
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: Sun,  7 Dec 2014 05:42:17 +0000 (UTC)	[thread overview]
Message-ID: <1417929771.a3991f7727be0eb973aad1b120d248a0739be453.dol-sen@gentoo> (raw)

commit:     a3991f7727be0eb973aad1b120d248a0739be453
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Dec  6 22:54:36 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Dec  7 05:22:51 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a3991f77

portage/sync/controller.py: Make a repo.postsync.d directory

This then runs per-repo postsync hooks only on scripts in the repo.postsync.d directory.
This also maintains compatibility with existing scripts in the postsync.d dir or other
sub-directories.
Both postsync.d directories support subdirectories.
Scripts are run in sorted order.

---
 pym/portage/sync/controller.py | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/pym/portage/sync/controller.py b/pym/portage/sync/controller.py
index 21aa7a7..41f3830 100644
--- a/pym/portage/sync/controller.py
+++ b/pym/portage/sync/controller.py
@@ -20,7 +20,9 @@ bad = create_color_func("BAD")
 warn = create_color_func("WARN")
 from portage.package.ebuild.doebuild import _check_temp_dir
 from portage.metadata import action_metadata
+from portage import OrderedDict
 from portage import _unicode_decode
+from portage import util
 
 
 class TaskHandler(object):
@@ -88,19 +90,21 @@ 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)
+		self.hooks = {}
+		for _dir in ["repo.postsync.d", "postsync.d"]:
+			postsync_dir = os.path.join(self.settings["PORTAGE_CONFIGROOT"],
+				portage.USER_CONFIG_PATH, _dir)
+			hooks = OrderedDict()
+			for filepath in util._recursive_file_list(postsync_dir):
+				name = filepath.split(postsync_dir)[1].lstrip(os.sep)
 				if os.access(filepath, os.X_OK):
-					hooks.append((filepath, name))
+					hooks[filepath] = name
 				else:
-					writemsg_level(" %s postsync.d hook: '%s' is not executable\n"
-						% (warn("*"), _unicode_decode(name),), level=logging.WARN, noiselevel=2)
-		self.hooks = hooks
+					writemsg_level(" %s %s hook: '%s' is not executable\n"
+						% (warn("*"), _dir, _unicode_decode(name),),
+						level=logging.WARN, noiselevel=2)
+			self.hooks[_dir] = hooks
+		print(self.hooks)
 
 
 	def get_module_descriptions(self, mod):
@@ -159,15 +163,19 @@ class SyncManager(object):
 
 	def perform_post_sync_hook(self, reponame, dosyncuri='', repolocation=''):
 		succeeded = os.EX_OK
-		for filepath, hook in self.hooks:
+		if reponame:
+			_hooks = self.hooks["repo.postsync.d"]
+		else:
+			_hooks = self.hooks["postsync.d"]
+		for filepath in _hooks:
 			writemsg_level("Spawning post_sync hook: %s\n"
-				% (_unicode_decode(hook)),
+				% (_unicode_decode(_hooks[filepath])),
 				level=logging.ERROR, noiselevel=4)
 			retval = portage.process.spawn([filepath,
 				reponame, dosyncuri, repolocation], env=self.settings.environ())
 			if retval != os.EX_OK:
 				writemsg_level(" %s Spawn failed for: %s, %s\n" % (bad("*"),
-					_unicode_decode(hook), filepath),
+					_unicode_decode(_hooks[filepath]), filepath),
 					level=logging.ERROR, noiselevel=-1)
 				succeeded = retval
 		return succeeded


             reply	other threads:[~2014-12-07  5:42 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-07  5:42 Brian Dolbec [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-09-17 23:59 [gentoo-commits] proj/portage:master commit in: pym/portage/sync/ 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-04 20:16 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=1417929771.a3991f7727be0eb973aad1b120d248a0739be453.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: link
Be 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