[pacman-dev] [PATCH 2/2] Move logging of sysupgrade start, add log when done

Allan McRae allan at archlinux.org
Sun Dec 16 09:05:05 EST 2012


On 13/12/12 23:19, Olivier Brunel wrote:
> The "starting sysupgrade" message was logged quite soon, making it be added
> even when nothing was actually done, because there was nothing to do, the user
> didn't confirm, or asked to only download packages.
> 
> The log message is now added only when (before) committing the transaction. And
> we also log a message at the end (in case of success or failure).
> 
> Signed-off-by: Olivier Brunel <i.am.jack.mail at gmail.com>
> ---
>  src/pacman/sync.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/src/pacman/sync.c b/src/pacman/sync.c
> index f8fce7f..77fd573 100644
> --- a/src/pacman/sync.c
> +++ b/src/pacman/sync.c
> @@ -793,7 +793,6 @@ static int sync_trans(alpm_list_t *targets)
>  
>  	if(config->op_s_upgrade) {
>  		printf(_(":: Starting full system upgrade...\n"));
> -		alpm_logaction(config->handle, "starting full system upgrade\n");

I really do not like that moving this prints effectively the same
message at two different times.  Also, the line below really is the
start of the system upgrade.

>  		if(alpm_sync_sysupgrade(config->handle, config->op_s_upgrade >= 2) == -1) {
>  			pm_printf(ALPM_LOG_ERROR, "%s\n", alpm_strerror(alpm_errno(config->handle)));
>  			trans_release();
> @@ -879,6 +878,9 @@ int sync_prepare_execute(void)
>  		goto cleanup;
>  	}
>  
> +	if(config->op_s_upgrade) {
> +		alpm_logaction(config->handle, "starting full system upgrade\n");
> +	}
>  	if(alpm_trans_commit(config->handle, &data) == -1) {
>  		alpm_errno_t err = alpm_errno(config->handle);
>  		pm_printf(ALPM_LOG_ERROR, _("failed to commit transaction (%s)\n"),
> @@ -911,11 +913,16 @@ int sync_prepare_execute(void)
>  			default:
>  				break;
>  		}
> +		alpm_logaction(config->handle, "failed to commit transaction (%s)\n",
> +				alpm_strerror(err));

Why only this error?  There are other just as valid error conditions to log.

>  		/* TODO: stderr? */
>  		printf(_("Errors occurred, no packages were upgraded.\n"));
>  		retval = 1;
>  		goto cleanup;
>  	}
> +	alpm_logaction(config->handle, (config->op_s_upgrade)
> +			? "full system upgrade completed\n"
> +			: "installation completed\n");
>  
>  	/* Step 4: release transaction resources */
>  cleanup:
> 



More information about the pacman-dev mailing list