[pacman-dev] [PATCH 1/6] order hooks by file name

Andrew Gregory andrew.gregory.8 at gmail.com
Tue Oct 27 04:47:30 UTC 2015


Signed-off-by: Andrew Gregory <andrew.gregory.8 at gmail.com>
---
 lib/libalpm/hook.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/libalpm/hook.c b/lib/libalpm/hook.c
index fe4b204..c7b4ee8 100644
--- a/lib/libalpm/hook.c
+++ b/lib/libalpm/hook.c
@@ -363,6 +363,11 @@ static int _alpm_hook_triggered(alpm_handle_t *handle, struct _alpm_hook_t *hook
 	return 0;
 }
 
+static int _alpm_hook_cmp(struct _alpm_hook_t *h1, struct _alpm_hook_t *h2)
+{
+	return strcmp(h1->name, h2->name);
+}
+
 static alpm_list_t *find_hook(alpm_list_t *haystack, const void *needle)
 {
 	while(haystack) {
@@ -478,6 +483,9 @@ int _alpm_hook_run(alpm_handle_t *handle, enum _alpm_hook_when_t when)
 		closedir(d);
 	}
 
+	hooks = alpm_list_msort(hooks, alpm_list_count(hooks),
+			(alpm_list_fn_cmp)_alpm_hook_cmp);
+
 	for(i = hooks; i; i = i->next) {
 		struct _alpm_hook_t *hook = i->data;
 		if(hook && hook->when == when && _alpm_hook_triggered(handle, hook)) {
-- 
2.6.2


More information about the pacman-dev mailing list