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>
This commit is contained in:
parent
b6f6a165c4
commit
28dbd5551e
9 changed files with 241 additions and 149 deletions
|
@ -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_db_t *db = handle->db_local;
|
||||||
alpm_trans_t *trans = handle->trans;
|
alpm_trans_t *trans = handle->trans;
|
||||||
alpm_progress_t progress = ALPM_PROGRESS_ADD_START;
|
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 *log_msg = "adding";
|
||||||
const char *pkgfile;
|
const char *pkgfile;
|
||||||
|
|
||||||
|
@ -478,18 +478,15 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
|
||||||
if(cmp < 0) {
|
if(cmp < 0) {
|
||||||
log_msg = "downgrading";
|
log_msg = "downgrading";
|
||||||
progress = ALPM_PROGRESS_DOWNGRADE_START;
|
progress = ALPM_PROGRESS_DOWNGRADE_START;
|
||||||
start = ALPM_EVENT_DOWNGRADE_START;
|
event.operation = ALPM_PACKAGE_DOWNGRADE;
|
||||||
done = ALPM_EVENT_DOWNGRADE_DONE;
|
|
||||||
} else if(cmp == 0) {
|
} else if(cmp == 0) {
|
||||||
log_msg = "reinstalling";
|
log_msg = "reinstalling";
|
||||||
progress = ALPM_PROGRESS_REINSTALL_START;
|
progress = ALPM_PROGRESS_REINSTALL_START;
|
||||||
start = ALPM_EVENT_REINSTALL_START;
|
event.operation = ALPM_PACKAGE_REINSTALL;
|
||||||
done = ALPM_EVENT_REINSTALL_DONE;
|
|
||||||
} else {
|
} else {
|
||||||
log_msg = "upgrading";
|
log_msg = "upgrading";
|
||||||
progress = ALPM_PROGRESS_UPGRADE_START;
|
progress = ALPM_PROGRESS_UPGRADE_START;
|
||||||
start = ALPM_EVENT_UPGRADE_START;
|
event.operation = ALPM_PACKAGE_UPGRADE;
|
||||||
done = ALPM_EVENT_UPGRADE_DONE;
|
|
||||||
}
|
}
|
||||||
is_upgrade = 1;
|
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 */
|
/* copy over the install reason */
|
||||||
newpkg->reason = alpm_pkg_get_reason(local);
|
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;
|
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);
|
PROGRESS(handle, progress, newpkg->name, 100, pkg_count, pkg_current);
|
||||||
|
|
||||||
switch(done) {
|
switch(event.operation) {
|
||||||
case ALPM_EVENT_ADD_DONE:
|
case ALPM_PACKAGE_INSTALL:
|
||||||
alpm_logaction(handle, ALPM_CALLER_PREFIX, "installed %s (%s)\n",
|
alpm_logaction(handle, ALPM_CALLER_PREFIX, "installed %s (%s)\n",
|
||||||
newpkg->name, newpkg->version);
|
newpkg->name, newpkg->version);
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_DOWNGRADE_DONE:
|
case ALPM_PACKAGE_DOWNGRADE:
|
||||||
alpm_logaction(handle, ALPM_CALLER_PREFIX, "downgraded %s (%s -> %s)\n",
|
alpm_logaction(handle, ALPM_CALLER_PREFIX, "downgraded %s (%s -> %s)\n",
|
||||||
newpkg->name, oldpkg->version, newpkg->version);
|
newpkg->name, oldpkg->version, newpkg->version);
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_REINSTALL_DONE:
|
case ALPM_PACKAGE_REINSTALL:
|
||||||
alpm_logaction(handle, ALPM_CALLER_PREFIX, "reinstalled %s (%s)\n",
|
alpm_logaction(handle, ALPM_CALLER_PREFIX, "reinstalled %s (%s)\n",
|
||||||
newpkg->name, newpkg->version);
|
newpkg->name, newpkg->version);
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_UPGRADE_DONE:
|
case ALPM_PACKAGE_UPGRADE:
|
||||||
alpm_logaction(handle, ALPM_CALLER_PREFIX, "upgraded %s (%s -> %s)\n",
|
alpm_logaction(handle, ALPM_CALLER_PREFIX, "upgraded %s (%s -> %s)\n",
|
||||||
newpkg->name, oldpkg->version, newpkg->version);
|
newpkg->name, oldpkg->version, newpkg->version);
|
||||||
break;
|
break;
|
||||||
|
@ -687,7 +689,8 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
|
||||||
free(scriptlet);
|
free(scriptlet);
|
||||||
}
|
}
|
||||||
|
|
||||||
EVENT(handle, done, newpkg, oldpkg);
|
event.type = ALPM_EVENT_PACKAGE_OPERATION_DONE;
|
||||||
|
EVENT(handle, &event);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
_alpm_pkg_free(oldpkg);
|
_alpm_pkg_free(oldpkg);
|
||||||
|
|
|
@ -275,10 +275,9 @@ int alpm_logaction(alpm_handle_t *handle, const char *prefix,
|
||||||
const char *fmt, ...) __attribute__((format(printf, 3, 4)));
|
const char *fmt, ...) __attribute__((format(printf, 3, 4)));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Events.
|
* Type of events.
|
||||||
* NULL parameters are passed to in all events unless specified otherwise.
|
|
||||||
*/
|
*/
|
||||||
typedef enum _alpm_event_t {
|
typedef enum _alpm_event_type_t {
|
||||||
/** Dependencies will be computed for a package. */
|
/** Dependencies will be computed for a package. */
|
||||||
ALPM_EVENT_CHECKDEPS_START = 1,
|
ALPM_EVENT_CHECKDEPS_START = 1,
|
||||||
/** Dependencies were computed for a package. */
|
/** Dependencies were computed for a package. */
|
||||||
|
@ -295,49 +294,12 @@ typedef enum _alpm_event_t {
|
||||||
ALPM_EVENT_INTERCONFLICTS_START,
|
ALPM_EVENT_INTERCONFLICTS_START,
|
||||||
/** Inter-conflicts were checked for target package. */
|
/** Inter-conflicts were checked for target package. */
|
||||||
ALPM_EVENT_INTERCONFLICTS_DONE,
|
ALPM_EVENT_INTERCONFLICTS_DONE,
|
||||||
/** Package will be installed.
|
/** Package will be installed/upgraded/downgraded/re-installed/removed; See
|
||||||
* A pointer to the target package is passed to the callback.
|
* alpm_event_package_operation_t for arguments. */
|
||||||
*/
|
ALPM_EVENT_PACKAGE_OPERATION_START,
|
||||||
ALPM_EVENT_ADD_START,
|
/** Package was installed/upgraded/downgraded/re-installed/removed; See
|
||||||
/** Package was installed.
|
* alpm_event_package_operation_t for arguments. */
|
||||||
* A pointer to the new package is passed to the callback.
|
ALPM_EVENT_PACKAGE_OPERATION_DONE,
|
||||||
*/
|
|
||||||
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,
|
|
||||||
/** Target package's integrity will be checked. */
|
/** Target package's integrity will be checked. */
|
||||||
ALPM_EVENT_INTEGRITY_START,
|
ALPM_EVENT_INTEGRITY_START,
|
||||||
/** Target package's integrity was checked. */
|
/** Target package's integrity was checked. */
|
||||||
|
@ -354,31 +316,27 @@ typedef enum _alpm_event_t {
|
||||||
ALPM_EVENT_DELTA_PATCHES_START,
|
ALPM_EVENT_DELTA_PATCHES_START,
|
||||||
/** Deltas were applied to packages. */
|
/** Deltas were applied to packages. */
|
||||||
ALPM_EVENT_DELTA_PATCHES_DONE,
|
ALPM_EVENT_DELTA_PATCHES_DONE,
|
||||||
/** Delta patch will be applied to target package.
|
/** Delta patch will be applied to target package; See
|
||||||
* The filename of the package and the filename of the patch is passed to the
|
* alpm_event_delta_patch_t for arguments.. */
|
||||||
* callback.
|
|
||||||
*/
|
|
||||||
ALPM_EVENT_DELTA_PATCH_START,
|
ALPM_EVENT_DELTA_PATCH_START,
|
||||||
/** Delta patch was applied to target package. */
|
/** Delta patch was applied to target package. */
|
||||||
ALPM_EVENT_DELTA_PATCH_DONE,
|
ALPM_EVENT_DELTA_PATCH_DONE,
|
||||||
/** Delta patch failed to apply to target package. */
|
/** Delta patch failed to apply to target package. */
|
||||||
ALPM_EVENT_DELTA_PATCH_FAILED,
|
ALPM_EVENT_DELTA_PATCH_FAILED,
|
||||||
/** Scriptlet has printed information.
|
/** Scriptlet has printed information; See alpm_event_scriptlet_info_t for
|
||||||
* A line of text is passed to the callback.
|
* arguments. */
|
||||||
*/
|
|
||||||
ALPM_EVENT_SCRIPTLET_INFO,
|
ALPM_EVENT_SCRIPTLET_INFO,
|
||||||
/** Files will be downloaded from a repository.
|
/** Files will be downloaded from a repository. */
|
||||||
* The repository's tree name is passed to the callback.
|
|
||||||
*/
|
|
||||||
ALPM_EVENT_RETRIEVE_START,
|
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,
|
ALPM_EVENT_DISKSPACE_START,
|
||||||
/** Disk space usage was computed for a package */
|
/** Disk space usage was computed for a package. */
|
||||||
ALPM_EVENT_DISKSPACE_DONE,
|
ALPM_EVENT_DISKSPACE_DONE,
|
||||||
/** An optdepend for another package is being removed
|
/** An optdepend for another package is being removed; See
|
||||||
* The requiring package and its dependency are passed to the callback */
|
* alpm_event_optdep_removal_t for arguments. */
|
||||||
ALPM_EVENT_OPTDEP_REMOVAL,
|
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,
|
ALPM_EVENT_DATABASE_MISSING,
|
||||||
/** Checking keys used to create signatures are in keyring. */
|
/** Checking keys used to create signatures are in keyring. */
|
||||||
ALPM_EVENT_KEYRING_START,
|
ALPM_EVENT_KEYRING_START,
|
||||||
|
@ -388,10 +346,74 @@ typedef enum _alpm_event_t {
|
||||||
ALPM_EVENT_KEY_DOWNLOAD_START,
|
ALPM_EVENT_KEY_DOWNLOAD_START,
|
||||||
/** Key downloading is finished. */
|
/** Key downloading is finished. */
|
||||||
ALPM_EVENT_KEY_DOWNLOAD_DONE
|
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;
|
} alpm_event_t;
|
||||||
|
|
||||||
/** Event callback */
|
typedef enum _alpm_package_operation_t {
|
||||||
typedef void (*alpm_cb_event)(alpm_event_t, void *, void *);
|
/** 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.
|
* Questions.
|
||||||
|
|
|
@ -89,9 +89,13 @@ static int sync_db_validate(alpm_db_t *db)
|
||||||
|
|
||||||
/* we can skip any validation if the database doesn't exist */
|
/* we can skip any validation if the database doesn't exist */
|
||||||
if(_alpm_access(db->handle, NULL, dbpath, R_OK) != 0 && errno == ENOENT) {
|
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_EXISTS;
|
||||||
db->status |= DB_STATUS_MISSING;
|
db->status |= DB_STATUS_MISSING;
|
||||||
EVENT(db->handle, ALPM_EVENT_DATABASE_MISSING, db->treename, NULL);
|
EVENT(db->handle, &event);
|
||||||
goto valid;
|
goto valid;
|
||||||
}
|
}
|
||||||
db->status |= DB_STATUS_EXISTS;
|
db->status |= DB_STATUS_EXISTS;
|
||||||
|
|
|
@ -31,10 +31,10 @@
|
||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define EVENT(h, e, d1, d2) \
|
#define EVENT(h, e) \
|
||||||
do { \
|
do { \
|
||||||
if((h)->eventcb) { \
|
if((h)->eventcb) { \
|
||||||
(h)->eventcb(e, d1, d2); \
|
(h)->eventcb((alpm_event_t *) (e)); \
|
||||||
} \
|
} \
|
||||||
} while(0)
|
} while(0)
|
||||||
#define QUESTION(h, q, d1, d2, d3, r) \
|
#define QUESTION(h, q, d1, d2, d3, r) \
|
||||||
|
|
|
@ -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)) {
|
for(j = optdeps; j; j = alpm_list_next(j)) {
|
||||||
alpm_depend_t *optdep = j->data;
|
alpm_depend_t *optdep = j->data;
|
||||||
if(alpm_pkg_find(lp, optdep->name)) {
|
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_list_t *lp;
|
||||||
alpm_trans_t *trans = handle->trans;
|
alpm_trans_t *trans = handle->trans;
|
||||||
alpm_db_t *db = handle->db_local;
|
alpm_db_t *db = handle->db_local;
|
||||||
|
alpm_event_t event;
|
||||||
|
|
||||||
if((trans->flags & ALPM_TRANS_FLAG_RECURSE)
|
if((trans->flags & ALPM_TRANS_FLAG_RECURSE)
|
||||||
&& !(trans->flags & ALPM_TRANS_FLAG_CASCADE)) {
|
&& !(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)) {
|
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");
|
_alpm_log(handle, ALPM_LOG_DEBUG, "looking for unsatisfied dependencies\n");
|
||||||
lp = alpm_checkdeps(handle, _alpm_db_get_pkgcache(db), trans->remove, NULL, 1);
|
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);
|
remove_notify_needed_optdepends(handle, trans->remove);
|
||||||
|
|
||||||
if(!(trans->flags & ALPM_TRANS_FLAG_NODEPS)) {
|
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;
|
return 0;
|
||||||
|
@ -657,12 +665,18 @@ int _alpm_remove_single_package(alpm_handle_t *handle,
|
||||||
{
|
{
|
||||||
const char *pkgname = oldpkg->name;
|
const char *pkgname = oldpkg->name;
|
||||||
const char *pkgver = oldpkg->version;
|
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) {
|
if(newpkg) {
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "removing old package first (%s-%s)\n",
|
_alpm_log(handle, ALPM_LOG_DEBUG, "removing old package first (%s-%s)\n",
|
||||||
pkgname, pkgver);
|
pkgname, pkgver);
|
||||||
} else {
|
} else {
|
||||||
EVENT(handle, ALPM_EVENT_REMOVE_START, oldpkg, NULL);
|
EVENT(handle, &event);
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "removing package %s-%s\n",
|
_alpm_log(handle, ALPM_LOG_DEBUG, "removing package %s-%s\n",
|
||||||
pkgname, pkgver);
|
pkgname, pkgver);
|
||||||
|
|
||||||
|
@ -696,7 +710,8 @@ int _alpm_remove_single_package(alpm_handle_t *handle,
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!newpkg) {
|
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 */
|
/* remove the package from the database */
|
||||||
|
|
|
@ -374,6 +374,7 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
|
||||||
int from_sync = 0;
|
int from_sync = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
alpm_trans_t *trans = handle->trans;
|
alpm_trans_t *trans = handle->trans;
|
||||||
|
alpm_event_t event;
|
||||||
|
|
||||||
if(data) {
|
if(data) {
|
||||||
*data = NULL;
|
*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 */
|
/* Build up list by repeatedly resolving each transaction package */
|
||||||
/* Resolve targets dependencies */
|
/* 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");
|
_alpm_log(handle, ALPM_LOG_DEBUG, "resolving target's dependencies\n");
|
||||||
|
|
||||||
/* build remove list for resolvedeps */
|
/* 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);
|
alpm_list_free(trans->add);
|
||||||
trans->add = resolved;
|
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)) {
|
if(!(trans->flags & ALPM_TRANS_FLAG_NOCONFLICTS)) {
|
||||||
/* check for inter-conflicts and whatnot */
|
/* 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");
|
_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;
|
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_inner(deps, (alpm_list_fn_free)alpm_conflict_free);
|
||||||
alpm_list_free(deps);
|
alpm_list_free(deps);
|
||||||
}
|
}
|
||||||
|
@ -683,6 +688,7 @@ static int apply_deltas(alpm_handle_t *handle)
|
||||||
int deltas_found = 0, ret = 0;
|
int deltas_found = 0, ret = 0;
|
||||||
const char *cachedir = _alpm_filecache_setup(handle);
|
const char *cachedir = _alpm_filecache_setup(handle);
|
||||||
alpm_trans_t *trans = handle->trans;
|
alpm_trans_t *trans = handle->trans;
|
||||||
|
alpm_event_delta_patch_t event;
|
||||||
|
|
||||||
for(i = trans->add; i; i = i->next) {
|
for(i = trans->add; i; i = i->next) {
|
||||||
alpm_pkg_t *spkg = i->data;
|
alpm_pkg_t *spkg = i->data;
|
||||||
|
@ -696,7 +702,8 @@ static int apply_deltas(alpm_handle_t *handle)
|
||||||
if(!deltas_found) {
|
if(!deltas_found) {
|
||||||
/* only show this if we actually have deltas to apply, and it is before
|
/* only show this if we actually have deltas to apply, and it is before
|
||||||
* the very first one */
|
* 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;
|
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);
|
_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);
|
int retval = system(command);
|
||||||
if(retval == 0) {
|
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 */
|
/* delete the delta file */
|
||||||
unlink(delta);
|
unlink(delta);
|
||||||
|
@ -752,7 +762,8 @@ static int apply_deltas(alpm_handle_t *handle)
|
||||||
|
|
||||||
if(retval != 0) {
|
if(retval != 0) {
|
||||||
/* one delta failed for this package, cancel the remaining ones */
|
/* 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;
|
handle->pm_errno = ALPM_ERR_DLT_PATCHFAILED;
|
||||||
ret = 1;
|
ret = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -760,7 +771,8 @@ static int apply_deltas(alpm_handle_t *handle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(deltas_found) {
|
if(deltas_found) {
|
||||||
EVENT(handle, ALPM_EVENT_DELTA_PATCHES_DONE, NULL, NULL);
|
event.type = ALPM_EVENT_DELTA_PATCHES_DONE;
|
||||||
|
EVENT(handle, &event);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
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)
|
static int validate_deltas(alpm_handle_t *handle, alpm_list_t *deltas)
|
||||||
{
|
{
|
||||||
alpm_list_t *i, *errors = NULL;
|
alpm_list_t *i, *errors = NULL;
|
||||||
|
alpm_event_t event;
|
||||||
|
|
||||||
if(!deltas) {
|
if(!deltas) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check integrity of deltas */
|
/* 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) {
|
for(i = deltas; i; i = i->next) {
|
||||||
alpm_delta_t *d = i->data;
|
alpm_delta_t *d = i->data;
|
||||||
char *filepath = _alpm_filecache_find(handle, d->delta);
|
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);
|
FREE(filepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EVENT(handle, ALPM_EVENT_DELTA_INTEGRITY_DONE, NULL, NULL);
|
event.type = ALPM_EVENT_DELTA_INTEGRITY_DONE;
|
||||||
|
EVENT(handle, &event);
|
||||||
|
|
||||||
if(errors) {
|
if(errors) {
|
||||||
for(i = errors; i; i = i->next) {
|
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;
|
const char *cachedir;
|
||||||
alpm_list_t *i, *files = NULL;
|
alpm_list_t *i, *files = NULL;
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
|
alpm_event_t event;
|
||||||
|
|
||||||
cachedir = _alpm_filecache_setup(handle);
|
cachedir = _alpm_filecache_setup(handle);
|
||||||
handle->trans->state = STATE_DOWNLOADING;
|
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) {
|
for(i = files; i; i = i->next) {
|
||||||
if(download_single_file(handle, i->data, cachedir) == -1) {
|
if(download_single_file(handle, i->data, cachedir) == -1) {
|
||||||
errors++;
|
errors++;
|
||||||
|
@ -993,8 +1010,10 @@ static int check_keyring(alpm_handle_t *handle)
|
||||||
{
|
{
|
||||||
size_t current = 0, numtargs;
|
size_t current = 0, numtargs;
|
||||||
alpm_list_t *i, *errors = NULL;
|
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);
|
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,
|
PROGRESS(handle, ALPM_PROGRESS_KEYRING_START, "", 100,
|
||||||
numtargs, current);
|
numtargs, current);
|
||||||
EVENT(handle, ALPM_EVENT_KEYRING_DONE, NULL, NULL);
|
event.type = ALPM_EVENT_KEYRING_DONE;
|
||||||
|
EVENT(handle, &event);
|
||||||
|
|
||||||
if(errors) {
|
if(errors) {
|
||||||
EVENT(handle, ALPM_EVENT_KEY_DOWNLOAD_START, NULL, NULL);
|
event.type = ALPM_EVENT_KEY_DOWNLOAD_START;
|
||||||
|
EVENT(handle, &event);
|
||||||
int fail = 0;
|
int fail = 0;
|
||||||
alpm_list_t *k;
|
alpm_list_t *k;
|
||||||
for(k = errors; k; k = k->next) {
|
for(k = errors; k; k = k->next) {
|
||||||
|
@ -1050,7 +1071,8 @@ static int check_keyring(alpm_handle_t *handle)
|
||||||
fail = 1;
|
fail = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EVENT(handle, ALPM_EVENT_KEY_DOWNLOAD_DONE, NULL, NULL);
|
event.type = ALPM_EVENT_KEY_DOWNLOAD_DONE;
|
||||||
|
EVENT(handle, &event);
|
||||||
if(fail) {
|
if(fail) {
|
||||||
_alpm_log(handle, ALPM_LOG_ERROR, _("required key missing from keyring\n"));
|
_alpm_log(handle, ALPM_LOG_ERROR, _("required key missing from keyring\n"));
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1075,9 +1097,11 @@ static int check_validity(alpm_handle_t *handle,
|
||||||
size_t current = 0;
|
size_t current = 0;
|
||||||
uint64_t current_bytes = 0;
|
uint64_t current_bytes = 0;
|
||||||
alpm_list_t *i, *errors = NULL;
|
alpm_list_t *i, *errors = NULL;
|
||||||
|
alpm_event_t event;
|
||||||
|
|
||||||
/* Check integrity of packages */
|
/* 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++) {
|
for(i = handle->trans->add; i; i = i->next, current++) {
|
||||||
struct validity v = { i->data, NULL, NULL, 0, 0, 0 };
|
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,
|
PROGRESS(handle, ALPM_PROGRESS_INTEGRITY_START, "", 100,
|
||||||
total, current);
|
total, current);
|
||||||
EVENT(handle, ALPM_EVENT_INTEGRITY_DONE, NULL, NULL);
|
event.type = ALPM_EVENT_INTEGRITY_DONE;
|
||||||
|
EVENT(handle, &event);
|
||||||
|
|
||||||
if(errors) {
|
if(errors) {
|
||||||
for(i = errors; i; i = i->next) {
|
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;
|
size_t current = 0, current_bytes = 0;
|
||||||
int errors = 0;
|
int errors = 0;
|
||||||
alpm_list_t *i;
|
alpm_list_t *i;
|
||||||
|
alpm_event_t event;
|
||||||
|
|
||||||
/* load packages from disk now that they are known-valid */
|
/* 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++) {
|
for(i = handle->trans->add; i; i = i->next, current++) {
|
||||||
alpm_pkg_t *spkg = i->data;
|
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,
|
PROGRESS(handle, ALPM_PROGRESS_LOAD_START, "", 100,
|
||||||
total, current);
|
total, current);
|
||||||
EVENT(handle, ALPM_EVENT_LOAD_DONE, NULL, NULL);
|
event.type = ALPM_EVENT_LOAD_DONE;
|
||||||
|
EVENT(handle, &event);
|
||||||
|
|
||||||
if(errors) {
|
if(errors) {
|
||||||
if(!handle->pm_errno) {
|
if(!handle->pm_errno) {
|
||||||
|
@ -1209,6 +1237,7 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
|
||||||
size_t total = 0;
|
size_t total = 0;
|
||||||
uint64_t total_bytes = 0;
|
uint64_t total_bytes = 0;
|
||||||
alpm_trans_t *trans = handle->trans;
|
alpm_trans_t *trans = handle->trans;
|
||||||
|
alpm_event_t event;
|
||||||
|
|
||||||
if(download_files(handle, &deltas)) {
|
if(download_files(handle, &deltas)) {
|
||||||
alpm_list_free(deltas);
|
alpm_list_free(deltas);
|
||||||
|
@ -1267,7 +1296,8 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
|
||||||
|
|
||||||
/* fileconflict check */
|
/* fileconflict check */
|
||||||
if(!(trans->flags & ALPM_TRANS_FLAG_DBONLY)) {
|
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_log(handle, ALPM_LOG_DEBUG, "looking for file conflicts\n");
|
||||||
alpm_list_t *conflict = _alpm_db_find_fileconflicts(handle,
|
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);
|
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 */
|
/* check available disk space */
|
||||||
if(handle->checkspace && !(trans->flags & ALPM_TRANS_FLAG_DBONLY)) {
|
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");
|
_alpm_log(handle, ALPM_LOG_DEBUG, "checking available disk space\n");
|
||||||
if(_alpm_check_diskspace(handle) == -1) {
|
if(_alpm_check_diskspace(handle) == -1) {
|
||||||
|
@ -1295,7 +1327,8 @@ int _alpm_sync_commit(alpm_handle_t *handle, alpm_list_t **data)
|
||||||
return -1;
|
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 */
|
/* remove conflicting and to-be-replaced packages */
|
||||||
|
|
|
@ -572,10 +572,14 @@ int _alpm_run_chroot(alpm_handle_t *handle, const char *cmd, char *const argv[])
|
||||||
} else {
|
} else {
|
||||||
while(!feof(pipe_file)) {
|
while(!feof(pipe_file)) {
|
||||||
char line[PATH_MAX];
|
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)
|
if(fgets(line, PATH_MAX, pipe_file) == NULL)
|
||||||
break;
|
break;
|
||||||
alpm_logaction(handle, "ALPM-SCRIPTLET", "%s", line);
|
alpm_logaction(handle, "ALPM-SCRIPTLET", "%s", line);
|
||||||
EVENT(handle, ALPM_EVENT_SCRIPTLET_INFO, line, NULL);
|
EVENT(handle, &event);
|
||||||
}
|
}
|
||||||
fclose(pipe_file);
|
fclose(pipe_file);
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,12 +149,12 @@ static void fill_progress(const int bar_percent, const int disp_percent,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* callback to handle messages/notifications from libalpm transactions */
|
/* callback to handle messages/notifications from libalpm transactions */
|
||||||
void cb_event(alpm_event_t event, void *data1, void *data2)
|
void cb_event(alpm_event_t *event)
|
||||||
{
|
{
|
||||||
if(config->print) {
|
if(config->print) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch(event) {
|
switch(event->type) {
|
||||||
case ALPM_EVENT_CHECKDEPS_START:
|
case ALPM_EVENT_CHECKDEPS_START:
|
||||||
printf(_("checking dependencies...\n"));
|
printf(_("checking dependencies...\n"));
|
||||||
break;
|
break;
|
||||||
|
@ -169,38 +169,43 @@ void cb_event(alpm_event_t event, void *data1, void *data2)
|
||||||
case ALPM_EVENT_INTERCONFLICTS_START:
|
case ALPM_EVENT_INTERCONFLICTS_START:
|
||||||
printf(_("looking for conflicting packages...\n"));
|
printf(_("looking for conflicting packages...\n"));
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_ADD_START:
|
case ALPM_EVENT_PACKAGE_OPERATION_START:
|
||||||
if(config->noprogressbar) {
|
if(config->noprogressbar) {
|
||||||
printf(_("installing %s...\n"), alpm_pkg_get_name(data1));
|
alpm_event_package_operation_t *e = (alpm_event_package_operation_t *) event;
|
||||||
|
switch(e->operation) {
|
||||||
|
case ALPM_PACKAGE_INSTALL:
|
||||||
|
printf(_("installing %s...\n"), alpm_pkg_get_name(e->newpkg));
|
||||||
|
break;
|
||||||
|
case ALPM_PACKAGE_UPGRADE:
|
||||||
|
printf(_("upgrading %s...\n"), alpm_pkg_get_name(e->newpkg));
|
||||||
|
break;
|
||||||
|
case ALPM_PACKAGE_REINSTALL:
|
||||||
|
printf(_("reinstalling %s...\n"), alpm_pkg_get_name(e->newpkg));
|
||||||
|
break;
|
||||||
|
case ALPM_PACKAGE_DOWNGRADE:
|
||||||
|
printf(_("downgrading %s...\n"), alpm_pkg_get_name(e->newpkg));
|
||||||
|
break;
|
||||||
|
case ALPM_PACKAGE_REMOVE:
|
||||||
|
printf(_("removing %s...\n"), alpm_pkg_get_name(e->oldpkg));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_ADD_DONE:
|
case ALPM_EVENT_PACKAGE_OPERATION_DONE:
|
||||||
display_optdepends(data1);
|
{
|
||||||
break;
|
alpm_event_package_operation_t *e = (alpm_event_package_operation_t *) event;
|
||||||
case ALPM_EVENT_REMOVE_START:
|
switch(e->operation) {
|
||||||
if(config->noprogressbar) {
|
case ALPM_PACKAGE_INSTALL:
|
||||||
printf(_("removing %s...\n"), alpm_pkg_get_name(data1));
|
display_optdepends(e->newpkg);
|
||||||
}
|
break;
|
||||||
break;
|
case ALPM_PACKAGE_UPGRADE:
|
||||||
case ALPM_EVENT_UPGRADE_START:
|
case ALPM_PACKAGE_DOWNGRADE:
|
||||||
if(config->noprogressbar) {
|
display_new_optdepends(e->oldpkg, e->newpkg);
|
||||||
printf(_("upgrading %s...\n"), alpm_pkg_get_name(data1));
|
break;
|
||||||
}
|
case ALPM_PACKAGE_REINSTALL:
|
||||||
break;
|
case ALPM_PACKAGE_REMOVE:
|
||||||
case ALPM_EVENT_UPGRADE_DONE:
|
break;
|
||||||
display_new_optdepends(data2, data1);
|
}
|
||||||
break;
|
|
||||||
case ALPM_EVENT_DOWNGRADE_START:
|
|
||||||
if(config->noprogressbar) {
|
|
||||||
printf(_("downgrading %s...\n"), alpm_pkg_get_name(data1));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ALPM_EVENT_DOWNGRADE_DONE:
|
|
||||||
display_new_optdepends(data2, data1);
|
|
||||||
break;
|
|
||||||
case ALPM_EVENT_REINSTALL_START:
|
|
||||||
if(config->noprogressbar) {
|
|
||||||
printf(_("reinstalling %s...\n"), alpm_pkg_get_name(data1));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_INTEGRITY_START:
|
case ALPM_EVENT_INTEGRITY_START:
|
||||||
|
@ -228,7 +233,10 @@ void cb_event(alpm_event_t event, void *data1, void *data2)
|
||||||
printf(_("applying deltas...\n"));
|
printf(_("applying deltas...\n"));
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_DELTA_PATCH_START:
|
case ALPM_EVENT_DELTA_PATCH_START:
|
||||||
printf(_("generating %s with %s... "), (char *)data1, (char *)data2);
|
{
|
||||||
|
alpm_event_delta_patch_t *e = (alpm_event_delta_patch_t *) event;
|
||||||
|
printf(_("generating %s with %s... "), e->delta->to, e->delta->delta);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_DELTA_PATCH_DONE:
|
case ALPM_EVENT_DELTA_PATCH_DONE:
|
||||||
printf(_("success!\n"));
|
printf(_("success!\n"));
|
||||||
|
@ -237,7 +245,7 @@ void cb_event(alpm_event_t event, void *data1, void *data2)
|
||||||
printf(_("failed.\n"));
|
printf(_("failed.\n"));
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_SCRIPTLET_INFO:
|
case ALPM_EVENT_SCRIPTLET_INFO:
|
||||||
fputs((const char *)data1, stdout);
|
fputs(((alpm_event_scriptlet_info_t *) event)->line, stdout);
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_RETRIEVE_START:
|
case ALPM_EVENT_RETRIEVE_START:
|
||||||
colon_printf(_("Retrieving packages ...\n"));
|
colon_printf(_("Retrieving packages ...\n"));
|
||||||
|
@ -248,18 +256,21 @@ void cb_event(alpm_event_t event, void *data1, void *data2)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_OPTDEP_REMOVAL:
|
case ALPM_EVENT_OPTDEP_REMOVAL:
|
||||||
colon_printf(_("%s optionally requires %s\n"), alpm_pkg_get_name(data1),
|
{
|
||||||
alpm_dep_compute_string(data2));
|
alpm_event_optdep_removal_t *e = (alpm_event_optdep_removal_t *) event;
|
||||||
|
colon_printf(_("%s optionally requires %s\n"),
|
||||||
|
alpm_pkg_get_name(e->pkg),
|
||||||
|
alpm_dep_compute_string(e->optdep));
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_DATABASE_MISSING:
|
case ALPM_EVENT_DATABASE_MISSING:
|
||||||
if(!config->op_s_sync) {
|
if(!config->op_s_sync) {
|
||||||
pm_printf(ALPM_LOG_WARNING,
|
pm_printf(ALPM_LOG_WARNING,
|
||||||
"database file for '%s' does not exist\n", (char *)data1);
|
"database file for '%s' does not exist\n",
|
||||||
|
((alpm_event_database_missing_t *) event)->dbname);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
/* all the simple done events, with fallthrough for each */
|
/* all the simple done events, with fallthrough for each */
|
||||||
case ALPM_EVENT_REINSTALL_DONE:
|
|
||||||
case ALPM_EVENT_REMOVE_DONE:
|
|
||||||
case ALPM_EVENT_FILECONFLICTS_DONE:
|
case ALPM_EVENT_FILECONFLICTS_DONE:
|
||||||
case ALPM_EVENT_CHECKDEPS_DONE:
|
case ALPM_EVENT_CHECKDEPS_DONE:
|
||||||
case ALPM_EVENT_RESOLVEDEPS_DONE:
|
case ALPM_EVENT_RESOLVEDEPS_DONE:
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#include <alpm.h>
|
#include <alpm.h>
|
||||||
|
|
||||||
/* callback to handle messages/notifications from libalpm */
|
/* callback to handle messages/notifications from libalpm */
|
||||||
void cb_event(alpm_event_t event, void *data1, void *data2);
|
void cb_event(alpm_event_t *event);
|
||||||
|
|
||||||
/* callback to handle questions from libalpm (yes/no) */
|
/* callback to handle questions from libalpm (yes/no) */
|
||||||
void cb_question(alpm_question_t event, void *data1, void *data2,
|
void cb_question(alpm_question_t event, void *data1, void *data2,
|
||||||
|
|
Loading…
Add table
Reference in a new issue