Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2015-12-14 12:40:26 +1000
committerAllan McRae <allan@archlinux.org>2015-12-15 15:03:14 +1000
commit3802cab56374b50d4775d9deaf229cdef5cdbe53 (patch)
tree8bb9cc0955a1f76366c2a7f87b9b177a4e2b8423
parentf98541400b7ede2d4a99de5f2f6a25257b545a98 (diff)
Collect all triggered hooks before running them
Having a first pass that checks which hooks are triggered followed by a second pass of the triggered hooks allows us to only provide output when a hook is actually triggered. Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r--lib/libalpm/hook.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/libalpm/hook.c b/lib/libalpm/hook.c
index f5627af0..ee7ad9d2 100644
--- a/lib/libalpm/hook.c
+++ b/lib/libalpm/hook.c
@@ -610,7 +610,7 @@ static int _alpm_hook_run_hook(alpm_handle_t *handle, struct _alpm_hook_t *hook)
int _alpm_hook_run(alpm_handle_t *handle, enum _alpm_hook_when_t when)
{
- alpm_list_t *i, *hooks = NULL;
+ alpm_list_t *i, *hooks = NULL, *hooks_triggered = NULL;
const char *suffix = ".hook";
size_t suflen = strlen(suffix);
int ret = 0;
@@ -712,11 +712,20 @@ int _alpm_hook_run(alpm_handle_t *handle, enum _alpm_hook_when_t when)
for(i = hooks; i; i = i->next) {
struct _alpm_hook_t *hook = i->data;
if(hook && hook->when == when && _alpm_hook_triggered(handle, hook)) {
+ hooks_triggered = alpm_list_add(hooks_triggered, hook);
+ }
+ }
+
+ if(hooks_triggered != NULL) {
+ for(i = hooks_triggered; i; i = i->next) {
+ struct _alpm_hook_t *hook = i->data;
_alpm_log(handle, ALPM_LOG_DEBUG, "running hook %s\n", hook->name);
if(_alpm_hook_run_hook(handle, hook) != 0 && hook->abort_on_fail) {
ret = -1;
}
}
+
+ alpm_list_free(hooks_triggered);
}
cleanup: