[pacman-dev] [PATCH 1/2][WIP][RFC] add TRANS_COMMIT_{START, END} events

Andrew Gregory andrew.gregory.8 at gmail.com
Thu Apr 10 19:59:52 EDT 2014


---
 lib/libalpm/alpm.h  | 5 ++++-
 lib/libalpm/sync.c  | 6 ++++++
 lib/libalpm/trans.c | 7 +++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index b0adb95..af33181 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -358,7 +358,10 @@ typedef enum _alpm_event_type_t {
 	ALPM_EVENT_PACSAVE_CREATED,
 	/** A .pacorig file was created; See alpm_event_pacorig_created_t for
 	 * arguments */
-	ALPM_EVENT_PACORIG_CREATED
+	ALPM_EVENT_PACORIG_CREATED,
+
+	ALPM_EVENT_TRANS_COMMIT_START,
+	ALPM_EVENT_TRANS_COMMIT_END,
 } alpm_event_type_t;
 
 /** Events.
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index a025b68..99592df 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -1348,6 +1348,9 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
 		EVENT(handle, &event);
 	}
 
+	event.type = ALPM_EVENT_TRANS_COMMIT_START;
+	EVENT(handle, &event);
+
 	/* remove conflicting and to-be-replaced packages */
 	if(trans->remove) {
 		_alpm_log(handle, ALPM_LOG_DEBUG, "removing conflicting and to-be-replaced packages\n");
@@ -1365,6 +1368,9 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
 		return -1;
 	}
 
+	event.type = ALPM_EVENT_TRANS_COMMIT_END;
+	EVENT(handle, &event);
+
 	return 0;
 }
 
diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
index e5328c5..a6bbfe7 100644
--- a/lib/libalpm/trans.c
+++ b/lib/libalpm/trans.c
@@ -178,10 +178,17 @@ int SYMEXPORT alpm_trans_commit(alpm_handle_t *handle, alpm_list_t **data)
 	trans->state = STATE_COMMITING;
 
 	if(trans->add == NULL) {
+		alpm_event_t event;
+		event.type = ALPM_EVENT_TRANS_COMMIT_START;
+		EVENT(handle, &event);
+
 		if(_alpm_remove_packages(handle, 1) == -1) {
 			/* pm_errno is set by _alpm_remove_packages() */
 			return -1;
 		}
+
+		event.type = ALPM_EVENT_TRANS_COMMIT_END;
+		EVENT(handle, &event);
 	} else {
 		if(_alpm_sync_commit(handle, data) == -1) {
 			/* pm_errno is set by _alpm_sync_commit() */
-- 
1.9.1



More information about the pacman-dev mailing list