mirror of
https://github.com/moparisthebest/pacman
synced 2024-08-13 17:03:46 -04:00
make status/log messages reflect version change
Currently pacman either prints 'adding' or 'upgrading' when installing a package. This make pacman print and log the other possible actions: 'downgrade' and 'reinstall' Signed-off-by: Simon Gomizelj <simongmzlj@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
9876d97839
commit
ce9fd69eba
@ -464,10 +464,13 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
|
|||||||
size_t pkg_current, size_t pkg_count)
|
size_t pkg_current, size_t pkg_count)
|
||||||
{
|
{
|
||||||
int i, ret = 0, errors = 0;
|
int i, ret = 0, errors = 0;
|
||||||
int is_upgrade;
|
int is_upgrade = 0;
|
||||||
alpm_pkg_t *oldpkg = NULL;
|
alpm_pkg_t *oldpkg = NULL;
|
||||||
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 event = ALPM_PROGRESS_ADD_START;
|
||||||
|
alpm_event_t done = ALPM_EVENT_ADD_DONE, start = ALPM_EVENT_ADD_START;
|
||||||
|
const char *log_msg = "adding";
|
||||||
const char *pkgfile;
|
const char *pkgfile;
|
||||||
|
|
||||||
ASSERT(trans != NULL, return -1);
|
ASSERT(trans != NULL, return -1);
|
||||||
@ -475,6 +478,23 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
|
|||||||
/* see if this is an upgrade. if so, remove the old package first */
|
/* see if this is an upgrade. if so, remove the old package first */
|
||||||
alpm_pkg_t *local = _alpm_db_get_pkgfromcache(db, newpkg->name);
|
alpm_pkg_t *local = _alpm_db_get_pkgfromcache(db, newpkg->name);
|
||||||
if(local) {
|
if(local) {
|
||||||
|
int cmp = _alpm_pkg_compare_versions(newpkg, local);
|
||||||
|
if(cmp < 0) {
|
||||||
|
log_msg = "downgrading";
|
||||||
|
event = ALPM_PROGRESS_DOWNGRADE_START;
|
||||||
|
start = ALPM_EVENT_DOWNGRADE_START;
|
||||||
|
done = ALPM_EVENT_DOWNGRADE_DONE;
|
||||||
|
} else if(cmp == 0) {
|
||||||
|
log_msg = "reinstalling";
|
||||||
|
event = ALPM_PROGRESS_REINSTALL_START;
|
||||||
|
start = ALPM_EVENT_REINSTALL_START;
|
||||||
|
done = ALPM_EVENT_REINSTALL_DONE;
|
||||||
|
} else {
|
||||||
|
log_msg = "upgrading";
|
||||||
|
event = ALPM_PROGRESS_UPGRADE_START;
|
||||||
|
start = ALPM_EVENT_UPGRADE_START;
|
||||||
|
done = ALPM_EVENT_UPGRADE_DONE;
|
||||||
|
}
|
||||||
is_upgrade = 1;
|
is_upgrade = 1;
|
||||||
|
|
||||||
/* we'll need to save some record for backup checks later */
|
/* we'll need to save some record for backup checks later */
|
||||||
@ -485,17 +505,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);
|
||||||
|
|
||||||
EVENT(handle, ALPM_EVENT_UPGRADE_START, newpkg, local);
|
|
||||||
} else {
|
|
||||||
is_upgrade = 0;
|
|
||||||
EVENT(handle, ALPM_EVENT_ADD_START, newpkg, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EVENT(handle, start, newpkg, local);
|
||||||
|
|
||||||
pkgfile = newpkg->origin_data.file;
|
pkgfile = newpkg->origin_data.file;
|
||||||
|
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "%s package %s-%s\n",
|
_alpm_log(handle, ALPM_LOG_DEBUG, "%s package %s-%s\n",
|
||||||
is_upgrade ? "upgrading" : "adding", newpkg->name, newpkg->version);
|
log_msg, newpkg->name, newpkg->version);
|
||||||
/* pre_install/pre_upgrade scriptlet */
|
/* pre_install/pre_upgrade scriptlet */
|
||||||
if(alpm_pkg_has_scriptlet(newpkg) &&
|
if(alpm_pkg_has_scriptlet(newpkg) &&
|
||||||
!(trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
|
!(trans->flags & ALPM_TRANS_FLAG_NOSCRIPTLET)) {
|
||||||
@ -564,13 +581,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* call PROGRESS once with 0 percent, as we sort-of skip that here */
|
/* call PROGRESS once with 0 percent, as we sort-of skip that here */
|
||||||
if(is_upgrade) {
|
PROGRESS(handle, event, newpkg->name, 0, pkg_count, pkg_current);
|
||||||
PROGRESS(handle, ALPM_PROGRESS_UPGRADE_START,
|
|
||||||
newpkg->name, 0, pkg_count, pkg_current);
|
|
||||||
} else {
|
|
||||||
PROGRESS(handle, ALPM_PROGRESS_ADD_START,
|
|
||||||
newpkg->name, 0, pkg_count, pkg_current);
|
|
||||||
}
|
|
||||||
|
|
||||||
for(i = 0; archive_read_next_header(archive, &entry) == ARCHIVE_OK; i++) {
|
for(i = 0; archive_read_next_header(archive, &entry) == ARCHIVE_OK; i++) {
|
||||||
int percent;
|
int percent;
|
||||||
@ -588,13 +599,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
|
|||||||
percent = 0;
|
percent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_upgrade) {
|
PROGRESS(handle, event, newpkg->name, percent, pkg_count, pkg_current);
|
||||||
PROGRESS(handle, ALPM_PROGRESS_UPGRADE_START,
|
|
||||||
newpkg->name, percent, pkg_count, pkg_current);
|
|
||||||
} else {
|
|
||||||
PROGRESS(handle, ALPM_PROGRESS_ADD_START,
|
|
||||||
newpkg->name, percent, pkg_count, pkg_current);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* extract the next file from the archive */
|
/* extract the next file from the archive */
|
||||||
errors += extract_single_file(handle, archive, entry, newpkg, oldpkg);
|
errors += extract_single_file(handle, archive, entry, newpkg, oldpkg);
|
||||||
@ -651,13 +656,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
|
|||||||
newpkg->name);
|
newpkg->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_upgrade) {
|
PROGRESS(handle, event, newpkg->name, 100, pkg_count, pkg_current);
|
||||||
PROGRESS(handle, ALPM_PROGRESS_UPGRADE_START,
|
|
||||||
newpkg->name, 100, pkg_count, pkg_current);
|
|
||||||
} else {
|
|
||||||
PROGRESS(handle, ALPM_PROGRESS_ADD_START,
|
|
||||||
newpkg->name, 100, pkg_count, pkg_current);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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)
|
||||||
@ -670,11 +669,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
|
|||||||
free(scriptlet);
|
free(scriptlet);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_upgrade) {
|
EVENT(handle, done, newpkg, oldpkg);
|
||||||
EVENT(handle, ALPM_EVENT_UPGRADE_DONE, newpkg, oldpkg);
|
|
||||||
} else {
|
|
||||||
EVENT(handle, ALPM_EVENT_ADD_DONE, newpkg, oldpkg);
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
_alpm_pkg_free(oldpkg);
|
_alpm_pkg_free(oldpkg);
|
||||||
|
@ -321,6 +321,24 @@ typedef enum _alpm_event_t {
|
|||||||
* to the callback, respectively.
|
* to the callback, respectively.
|
||||||
*/
|
*/
|
||||||
ALPM_EVENT_UPGRADE_DONE,
|
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. */
|
||||||
@ -400,6 +418,8 @@ typedef void (*alpm_cb_question)(alpm_question_t, void *, void *, void *, int *)
|
|||||||
typedef enum _alpm_progress_t {
|
typedef enum _alpm_progress_t {
|
||||||
ALPM_PROGRESS_ADD_START,
|
ALPM_PROGRESS_ADD_START,
|
||||||
ALPM_PROGRESS_UPGRADE_START,
|
ALPM_PROGRESS_UPGRADE_START,
|
||||||
|
ALPM_PROGRESS_DOWNGRADE_START,
|
||||||
|
ALPM_PROGRESS_REINSTALL_START,
|
||||||
ALPM_PROGRESS_REMOVE_START,
|
ALPM_PROGRESS_REMOVE_START,
|
||||||
ALPM_PROGRESS_CONFLICTS_START,
|
ALPM_PROGRESS_CONFLICTS_START,
|
||||||
ALPM_PROGRESS_DISKSPACE_START,
|
ALPM_PROGRESS_DISKSPACE_START,
|
||||||
|
@ -207,6 +207,30 @@ void cb_event(alpm_event_t event, void *data1, void *data2)
|
|||||||
alpm_pkg_get_version(data1));
|
alpm_pkg_get_version(data1));
|
||||||
display_new_optdepends(data2, data1);
|
display_new_optdepends(data2, data1);
|
||||||
break;
|
break;
|
||||||
|
case ALPM_EVENT_DOWNGRADE_START:
|
||||||
|
if(config->noprogressbar) {
|
||||||
|
printf(_("downgrading %s...\n"), alpm_pkg_get_name(data1));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
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);
|
||||||
|
break;
|
||||||
|
case ALPM_EVENT_REINSTALL_START:
|
||||||
|
if(config->noprogressbar) {
|
||||||
|
printf(_("reinstalling %s...\n"), alpm_pkg_get_name(data1));
|
||||||
|
}
|
||||||
|
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"));
|
||||||
@ -444,6 +468,12 @@ void cb_progress(alpm_progress_t event, const char *pkgname, int percent,
|
|||||||
case ALPM_PROGRESS_UPGRADE_START:
|
case ALPM_PROGRESS_UPGRADE_START:
|
||||||
opr = _("upgrading");
|
opr = _("upgrading");
|
||||||
break;
|
break;
|
||||||
|
case ALPM_PROGRESS_DOWNGRADE_START:
|
||||||
|
opr = _("downgrading");
|
||||||
|
break;
|
||||||
|
case ALPM_PROGRESS_REINSTALL_START:
|
||||||
|
opr = _("reinstalling");
|
||||||
|
break;
|
||||||
case ALPM_PROGRESS_REMOVE_START:
|
case ALPM_PROGRESS_REMOVE_START:
|
||||||
opr = _("removing");
|
opr = _("removing");
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user