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

Olivier Brunel i.am.jack.mail at gmail.com
Thu Dec 13 08:19:01 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 | 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");
 		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));
 		/* 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:
-- 
1.8.0.2



More information about the pacman-dev mailing list