summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/hook.c
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2015-12-14 06:48:44 +0100
committerAllan McRae <allan@archlinux.org>2015-12-15 11:12:23 +0100
commit760bea543211673884c254b7e0c44e0f70fe2257 (patch)
tree6ac940877290cc5a62919a4f92f9fdc715c0d066 /lib/libalpm/hook.c
parent8d3bd4ec13940da70f946e6e63d59a05c89cbb50 (diff)
downloadpacman-760bea543211673884c254b7e0c44e0f70fe2257.tar.gz
pacman-760bea543211673884c254b7e0c44e0f70fe2257.tar.xz
Show progress processing hooks
Introduces the ALPM_EVENT_HOOK_RUN_{START,DONE} events that are triggered at the start and end of running an individual hook. Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm/hook.c')
-rw-r--r--lib/libalpm/hook.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/libalpm/hook.c b/lib/libalpm/hook.c
index 9f73ecc6..804cfa57 100644
--- a/lib/libalpm/hook.c
+++ b/lib/libalpm/hook.c
@@ -611,9 +611,10 @@ static int _alpm_hook_run_hook(alpm_handle_t *handle, struct _alpm_hook_t *hook)
int _alpm_hook_run(alpm_handle_t *handle, alpm_hook_when_t when)
{
alpm_event_hook_t event = { .when = when };
+ alpm_event_hook_run_t hook_event;
alpm_list_t *i, *hooks = NULL, *hooks_triggered = NULL;
const char *suffix = ".hook";
- size_t suflen = strlen(suffix);
+ size_t suflen = strlen(suffix), triggered = 0;
int ret = 0;
for(i = alpm_list_last(handle->hookdirs); i; i = alpm_list_previous(i)) {
@@ -714,6 +715,7 @@ int _alpm_hook_run(alpm_handle_t *handle, alpm_hook_when_t when)
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);
+ triggered++;
}
}
@@ -721,12 +723,23 @@ int _alpm_hook_run(alpm_handle_t *handle, alpm_hook_when_t when)
event.type = ALPM_EVENT_HOOK_START;
EVENT(handle, &event);
- for(i = hooks_triggered; i; i = i->next) {
+ hook_event.position = 1;
+ hook_event.total = triggered;
+
+ for(i = hooks_triggered; i; i = i->next, hook_event.position++) {
struct _alpm_hook_t *hook = i->data;
_alpm_log(handle, ALPM_LOG_DEBUG, "running hook %s\n", hook->name);
+
+ hook_event.type = ALPM_EVENT_HOOK_RUN_START;
+ hook_event.name = hook->name;
+ EVENT(handle, &hook_event);
+
if(_alpm_hook_run_hook(handle, hook) != 0 && hook->abort_on_fail) {
ret = -1;
}
+
+ hook_event.type = ALPM_EVENT_HOOK_RUN_DONE;
+ EVENT(handle, &hook_event);
}
alpm_list_free(hooks_triggered);