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

Olivier Brunel i.am.jack.mail at gmail.com
Thu Dec 13 06:38:17 EST 2012


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 | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 6c8923d..da014a7 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -789,7 +789,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"));
 		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();
@@ -875,6 +874,7 @@ int sync_prepare_execute(void)
 		goto cleanup;
 	}
 
+	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"),
@@ -907,11 +907,14 @@ int sync_prepare_execute(void)
 			default:
 				break;
 		}
+		alpm_logaction(config->handle, _("failed to commit transaction (%s)\n"),
+				alpm_strerror(err));
 		/* TODO: stderr? */
 		printf(_("Errors occurred, no packages were upgraded.\n"));
 		retval = 1;
 		goto cleanup;
 	}
+	alpm_logaction(config->handle, _("full system upgrade completed\n"));
 
 	/* Step 4: release transaction resources */
 cleanup:
-- 
1.8.0.2



More information about the pacman-dev mailing list