[pacman-dev] [PATCH] Show progress processing hooks
Andrew Gregory
andrew.gregory.8 at gmail.com
Mon Dec 14 16:37:06 UTC 2015
On 12/14/15 at 03:51pm, Allan McRae wrote:
> 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 at archlinux.org>
> ---
...
> lib/libalpm/alpm.h | 18 +++++++++++++++++-
> lib/libalpm/hook.c | 14 +++++++++++++-
> src/pacman/callback.c | 13 +++++++++++++
> 3 files changed, 43 insertions(+), 2 deletions(-)
...
> diff --git a/src/pacman/callback.c b/src/pacman/callback.c
> index c33bd24..ae725d3 100644
> --- a/src/pacman/callback.c
> +++ b/src/pacman/callback.c
> @@ -172,6 +172,18 @@ void cb_event(alpm_event_t *event)
> event->hook.when == ALPM_HOOK_PRE_TRANSACTION
> ? _("pre-transaction") : _("post-transaction"));
> break;
> + case ALPM_EVENT_HOOK_RUN_START:
> + {
> + alpm_event_hook_run_t *e = &event->hook_run;
> + int digits = 1;
> + size_t tmp = e->total;
> + while((tmp /= 10)) {
> + ++digits;
> + }
I would suggest extracting the above bit into a function since we do
the exact same calculation elsewhere and cb_event is already massive.
> + printf("(%*zu/%*zu) %s\n", digits, e->position,
> + digits, e->total, e->desc);
> + }
> + break;
> case ALPM_EVENT_CHECKDEPS_START:
> printf(_("checking dependencies...\n"));
> break;
> @@ -339,6 +351,7 @@ void cb_event(alpm_event_t *event)
> case ALPM_EVENT_RETRIEVE_DONE:
> case ALPM_EVENT_RETRIEVE_FAILED:
> case ALPM_EVENT_HOOK_DONE:
> + case ALPM_EVENT_HOOK_RUN_DONE:
> /* we can safely ignore those as well */
> case ALPM_EVENT_PKGDOWNLOAD_START:
> case ALPM_EVENT_PKGDOWNLOAD_DONE:
> --
> 2.6.4
More information about the pacman-dev
mailing list