log important events from the backend
This ensures that important events will be logged and consistent regardless of the frontend. The need for global context in the event callback is also removed. The event is logged before any post_* scripts run, so this also moves the post_* script output underneath the event in the log. Fixes FS#36504 Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
ea6aeef8ba
commit
d78f45ae0c
|
@ -649,6 +649,28 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
|
||||||
|
|
||||||
PROGRESS(handle, event, newpkg->name, 100, pkg_count, pkg_current);
|
PROGRESS(handle, event, newpkg->name, 100, pkg_count, pkg_current);
|
||||||
|
|
||||||
|
switch(done) {
|
||||||
|
case ALPM_EVENT_ADD_DONE:
|
||||||
|
alpm_logaction(handle, ALPM_CALLER_PREFIX, "installed %s (%s)\n",
|
||||||
|
newpkg->name, newpkg->version);
|
||||||
|
break;
|
||||||
|
case ALPM_EVENT_DOWNGRADE_DONE:
|
||||||
|
alpm_logaction(handle, ALPM_CALLER_PREFIX, "downgraded %s (%s -> %s)\n",
|
||||||
|
newpkg->name, oldpkg->version, newpkg->version);
|
||||||
|
break;
|
||||||
|
case ALPM_EVENT_REINSTALL_DONE:
|
||||||
|
alpm_logaction(handle, ALPM_CALLER_PREFIX, "reinstalled %s (%s)\n",
|
||||||
|
newpkg->name, newpkg->version);
|
||||||
|
break;
|
||||||
|
case ALPM_EVENT_UPGRADE_DONE:
|
||||||
|
alpm_logaction(handle, ALPM_CALLER_PREFIX, "upgraded %s (%s -> %s)\n",
|
||||||
|
newpkg->name, oldpkg->version, newpkg->version);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* we should never reach here */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
/* run the post-install script if it exists */
|
/* run the post-install script if it exists */
|
||||||
if(alpm_pkg_has_scriptlet(newpkg)
|
if(alpm_pkg_has_scriptlet(newpkg)
|
||||||
&& !(trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
|
&& !(trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
|
||||||
|
|
|
@ -687,6 +687,11 @@ int _alpm_remove_single_package(alpm_handle_t *handle,
|
||||||
remove_package_files(handle, oldpkg, newpkg, targ_count, pkg_count);
|
remove_package_files(handle, oldpkg, newpkg, targ_count, pkg_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!newpkg) {
|
||||||
|
alpm_logaction(handle, ALPM_CALLER_PREFIX, "removed %s (%s)\n",
|
||||||
|
oldpkg->name, oldpkg->version);
|
||||||
|
}
|
||||||
|
|
||||||
/* run the post-remove script if it exists */
|
/* run the post-remove script if it exists */
|
||||||
if(!newpkg && alpm_pkg_has_scriptlet(oldpkg) &&
|
if(!newpkg && alpm_pkg_has_scriptlet(oldpkg) &&
|
||||||
!(handle->trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
|
!(handle->trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
|
||||||
|
|
|
@ -148,8 +148,6 @@ static void fill_progress(const int bar_percent, const int disp_percent,
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* 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, void *data1, void *data2)
|
||||||
{
|
{
|
||||||
|
@ -177,10 +175,6 @@ void cb_event(alpm_event_t event, void *data1, void *data2)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_ADD_DONE:
|
case ALPM_EVENT_ADD_DONE:
|
||||||
alpm_logaction(config->handle, PACMAN_CALLER_PREFIX,
|
|
||||||
"installed %s (%s)\n",
|
|
||||||
alpm_pkg_get_name(data1),
|
|
||||||
alpm_pkg_get_version(data1));
|
|
||||||
display_optdepends(data1);
|
display_optdepends(data1);
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_REMOVE_START:
|
case ALPM_EVENT_REMOVE_START:
|
||||||
|
@ -188,23 +182,12 @@ void cb_event(alpm_event_t event, void *data1, void *data2)
|
||||||
printf(_("removing %s...\n"), alpm_pkg_get_name(data1));
|
printf(_("removing %s...\n"), alpm_pkg_get_name(data1));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_REMOVE_DONE:
|
|
||||||
alpm_logaction(config->handle, PACMAN_CALLER_PREFIX,
|
|
||||||
"removed %s (%s)\n",
|
|
||||||
alpm_pkg_get_name(data1),
|
|
||||||
alpm_pkg_get_version(data1));
|
|
||||||
break;
|
|
||||||
case ALPM_EVENT_UPGRADE_START:
|
case ALPM_EVENT_UPGRADE_START:
|
||||||
if(config->noprogressbar) {
|
if(config->noprogressbar) {
|
||||||
printf(_("upgrading %s...\n"), alpm_pkg_get_name(data1));
|
printf(_("upgrading %s...\n"), alpm_pkg_get_name(data1));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_UPGRADE_DONE:
|
case ALPM_EVENT_UPGRADE_DONE:
|
||||||
alpm_logaction(config->handle, PACMAN_CALLER_PREFIX,
|
|
||||||
"upgraded %s (%s -> %s)\n",
|
|
||||||
alpm_pkg_get_name(data1),
|
|
||||||
alpm_pkg_get_version(data2),
|
|
||||||
alpm_pkg_get_version(data1));
|
|
||||||
display_new_optdepends(data2, data1);
|
display_new_optdepends(data2, data1);
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_DOWNGRADE_START:
|
case ALPM_EVENT_DOWNGRADE_START:
|
||||||
|
@ -213,11 +196,6 @@ void cb_event(alpm_event_t event, void *data1, void *data2)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_DOWNGRADE_DONE:
|
case ALPM_EVENT_DOWNGRADE_DONE:
|
||||||
alpm_logaction(config->handle, PACMAN_CALLER_PREFIX,
|
|
||||||
"downgraded %s (%s -> %s)\n",
|
|
||||||
alpm_pkg_get_name(data1),
|
|
||||||
alpm_pkg_get_version(data2),
|
|
||||||
alpm_pkg_get_version(data1));
|
|
||||||
display_new_optdepends(data2, data1);
|
display_new_optdepends(data2, data1);
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_REINSTALL_START:
|
case ALPM_EVENT_REINSTALL_START:
|
||||||
|
@ -225,12 +203,6 @@ void cb_event(alpm_event_t event, void *data1, void *data2)
|
||||||
printf(_("reinstalling %s...\n"), alpm_pkg_get_name(data1));
|
printf(_("reinstalling %s...\n"), alpm_pkg_get_name(data1));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ALPM_EVENT_REINSTALL_DONE:
|
|
||||||
alpm_logaction(config->handle, PACMAN_CALLER_PREFIX,
|
|
||||||
"reinstalled %s (%s)\n",
|
|
||||||
alpm_pkg_get_name(data1),
|
|
||||||
alpm_pkg_get_version(data1));
|
|
||||||
break;
|
|
||||||
case ALPM_EVENT_INTEGRITY_START:
|
case ALPM_EVENT_INTEGRITY_START:
|
||||||
if(config->noprogressbar) {
|
if(config->noprogressbar) {
|
||||||
printf(_("checking package integrity...\n"));
|
printf(_("checking package integrity...\n"));
|
||||||
|
@ -286,6 +258,8 @@ void cb_event(alpm_event_t event, void *data1, void *data2)
|
||||||
}
|
}
|
||||||
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:
|
||||||
|
|
Loading…
Reference in New Issue