From b46bdeea146b19f026b2bb2ad4d281aa89fff777 Mon Sep 17 00:00:00 2001 From: Andrew Gregory Date: Tue, 27 Oct 2015 00:47:30 -0400 Subject: order hooks by file name Signed-off-by: Andrew Gregory Signed-off-by: Allan McRae --- lib/libalpm/hook.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/libalpm') diff --git a/lib/libalpm/hook.c b/lib/libalpm/hook.c index fe4b2041..c7b4ee87 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)) { -- cgit v1.2.3-70-g09d2