summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorOlivier Brunel <jjk@jjacky.com>2014-01-10 16:25:14 +0100
committerAllan McRae <allan@archlinux.org>2014-03-03 02:25:54 +0100
commit28dbd5551ee75e843019e6f067ed069daaabba0b (patch)
tree409a7b18a3363ae9a53da30ee17ce59fbc67dd5b /lib/libalpm
parentb6f6a165c4630cac86efb2608b9909b20488a710 (diff)
downloadpacman-28dbd5551ee75e843019e6f067ed069daaabba0b.tar.gz
pacman-28dbd5551ee75e843019e6f067ed069daaabba0b.tar.xz
Update the event callback
Instead of using two void* arguments for all events, we now send one pointer to an alpm_event_t struct. This contains the type of event that was triggered. With this information, the pointer can then be typecasted to the event-specific struct in order to get additional arguments. Signed-off-by: Olivier Brunel <jjk@jjacky.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/add.c31
-rw-r--r--lib/libalpm/alpm.h148
-rw-r--r--lib/libalpm/be_sync.c6
-rw-r--r--lib/libalpm/handle.h4
-rw-r--r--lib/libalpm/remove.c25
-rw-r--r--lib/libalpm/sync.c81
-rw-r--r--lib/libalpm/util.c6
7 files changed, 191 insertions, 110 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index 1199d300..b0f97d89 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -465,7 +465,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
alpm_db_t *db = handle->db_local;
alpm_trans_t *trans = handle->trans;
alpm_progress_t progress = ALPM_PROGRESS_ADD_START;
- alpm_event_t done = ALPM_EVENT_ADD_DONE, start = ALPM_EVENT_ADD_START;
+ alpm_event_package_operation_t event;
const char *log_msg = "adding";
const char *pkgfile;
@@ -478,18 +478,15 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
if(cmp < 0) {
log_msg = "downgrading";
progress = ALPM_PROGRESS_DOWNGRADE_START;
- start = ALPM_EVENT_DOWNGRADE_START;
- done = ALPM_EVENT_DOWNGRADE_DONE;
+ event.operation = ALPM_PACKAGE_DOWNGRADE;
} else if(cmp == 0) {
log_msg = "reinstalling";
progress = ALPM_PROGRESS_REINSTALL_START;
- start = ALPM_EVENT_REINSTALL_START;
- done = ALPM_EVENT_REINSTALL_DONE;
+ event.operation = ALPM_PACKAGE_REINSTALL;
} else {
log_msg = "upgrading";
progress = ALPM_PROGRESS_UPGRADE_START;
- start = ALPM_EVENT_UPGRADE_START;
- done = ALPM_EVENT_UPGRADE_DONE;
+ event.operation = ALPM_PACKAGE_UPGRADE;
}
is_upgrade = 1;
@@ -501,9 +498,14 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
/* copy over the install reason */
newpkg->reason = alpm_pkg_get_reason(local);
+ } else {
+ event.operation = ALPM_PACKAGE_INSTALL;
}
- EVENT(handle, start, newpkg, local);
+ event.type = ALPM_EVENT_PACKAGE_OPERATION_START;
+ event.oldpkg = oldpkg;
+ event.newpkg = newpkg;
+ EVENT(handle, &event);
pkgfile = newpkg->origin_data.file;
@@ -654,20 +656,20 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
PROGRESS(handle, progress, newpkg->name, 100, pkg_count, pkg_current);
- switch(done) {
- case ALPM_EVENT_ADD_DONE:
+ switch(event.operation) {
+ case ALPM_PACKAGE_INSTALL:
alpm_logaction(handle, ALPM_CALLER_PREFIX, "installed %s (%s)\n",
newpkg->name, newpkg->version);
break;
- case ALPM_EVENT_DOWNGRADE_DONE:
+ case ALPM_PACKAGE_DOWNGRADE:
alpm_logaction(handle, ALPM_CALLER_PREFIX, "downgraded %s (%s -> %s)\n",
newpkg->name, oldpkg->version, newpkg->version);
break;
- case ALPM_EVENT_REINSTALL_DONE:
+ case ALPM_PACKAGE_REINSTALL:
alpm_logaction(handle, ALPM_CALLER_PREFIX, "reinstalled %s (%s)\n",
newpkg->name, newpkg->version);
break;
- case ALPM_EVENT_UPGRADE_DONE:
+ case ALPM_PACKAGE_UPGRADE:
alpm_logaction(handle, ALPM_CALLER_PREFIX, "upgraded %s (%s -> %s)\n",
newpkg->name, oldpkg->version, newpkg->version);
break;
@@ -687,7 +689,8 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
free(scriptlet);
}
- EVENT(handle, done, newpkg, oldpkg);
+ event.type = ALPM_EVENT_PACKAGE_OPERATION_DONE;
+ EVENT(handle, &event);
cleanup:
_alpm_pkg_free(oldpkg);
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 6a2a1fe5..8b0a20cb 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -275,10 +275,9 @@ int alpm_logaction(alpm_handle_t *handle, const char *prefix,
const char *fmt, ...) __attribute__((format(printf, 3, 4)));
/**
- * Events.
- * NULL parameters are passed to in all events unless specified otherwise.
+ * Type of events.
*/
-typedef enum _alpm_event_t {
+typedef enum _alpm_event_type_t {
/** Dependencies will be computed for a package. */
ALPM_EVENT_CHECKDEPS_START = 1,
/** Dependencies were computed for a package. */
@@ -295,49 +294,12 @@ typedef enum _alpm_event_t {
ALPM_EVENT_INTERCONFLICTS_START,
/** Inter-conflicts were checked for target package. */
ALPM_EVENT_INTERCONFLICTS_DONE,
- /** Package will be installed.
- * A pointer to the target package is passed to the callback.
- */
- ALPM_EVENT_ADD_START,
- /** Package was installed.
- * A pointer to the new package is passed to the callback.
- */
- ALPM_EVENT_ADD_DONE,
- /** Package will be removed.
- * A pointer to the target package is passed to the callback.
- */
- ALPM_EVENT_REMOVE_START,
- /** Package was removed.
- * A pointer to the removed package is passed to the callback.
- */
- ALPM_EVENT_REMOVE_DONE,
- /** Package will be upgraded.
- * A pointer to the upgraded package is passed to the callback.
- */
- ALPM_EVENT_UPGRADE_START,
- /** Package was upgraded.
- * A pointer to the new package, and a pointer to the old package is passed
- * to the callback, respectively.
- */
- ALPM_EVENT_UPGRADE_DONE,
- /** Package will be downgraded.
- * A pointer to the downgraded package is passed to the callback.
- */
- ALPM_EVENT_DOWNGRADE_START,
- /** Package was downgraded.
- * A pointer to the new package, and a pointer to the old package is passed
- * to the callback, respectively.
- */
- ALPM_EVENT_DOWNGRADE_DONE,
- /** Package will be reinstalled.
- * A pointer to the reinstalled package is passed to the callback.
- */
- ALPM_EVENT_REINSTALL_START,
- /** Package was reinstalled.
- * A pointer to the new package, and a pointer to the old package is passed
- * to the callback, respectively.
- */
- ALPM_EVENT_REINSTALL_DONE,
+ /** Package will be installed/upgraded/downgraded/re-installed/removed; See
+ * alpm_event_package_operation_t for arguments. */
+ ALPM_EVENT_PACKAGE_OPERATION_START,
+ /** Package was installed/upgraded/downgraded/re-installed/removed; See
+ * alpm_event_package_operation_t for arguments. */
+ ALPM_EVENT_PACKAGE_OPERATION_DONE,
/** Target package's integrity will be checked. */
ALPM_EVENT_INTEGRITY_START,
/** Target package's integrity was checked. */
@@ -354,31 +316,27 @@ typedef enum _alpm_event_t {
ALPM_EVENT_DELTA_PATCHES_START,
/** Deltas were applied to packages. */
ALPM_EVENT_DELTA_PATCHES_DONE,
- /** Delta patch will be applied to target package.
- * The filename of the package and the filename of the patch is passed to the
- * callback.
- */
+ /** Delta patch will be applied to target package; See
+ * alpm_event_delta_patch_t for arguments.. */
ALPM_EVENT_DELTA_PATCH_START,
/** Delta patch was applied to target package. */
ALPM_EVENT_DELTA_PATCH_DONE,
/** Delta patch failed to apply to target package. */
ALPM_EVENT_DELTA_PATCH_FAILED,
- /** Scriptlet has printed information.
- * A line of text is passed to the callback.
- */
+ /** Scriptlet has printed information; See alpm_event_scriptlet_info_t for
+ * arguments. */
ALPM_EVENT_SCRIPTLET_INFO,
- /** Files will be downloaded from a repository.
- * The repository's tree name is passed to the callback.
- */
+ /** Files will be downloaded from a repository. */
ALPM_EVENT_RETRIEVE_START,
- /** Disk space usage will be computed for a package */
+ /** Disk space usage will be computed for a package. */
ALPM_EVENT_DISKSPACE_START,
- /** Disk space usage was computed for a package */
+ /** Disk space usage was computed for a package. */
ALPM_EVENT_DISKSPACE_DONE,
- /** An optdepend for another package is being removed
- * The requiring package and its dependency are passed to the callback */
+ /** An optdepend for another package is being removed; See
+ * alpm_event_optdep_removal_t for arguments. */
ALPM_EVENT_OPTDEP_REMOVAL,
- /** A configured repository database is missing */
+ /** A configured repository database is missing; See
+ * alpm_event_database_missing_t for arguments. */
ALPM_EVENT_DATABASE_MISSING,
/** Checking keys used to create signatures are in keyring. */
ALPM_EVENT_KEYRING_START,
@@ -388,10 +346,74 @@ typedef enum _alpm_event_t {
ALPM_EVENT_KEY_DOWNLOAD_START,
/** Key downloading is finished. */
ALPM_EVENT_KEY_DOWNLOAD_DONE
+} alpm_event_type_t;
+
+/** Events.
+ * This is a generic struct this is passed to the callback, that allows the
+ * frontend to know which type of event was triggered. It is then possible to
+ * typecast the pointer to the right structure, in order to access
+ * event-specific data. */
+typedef struct _alpm_event_t {
+ /** Type of event. */
+ alpm_event_type_t type;
} alpm_event_t;
-/** Event callback */
-typedef void (*alpm_cb_event)(alpm_event_t, void *, void *);
+typedef enum _alpm_package_operation_t {
+ /** Package (to be) installed. (No oldpkg) */
+ ALPM_PACKAGE_INSTALL = 1,
+ /** Package (to be) upgraded */
+ ALPM_PACKAGE_UPGRADE,
+ /** Package (to be) re-installed. */
+ ALPM_PACKAGE_REINSTALL,
+ /** Package (to be) downgraded. */
+ ALPM_PACKAGE_DOWNGRADE,
+ /** Package (to be) removed. (No newpkg) */
+ ALPM_PACKAGE_REMOVE
+} alpm_package_operation_t;
+
+typedef struct _alpm_event_package_operation_t {
+ /** Type of event. */
+ alpm_event_type_t type;
+ /** Type of operation. */
+ alpm_package_operation_t operation;
+ /** Old package. */
+ alpm_pkg_t *oldpkg;
+ /** New package. */
+ alpm_pkg_t *newpkg;
+} alpm_event_package_operation_t;
+
+typedef struct _alpm_event_optdep_removal_t {
+ /** Type of event. */
+ alpm_event_type_t type;
+ /** Package with the optdep. */
+ alpm_pkg_t *pkg;
+ /** Optdep being removed. */
+ alpm_depend_t *optdep;
+} alpm_event_optdep_removal_t;
+
+typedef struct _alpm_event_delta_patch_t {
+ /** Type of event. */
+ alpm_event_type_t type;
+ /** Delta info */
+ alpm_delta_t *delta;
+} alpm_event_delta_patch_t;
+
+typedef struct _alpm_event_scriptlet_info_t {
+ /** Type of event. */
+ alpm_event_type_t type;
+ /** Line of scriptlet output. */
+ const char *line;
+} alpm_event_scriptlet_info_t;
+
+typedef struct _alpm_event_database_missing_t {
+ /** Type of event. */
+ alpm_event_type_t type;
+ /** Name of the database. */
+ const char *dbname;
+} alpm_event_database_missing_t;
+
+/** Event callback. */
+typedef void (*alpm_cb_event)(alpm_event_t *);
/**
* Questions.
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index 17a8a69f..df0b1b73 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -89,9 +89,13 @@ static int sync_db_validate(alpm_db_t *db)
/* we can skip any validation if the database doesn't exist */
if(_alpm_access(db->handle, NULL, dbpath, R_OK) != 0 && errno == ENOENT) {
+ alpm_event_database_missing_t event = {
+ .type = ALPM_EVENT_DATABASE_MISSING,
+ .dbname = db->treename
+ };
db->status &= ~DB_STATUS_EXISTS;
db->status |= DB_STATUS_MISSING;
- EVENT(db->handle, ALPM_EVENT_DATABASE_MISSING, db->treename, NULL);
+ EVENT(db->handle, &event);
goto valid;
}
db->status |= DB_STATUS_EXISTS;
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index e11d82a1..db42e8ca 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -31,10 +31,10 @@
#include <curl/curl.h>
#endif
-#define EVENT(h, e, d1, d2) \
+#define EVENT(h, e) \
do { \
if((h)->eventcb) { \
- (h)->eventcb(e, d1, d2); \
+ (h)->eventcb((alpm_event_t *) (e)); \
} \
} while(0)
#define QUESTION(h, q, d1, d2, d3, r) \
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 6fb82eed..dce55784 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -179,7 +179,12 @@ static void remove_notify_needed_optdepends(alpm_handle_t *handle, alpm_list_t *
for(j = optdeps; j; j = alpm_list_next(j)) {
alpm_depend_t *optdep = j->data;
if(alpm_pkg_find(lp, optdep->name)) {
- EVENT(handle, ALPM_EVENT_OPTDEP_REMOVAL, pkg, optdep);
+ alpm_event_optdep_removal_t event = {
+ .type = ALPM_EVENT_OPTDEP_REMOVAL,
+ .pkg = pkg,
+ .optdep = optdep
+ };
+ EVENT(handle, &event);
}
}
}
@@ -203,6 +208,7 @@ int _alpm_remove_prepare(alpm_handle_t *handle, alpm_list_t **data)
alpm_list_t *lp;
alpm_trans_t *trans = handle->trans;
alpm_db_t *db = handle->db_local;
+ alpm_event_t event;
if((trans->flags & ALPM_TRANS_FLAG_RECURSE)
&& !(trans->flags & ALPM_TRANS_FLAG_CASCADE)) {
@@ -214,7 +220,8 @@ int _alpm_remove_prepare(alpm_handle_t *handle, alpm_list_t **data)
}
if(!(trans->flags & ALPM_TRANS_FLAG_NODEPS)) {
- EVENT(handle, ALPM_EVENT_CHECKDEPS_START, NULL, NULL);
+ event.type = ALPM_EVENT_CHECKDEPS_START;
+ EVENT(handle, &event);
_alpm_log(handle, ALPM_LOG_DEBUG, "looking for unsatisfied dependencies\n");
lp = alpm_checkdeps(handle, _alpm_db_get_pkgcache(db), trans->remove, NULL, 1);
@@ -255,7 +262,8 @@ int _alpm_remove_prepare(alpm_handle_t *handle, alpm_list_t **data)
remove_notify_needed_optdepends(handle, trans->remove);
if(!(trans->flags & ALPM_TRANS_FLAG_NODEPS)) {
- EVENT(handle, ALPM_EVENT_CHECKDEPS_DONE, NULL, NULL);
+ event.type = ALPM_EVENT_CHECKDEPS_DONE;
+ EVENT(handle, &event);
}
return 0;
@@ -657,12 +665,18 @@ int _alpm_remove_single_package(alpm_handle_t *handle,
{
const char *pkgname = oldpkg->name;
const char *pkgver = oldpkg->version;
+ alpm_event_package_operation_t event = {
+ .type = ALPM_EVENT_PACKAGE_OPERATION_START,
+ .operation = ALPM_PACKAGE_REMOVE,
+ .oldpkg = oldpkg,
+ .newpkg = NULL
+ };
if(newpkg) {
_alpm_log(handle, ALPM_LOG_DEBUG, "removing old package first (%s-%s)\n",
pkgname, pkgver);
} else {
- EVENT(handle, ALPM_EVENT_REMOVE_START, oldpkg, NULL);
+ EVENT(handle, &event);
_alpm_log(handle, ALPM_LOG_DEBUG, "removing package %s-%s\n",
pkgname, pkgver);
@@ -696,7 +710,8 @@ int _alpm_remove_single_package(alpm_handle_t *handle,
}
if(!newpkg) {
- EVENT(handle, ALPM_EVENT_REMOVE_DONE, oldpkg, NULL);
+ event.type = ALPM_EVENT_PACKAGE_OPERATION_DONE;
+ EVENT(handle, &event);
}
/* remove the package from the database */
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index c6c50a46..076935d1 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -374,6 +374,7 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
int from_sync = 0;
int ret = 0;
alpm_trans_t *trans = handle->trans;
+ alpm_event_t event;
if(data) {
*data = NULL;
@@ -406,7 +407,8 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
/* Build up list by repeatedly resolving each transaction package */
/* Resolve targets dependencies */
- EVENT(handle, ALPM_EVENT_RESOLVEDEPS_START, NULL, NULL);
+ event.type = ALPM_EVENT_RESOLVEDEPS_START;
+ EVENT(handle, &event);
_alpm_log(handle, ALPM_LOG_DEBUG, "resolving target's dependencies\n");
/* build remove list for resolvedeps */
@@ -483,12 +485,14 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
alpm_list_free(trans->add);
trans->add = resolved;
- EVENT(handle, ALPM_EVENT_RESOLVEDEPS_DONE, NULL, NULL);
+ event.type = ALPM_EVENT_RESOLVEDEPS_DONE;
+ EVENT(handle, &event);
}
if(!(trans->flags & ALPM_TRANS_FLAG_NOCONFLICTS)) {
/* check for inter-conflicts and whatnot */
- EVENT(handle, ALPM_EVENT_INTERCONFLICTS_START, NULL, NULL);
+ event.type = ALPM_EVENT_INTERCONFLICTS_START;
+ EVENT(handle, &event);
_alpm_log(handle, ALPM_LOG_DEBUG, "looking for conflicts\n");
@@ -598,7 +602,8 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
goto cleanup;
}
}
- EVENT(handle, ALPM_EVENT_INTERCONFLICTS_DONE, NULL, NULL);
+ event.type = ALPM_EVENT_INTERCONFLICTS_DONE;
+ EVENT(handle, &event);
alpm_list_free_inner(deps, (alpm_list_fn_free)alpm_conflict_free);
alpm_list_free(deps);
}
@@ -683,6 +688,7 @@ static int apply_deltas(alpm_handle_t *handle)
int deltas_found = 0, ret = 0;
const char *cachedir = _alpm_filecache_setup(handle);
alpm_trans_t *trans = handle->trans;
+ alpm_event_delta_patch_t event;
for(i = trans->add; i; i = i->next) {
alpm_pkg_t *spkg = i->data;
@@ -696,7 +702,8 @@ static int apply_deltas(alpm_handle_t *handle)
if(!deltas_found) {
/* only show this if we actually have deltas to apply, and it is before
* the very first one */
- EVENT(handle, ALPM_EVENT_DELTA_PATCHES_START, NULL, NULL);
+ event.type = ALPM_EVENT_DELTA_PATCHES_START;
+ EVENT(handle, &event);
deltas_found = 1;
}
@@ -730,11 +737,14 @@ static int apply_deltas(alpm_handle_t *handle)
_alpm_log(handle, ALPM_LOG_DEBUG, "command: %s\n", command);
- EVENT(handle, ALPM_EVENT_DELTA_PATCH_START, d->to, d->delta);
+ event.type = ALPM_EVENT_DELTA_PATCH_START;
+ event.delta = d;
+ EVENT(handle, &event);
int retval = system(command);
if(retval == 0) {
- EVENT(handle, ALPM_EVENT_DELTA_PATCH_DONE, NULL, NULL);
+ event.type = ALPM_EVENT_DELTA_PATCH_DONE;
+ EVENT(handle, &event);
/* delete the delta file */
unlink(delta);
@@ -752,7 +762,8 @@ static int apply_deltas(alpm_handle_t *handle)
if(retval != 0) {
/* one delta failed for this package, cancel the remaining ones */
- EVENT(handle, ALPM_EVENT_DELTA_PATCH_FAILED, NULL, NULL);
+ event.type = ALPM_EVENT_DELTA_PATCH_FAILED;
+ EVENT(handle, &event);
handle->pm_errno = ALPM_ERR_DLT_PATCHFAILED;
ret = 1;
break;
@@ -760,7 +771,8 @@ static int apply_deltas(alpm_handle_t *handle)
}
}
if(deltas_found) {
- EVENT(handle, ALPM_EVENT_DELTA_PATCHES_DONE, NULL, NULL);
+ event.type = ALPM_EVENT_DELTA_PATCHES_DONE;
+ EVENT(handle, &event);
}
return ret;
@@ -789,13 +801,15 @@ static int prompt_to_delete(alpm_handle_t *handle, const char *filepath,
static int validate_deltas(alpm_handle_t *handle, alpm_list_t *deltas)
{
alpm_list_t *i, *errors = NULL;
+ alpm_event_t event;
if(!deltas) {
return 0;
}
/* Check integrity of deltas */
- EVENT(handle, ALPM_EVENT_DELTA_INTEGRITY_START, NULL, NULL);
+ event.type = ALPM_EVENT_DELTA_INTEGRITY_START;
+ EVENT(handle, &event);
for(i = deltas; i; i = i->next) {
alpm_delta_t *d = i->data;
char *filepath = _alpm_filecache_find(handle, d->delta);
@@ -806,7 +820,8 @@ static int validate_deltas(alpm_handle_t *handle, alpm_list_t *deltas)
FREE(filepath);
}
}
- EVENT(handle, ALPM_EVENT_DELTA_INTEGRITY_DONE, NULL, NULL);
+ event.type = ALPM_EVENT_DELTA_INTEGRITY_DONE;
+ EVENT(handle, &event);
if(errors) {
for(i = errors; i; i = i->next) {
@@ -912,6 +927,7 @@ static int download_files(alpm_handle_t *handle, alpm_list_t **deltas)
const char *cachedir;
alpm_list_t *i, *files = NULL;
int errors = 0;
+ alpm_event_t event;
cachedir = _alpm_filecache_setup(handle);
handle->trans->state = STATE_DOWNLOADING;
@@ -959,7 +975,8 @@ static int download_files(alpm_handle_t *handle, alpm_list_t **deltas)
}
}
- EVENT(handle, ALPM_EVENT_RETRIEVE_START, NULL, NULL);
+ event.type = ALPM_EVENT_RETRIEVE_START;
+ EVENT(handle, &event);
for(i = files; i; i = i->next) {
if(download_single_file(handle, i->data, cachedir) == -1) {
errors++;
@@ -993,8 +1010,10 @@ static int check_keyring(alpm_handle_t *handle)
{
size_t current = 0, numtargs;
alpm_list_t *i, *errors = NULL;
+ alpm_event_t event;
- EVENT(handle, ALPM_EVENT_KEYRING_START, NULL, NULL);
+ event.type = ALPM_EVENT_KEYRING_START;
+ EVENT(handle, &event);
numtargs = alpm_list_count(handle->trans->add);
@@ -1038,10 +1057,12 @@ static int check_keyring(alpm_handle_t *handle)
PROGRESS(handle, ALPM_PROGRESS_KEYRING_START, "", 100,
numtargs, current);
- EVENT(handle, ALPM_EVENT_KEYRING_DONE, NULL, NULL);
+ event.type = ALPM_EVENT_KEYRING_DONE;
+ EVENT(handle, &event);
if(errors) {
- EVENT(handle, ALPM_EVENT_KEY_DOWNLOAD_START, NULL, NULL);
+ event.type = ALPM_EVENT_KEY_DOWNLOAD_START;
+ EVENT(handle, &event);
int fail = 0;
alpm_list_t *k;
for(k = errors; k; k = k->next) {
@@ -1050,7 +1071,8 @@ static int check_keyring(alpm_handle_t *handle)
fail = 1;
}
}
- EVENT(handle, ALPM_EVENT_KEY_DOWNLOAD_DONE, NULL, NULL);
+ event.type = ALPM_EVENT_KEY_DOWNLOAD_DONE;
+ EVENT(handle, &event);
if(fail) {
_alpm_log(handle, ALPM_LOG_ERROR, _("required key missing from keyring\n"));
return -1;
@@ -1075,9 +1097,11 @@ static int check_validity(alpm_handle_t *handle,
size_t current = 0;
uint64_t current_bytes = 0;
alpm_list_t *i, *errors = NULL;
+ alpm_event_t event;
/* Check integrity of packages */
- EVENT(handle, ALPM_EVENT_INTEGRITY_START, NULL, NULL);
+ event.type = ALPM_EVENT_INTEGRITY_START;
+ EVENT(handle, &event);
for(i = handle->trans->add; i; i = i->next, current++) {
struct validity v = { i->data, NULL, NULL, 0, 0, 0 };
@@ -1109,7 +1133,8 @@ static int check_validity(alpm_handle_t *handle,
PROGRESS(handle, ALPM_PROGRESS_INTEGRITY_START, "", 100,
total, current);
- EVENT(handle, ALPM_EVENT_INTEGRITY_DONE, NULL, NULL);
+ event.type = ALPM_EVENT_INTEGRITY_DONE;
+ EVENT(handle, &event);
if(errors) {
for(i = errors; i; i = i->next) {
@@ -1148,9 +1173,11 @@ static int load_packages(alpm_handle_t *handle, alpm_list_t **data,
size_t current = 0, current_bytes = 0;
int errors = 0;
alpm_list_t *i;
+ alpm_event_t event;
/* load packages from disk now that they are known-valid */
- EVENT(handle, ALPM_EVENT_LOAD_START, NULL, NULL);
+ event.type = ALPM_EVENT_LOAD_START;
+ EVENT(handle, &event);
for(i = handle->trans->add; i; i = i->next, current++) {
alpm_pkg_t *spkg = i->data;
@@ -1191,7 +1218,8 @@ static int load_packages(alpm_handle_t *handle, alpm_list_t **data,
PROGRESS(handle, ALPM_PROGRESS_LOAD_START, "", 100,
total, current);
- EVENT(handle, ALPM_EVENT_LOAD_DONE, NULL, NULL);
+ event.type = ALPM_EVENT_LOAD_DONE;
+ EVENT(handle, &event);
if(errors) {
if(!handle->pm_errno) {
@@ -1209,6 +1237,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
size_t total = 0;
uint64_t total_bytes = 0;
alpm_trans_t *trans = handle->trans;
+ alpm_event_t event;
if(download_files(handle, &deltas)) {
alpm_list_free(deltas);
@@ -1267,7 +1296,8 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
/* fileconflict check */
if(!(trans->flags & ALPM_TRANS_FLAG_DBONLY)) {
- EVENT(handle, ALPM_EVENT_FILECONFLICTS_START, NULL, NULL);
+ event.type = ALPM_EVENT_FILECONFLICTS_START;
+ EVENT(handle, &event);
_alpm_log(handle, ALPM_LOG_DEBUG, "looking for file conflicts\n");
alpm_list_t *conflict = _alpm_db_find_fileconflicts(handle,
@@ -1282,12 +1312,14 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
RET_ERR(handle, ALPM_ERR_FILE_CONFLICTS, -1);
}
- EVENT(handle, ALPM_EVENT_FILECONFLICTS_DONE, NULL, NULL);
+ event.type = ALPM_EVENT_FILECONFLICTS_DONE;
+ EVENT(handle, &event);
}
/* check available disk space */
if(handle->checkspace && !(trans->flags & ALPM_TRANS_FLAG_DBONLY)) {
- EVENT(handle, ALPM_EVENT_DISKSPACE_START, NULL, NULL);
+ event.type = ALPM_EVENT_DISKSPACE_START;
+ EVENT(handle, &event);
_alpm_log(handle, ALPM_LOG_DEBUG, "checking available disk space\n");
if(_alpm_check_diskspace(handle) == -1) {
@@ -1295,7 +1327,8 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
return -1;
}
- EVENT(handle, ALPM_EVENT_DISKSPACE_DONE, NULL, NULL);
+ event.type = ALPM_EVENT_DISKSPACE_DONE;
+ EVENT(handle, &event);
}
/* remove conflicting and to-be-replaced packages */
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 1bc208c6..d9f741b3 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -572,10 +572,14 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[])
} else {
while(!feof(pipe_file)) {
char line[PATH_MAX];
+ alpm_event_scriptlet_info_t event = {
+ .type = ALPM_EVENT_SCRIPTLET_INFO,
+ .line = line
+ };
if(fgets(line, PATH_MAX, pipe_file) == NULL)
break;
alpm_logaction(handle, "ALPM-SCRIPTLET", "%s", line);
- EVENT(handle, ALPM_EVENT_SCRIPTLET_INFO, line, NULL);
+ EVENT(handle, &event);
}
fclose(pipe_file);
}