[pacman-dev] [PATCH 3/3] Add ALPM_EVENT_TRANSACTION_{START, DONE} events

Allan McRae allan at archlinux.org
Mon Dec 14 03:45:42 UTC 2015


This provides a way to detect when the processing of package changes starts,
allowing pacman to deliminate hook output and package installation/removal
output.

Signed-off-by: Allan McRae <allan at archlinux.org>
---
 lib/libalpm/alpm.h    | 4 ++++
 lib/libalpm/trans.c   | 5 +++++
 src/pacman/callback.c | 4 ++++
 3 files changed, 13 insertions(+)

diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index f8e1f25..8fcdfdf 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -384,6 +384,10 @@ typedef enum _alpm_event_type_t {
 	ALPM_EVENT_INTERCONFLICTS_START,
 	/** Inter-conflicts were checked for target package. */
 	ALPM_EVENT_INTERCONFLICTS_DONE,
+	/** Processing the package transaction is starting. */
+	ALPM_EVENT_TRANSACTION_START,
+	/** Processing the package transaction is finished. */
+	ALPM_EVENT_TRANSACTION_DONE,
 	/** Package will be installed/upgraded/downgraded/re-installed/removed; See
 	 * alpm_event_package_operation_t for arguments. */
 	ALPM_EVENT_PACKAGE_OPERATION_START,
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index 06997a0..0ead10d 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -160,6 +160,7 @@ int SYMEXPORT alpm_trans_prepare(alpm_handle_t *handle, alpm_list_t **data)
 int SYMEXPORT alpm_trans_commit(alpm_handle_t *handle, alpm_list_t **data)
 {
 	alpm_trans_t *trans;
+	alpm_event_any_t event;
 
 	/* Sanity checks */
 	CHECK_HANDLE(handle, return -1);
@@ -197,6 +198,8 @@ int SYMEXPORT alpm_trans_commit(alpm_handle_t *handle, alpm_list_t **data)
 	trans->state = STATE_COMMITING;
 
 	alpm_logaction(handle, ALPM_CALLER_PREFIX, "transaction started\n");
+	event.type = ALPM_EVENT_TRANSACTION_START;
+	EVENT(handle, &event);
 
 	if(trans->add == NULL) {
 		if(_alpm_remove_packages(handle, 1) == -1) {
@@ -222,6 +225,8 @@ int SYMEXPORT alpm_trans_commit(alpm_handle_t *handle, alpm_list_t **data)
 		alpm_logaction(handle, ALPM_CALLER_PREFIX, "transaction completed\n");
 		_alpm_hook_run(handle, ALPM_HOOK_POST_TRANSACTION);
 	}
+	event.type = ALPM_EVENT_TRANSACTION_DONE;
+	EVENT(handle, &event);
 
 	trans->state = STATE_COMMITED;
 
diff --git a/src/pacman/callback.c b/src/pacman/callback.c
index 37966ab..c33bd24 100644
--- a/src/pacman/callback.c
+++ b/src/pacman/callback.c
@@ -186,6 +186,9 @@ void cb_event(alpm_event_t *event)
 		case ALPM_EVENT_INTERCONFLICTS_START:
 			printf(_("looking for conflicting packages...\n"));
 			break;
+		case ALPM_EVENT_TRANSACTION_START:
+			colon_printf(_("Processing package changes...\n"));
+			break;
 		case ALPM_EVENT_PACKAGE_OPERATION_START:
 			if(config->noprogressbar) {
 				alpm_event_package_operation_t *e = &event->package_operation;
@@ -325,6 +328,7 @@ void cb_event(alpm_event_t *event)
 		case ALPM_EVENT_CHECKDEPS_DONE:
 		case ALPM_EVENT_RESOLVEDEPS_DONE:
 		case ALPM_EVENT_INTERCONFLICTS_DONE:
+		case ALPM_EVENT_TRANSACTION_DONE:
 		case ALPM_EVENT_INTEGRITY_DONE:
 		case ALPM_EVENT_KEYRING_DONE:
 		case ALPM_EVENT_KEY_DOWNLOAD_DONE:
-- 
2.6.4


More information about the pacman-dev mailing list