pacman+libalpm: print version names for conflicting packages
When ever pacman prints a conflict, it now prints pkgname-version, instead of just pkgname. alpm_conflict_t now carries *alpm_pkg_ts instead of just the names of each package. Fixes FS#12536 (point 2)
This commit is contained in:
parent
f9d8beef45
commit
2348dcab22
6 changed files with 70 additions and 54 deletions
|
@ -600,16 +600,10 @@ typedef struct _alpm_depmissing_t {
|
||||||
|
|
||||||
/** A conflict that has occurred between two packages. */
|
/** A conflict that has occurred between two packages. */
|
||||||
typedef struct _alpm_conflict_t {
|
typedef struct _alpm_conflict_t {
|
||||||
/** Hash of the first package name
|
/** The first package */
|
||||||
* (used internally to speed up conflict checks) */
|
alpm_pkg_t *package1;
|
||||||
unsigned long package1_hash;
|
/** The second package */
|
||||||
/** Hash of the second package name
|
alpm_pkg_t *package2;
|
||||||
* (used internally to speed up conflict checks) */
|
|
||||||
unsigned long package2_hash;
|
|
||||||
/** Name of the first package */
|
|
||||||
char *package1;
|
|
||||||
/** Name of the second package */
|
|
||||||
char *package2;
|
|
||||||
/** The conflict */
|
/** The conflict */
|
||||||
alpm_depend_t *reason;
|
alpm_depend_t *reason;
|
||||||
} alpm_conflict_t;
|
} alpm_conflict_t;
|
||||||
|
|
|
@ -50,10 +50,8 @@ static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2,
|
||||||
|
|
||||||
CALLOC(conflict, 1, sizeof(alpm_conflict_t), return NULL);
|
CALLOC(conflict, 1, sizeof(alpm_conflict_t), return NULL);
|
||||||
|
|
||||||
conflict->package1_hash = pkg1->name_hash;
|
ASSERT(_alpm_pkg_dup(pkg1, &conflict->package1) == 0, goto error);
|
||||||
conflict->package2_hash = pkg2->name_hash;
|
ASSERT(_alpm_pkg_dup(pkg2, &conflict->package2) == 0, goto error);
|
||||||
STRDUP(conflict->package1, pkg1->name, goto error);
|
|
||||||
STRDUP(conflict->package2, pkg2->name, goto error);
|
|
||||||
conflict->reason = reason;
|
conflict->reason = reason;
|
||||||
|
|
||||||
return conflict;
|
return conflict;
|
||||||
|
@ -66,8 +64,9 @@ error:
|
||||||
void SYMEXPORT alpm_conflict_free(alpm_conflict_t *conflict)
|
void SYMEXPORT alpm_conflict_free(alpm_conflict_t *conflict)
|
||||||
{
|
{
|
||||||
ASSERT(conflict != NULL, return);
|
ASSERT(conflict != NULL, return);
|
||||||
FREE(conflict->package2);
|
_alpm_pkg_free(conflict->package1);
|
||||||
FREE(conflict->package1);
|
_alpm_pkg_free(conflict->package2);
|
||||||
|
|
||||||
FREE(conflict);
|
FREE(conflict);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,10 +78,8 @@ alpm_conflict_t *_alpm_conflict_dup(const alpm_conflict_t *conflict)
|
||||||
alpm_conflict_t *newconflict;
|
alpm_conflict_t *newconflict;
|
||||||
CALLOC(newconflict, 1, sizeof(alpm_conflict_t), return NULL);
|
CALLOC(newconflict, 1, sizeof(alpm_conflict_t), return NULL);
|
||||||
|
|
||||||
newconflict->package1_hash = conflict->package1_hash;
|
ASSERT(_alpm_pkg_dup(conflict->package1, &newconflict->package1) == 0, goto error);
|
||||||
newconflict->package2_hash = conflict->package2_hash;
|
ASSERT(_alpm_pkg_dup(conflict->package2, &newconflict->package2) == 0, goto error);
|
||||||
STRDUP(newconflict->package1, conflict->package1, goto error);
|
|
||||||
STRDUP(newconflict->package2, conflict->package2, goto error);
|
|
||||||
newconflict->reason = conflict->reason;
|
newconflict->reason = conflict->reason;
|
||||||
|
|
||||||
return newconflict;
|
return newconflict;
|
||||||
|
@ -105,10 +102,10 @@ static int conflict_isin(alpm_conflict_t *needle, alpm_list_t *haystack)
|
||||||
alpm_list_t *i;
|
alpm_list_t *i;
|
||||||
for(i = haystack; i; i = i->next) {
|
for(i = haystack; i; i = i->next) {
|
||||||
alpm_conflict_t *conflict = i->data;
|
alpm_conflict_t *conflict = i->data;
|
||||||
if(needle->package1_hash == conflict->package1_hash
|
if(needle->package1->name_hash == conflict->package1->name_hash
|
||||||
&& needle->package2_hash == conflict->package2_hash
|
&& needle->package2->name_hash == conflict->package2->name_hash
|
||||||
&& strcmp(needle->package1, conflict->package1) == 0
|
&& strcmp(needle->package1->name, conflict->package1->name) == 0
|
||||||
&& strcmp(needle->package2, conflict->package2) == 0) {
|
&& strcmp(needle->package2->name, conflict->package2->name) == 0) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -517,21 +517,23 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
|
||||||
|
|
||||||
for(i = deps; i; i = i->next) {
|
for(i = deps; i; i = i->next) {
|
||||||
alpm_conflict_t *conflict = i->data;
|
alpm_conflict_t *conflict = i->data;
|
||||||
|
const char *name1 = conflict->package1->name;
|
||||||
|
const char *name2 = conflict->package2->name;
|
||||||
alpm_pkg_t *rsync, *sync, *sync1, *sync2;
|
alpm_pkg_t *rsync, *sync, *sync1, *sync2;
|
||||||
|
|
||||||
/* have we already removed one of the conflicting targets? */
|
/* have we already removed one of the conflicting targets? */
|
||||||
sync1 = alpm_pkg_find(trans->add, conflict->package1);
|
sync1 = alpm_pkg_find(trans->add, name1);
|
||||||
sync2 = alpm_pkg_find(trans->add, conflict->package2);
|
sync2 = alpm_pkg_find(trans->add, name2);
|
||||||
if(!sync1 || !sync2) {
|
if(!sync1 || !sync2) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "conflicting packages in the sync list: '%s' <-> '%s'\n",
|
_alpm_log(handle, ALPM_LOG_DEBUG, "conflicting packages in the sync list: '%s' <-> '%s'\n",
|
||||||
conflict->package1, conflict->package2);
|
name1, name2);
|
||||||
|
|
||||||
/* if sync1 provides sync2, we remove sync2 from the targets, and vice versa */
|
/* if sync1 provides sync2, we remove sync2 from the targets, and vice versa */
|
||||||
alpm_depend_t *dep1 = alpm_dep_from_string(conflict->package1);
|
alpm_depend_t *dep1 = alpm_dep_from_string(name1);
|
||||||
alpm_depend_t *dep2 = alpm_dep_from_string(conflict->package2);
|
alpm_depend_t *dep2 = alpm_dep_from_string(name2);
|
||||||
if(_alpm_depcmp(sync1, dep2)) {
|
if(_alpm_depcmp(sync1, dep2)) {
|
||||||
rsync = sync2;
|
rsync = sync2;
|
||||||
sync = sync1;
|
sync = sync1;
|
||||||
|
@ -559,8 +561,8 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
|
||||||
|
|
||||||
/* Prints warning */
|
/* Prints warning */
|
||||||
_alpm_log(handle, ALPM_LOG_WARNING,
|
_alpm_log(handle, ALPM_LOG_WARNING,
|
||||||
_("removing '%s' from target list because it conflicts with '%s'\n"),
|
_("removing '%s-%s' from target list because it conflicts with '%s-%s'\n"),
|
||||||
rsync->name, sync->name);
|
rsync->name, rsync->version, sync->name, sync->version);
|
||||||
trans->add = alpm_list_remove(trans->add, rsync, _alpm_pkg_cmp, NULL);
|
trans->add = alpm_list_remove(trans->add, rsync, _alpm_pkg_cmp, NULL);
|
||||||
/* rsync is not a transaction target anymore */
|
/* rsync is not a transaction target anymore */
|
||||||
trans->unresolvable = alpm_list_add(trans->unresolvable, rsync);
|
trans->unresolvable = alpm_list_add(trans->unresolvable, rsync);
|
||||||
|
@ -581,16 +583,18 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
|
||||||
.conflict = i->data
|
.conflict = i->data
|
||||||
};
|
};
|
||||||
alpm_conflict_t *conflict = i->data;
|
alpm_conflict_t *conflict = i->data;
|
||||||
|
const char *name1 = conflict->package1->name;
|
||||||
|
const char *name2 = conflict->package2->name;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
|
||||||
/* if conflict->package2 (the local package) is not elected for removal,
|
/* if name2 (the local package) is not elected for removal,
|
||||||
we ask the user */
|
we ask the user */
|
||||||
if(alpm_pkg_find(trans->remove, conflict->package2)) {
|
if(alpm_pkg_find(trans->remove, name2)) {
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
for(j = trans->add; j && !found; j = j->next) {
|
for(j = trans->add; j && !found; j = j->next) {
|
||||||
alpm_pkg_t *spkg = j->data;
|
alpm_pkg_t *spkg = j->data;
|
||||||
if(alpm_pkg_find(spkg->removes, conflict->package2)) {
|
if(alpm_pkg_find(spkg->removes, name2)) {
|
||||||
found = 1;
|
found = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -598,15 +602,15 @@ int _alpm_sync_prepare(alpm_handle_t *handle, alpm_list_t **data)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "package '%s' conflicts with '%s'\n",
|
_alpm_log(handle, ALPM_LOG_DEBUG, "package '%s-%s' conflicts with '%s-%s'\n",
|
||||||
conflict->package1, conflict->package2);
|
name1, conflict->package1->version, name2,conflict->package2->version);
|
||||||
|
|
||||||
QUESTION(handle, &question);
|
QUESTION(handle, &question);
|
||||||
if(question.remove) {
|
if(question.remove) {
|
||||||
/* append to the removes list */
|
/* append to the removes list */
|
||||||
alpm_pkg_t *sync = alpm_pkg_find(trans->add, conflict->package1);
|
alpm_pkg_t *sync = alpm_pkg_find(trans->add, name1);
|
||||||
alpm_pkg_t *local = _alpm_db_get_pkgfromcache(handle->db_local, conflict->package2);
|
alpm_pkg_t *local = _alpm_db_get_pkgfromcache(handle->db_local, name2);
|
||||||
_alpm_log(handle, ALPM_LOG_DEBUG, "electing '%s' for removal\n", conflict->package2);
|
_alpm_log(handle, ALPM_LOG_DEBUG, "electing '%s' for removal\n", name2);
|
||||||
sync->removes = alpm_list_add(sync->removes, local);
|
sync->removes = alpm_list_add(sync->removes, local);
|
||||||
} else { /* abort */
|
} else { /* abort */
|
||||||
_alpm_log(handle, ALPM_LOG_ERROR, _("unresolvable package conflicts detected\n"));
|
_alpm_log(handle, ALPM_LOG_ERROR, _("unresolvable package conflicts detected\n"));
|
||||||
|
|
|
@ -423,6 +423,8 @@ void cb_event(void *ctx, alpm_event_t *event)
|
||||||
void cb_question(void *ctx, alpm_question_t *question)
|
void cb_question(void *ctx, alpm_question_t *question)
|
||||||
{
|
{
|
||||||
(void)ctx;
|
(void)ctx;
|
||||||
|
const colstr_t *colstr = &config->colstr;
|
||||||
|
|
||||||
if(config->print) {
|
if(config->print) {
|
||||||
switch(question->type) {
|
switch(question->type) {
|
||||||
case ALPM_QUESTION_INSTALL_IGNOREPKG:
|
case ALPM_QUESTION_INSTALL_IGNOREPKG:
|
||||||
|
@ -460,18 +462,30 @@ void cb_question(void *ctx, alpm_question_t *question)
|
||||||
{
|
{
|
||||||
alpm_question_conflict_t *q = &question->conflict;
|
alpm_question_conflict_t *q = &question->conflict;
|
||||||
/* print conflict only if it contains new information */
|
/* print conflict only if it contains new information */
|
||||||
if(strcmp(q->conflict->package1, q->conflict->reason->name) == 0
|
if(strcmp(alpm_pkg_get_name(q->conflict->package1), q->conflict->reason->name) == 0
|
||||||
|| strcmp(q->conflict->package2, q->conflict->reason->name) == 0) {
|
|| strcmp(alpm_pkg_get_name(q->conflict->package2), q->conflict->reason->name) == 0) {
|
||||||
q->remove = noyes(_("%s and %s are in conflict. Remove %s?"),
|
q->remove = noyes(_("%s-%s%s%s and %s-%s%s%s are in conflict. Remove %s?"),
|
||||||
q->conflict->package1,
|
alpm_pkg_get_name(q->conflict->package1),
|
||||||
q->conflict->package2,
|
colstr->faint,
|
||||||
q->conflict->package2);
|
alpm_pkg_get_version(q->conflict->package1),
|
||||||
|
colstr->nocolor,
|
||||||
|
alpm_pkg_get_name(q->conflict->package2),
|
||||||
|
colstr->faint,
|
||||||
|
alpm_pkg_get_version(q->conflict->package2),
|
||||||
|
colstr->nocolor,
|
||||||
|
alpm_pkg_get_name(q->conflict->package2));
|
||||||
} else {
|
} else {
|
||||||
q->remove = noyes(_("%s and %s are in conflict (%s). Remove %s?"),
|
q->remove = noyes(_("%s-%s%s%s and %s-%s%s%s are in conflict (%s). Remove %s?"),
|
||||||
q->conflict->package1,
|
alpm_pkg_get_name(q->conflict->package1),
|
||||||
q->conflict->package2,
|
colstr->faint,
|
||||||
|
alpm_pkg_get_version(q->conflict->package1),
|
||||||
|
colstr->nocolor,
|
||||||
|
alpm_pkg_get_name(q->conflict->package2),
|
||||||
|
colstr->faint,
|
||||||
|
alpm_pkg_get_version(q->conflict->package2),
|
||||||
|
colstr->nocolor,
|
||||||
q->conflict->reason->name,
|
q->conflict->reason->name,
|
||||||
q->conflict->package2);
|
alpm_pkg_get_name(q->conflict->package2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -157,7 +157,7 @@ static int check_db_local_package_conflicts(alpm_list_t *pkglist)
|
||||||
for(i = data; i; i = i->next) {
|
for(i = data; i; i = i->next) {
|
||||||
alpm_conflict_t *conflict = i->data;
|
alpm_conflict_t *conflict = i->data;
|
||||||
pm_printf(ALPM_LOG_ERROR, "'%s' conflicts with '%s'\n",
|
pm_printf(ALPM_LOG_ERROR, "'%s' conflicts with '%s'\n",
|
||||||
conflict->package1, conflict->package2);
|
alpm_pkg_get_name(conflict->package1), alpm_pkg_get_name(conflict->package2));
|
||||||
ret++;
|
ret++;
|
||||||
}
|
}
|
||||||
alpm_list_free_inner(data, (alpm_list_fn_free)alpm_conflict_free);
|
alpm_list_free_inner(data, (alpm_list_fn_free)alpm_conflict_free);
|
||||||
|
|
|
@ -778,12 +778,19 @@ int sync_prepare_execute(void)
|
||||||
alpm_conflict_t *conflict = i->data;
|
alpm_conflict_t *conflict = i->data;
|
||||||
/* only print reason if it contains new information */
|
/* only print reason if it contains new information */
|
||||||
if(conflict->reason->mod == ALPM_DEP_MOD_ANY) {
|
if(conflict->reason->mod == ALPM_DEP_MOD_ANY) {
|
||||||
colon_printf(_("%s and %s are in conflict\n"),
|
colon_printf(_("%s-%s and %s-%s are in conflict\n"),
|
||||||
conflict->package1, conflict->package2);
|
alpm_pkg_get_name(conflict->package1),
|
||||||
|
alpm_pkg_get_version(conflict->package1),
|
||||||
|
alpm_pkg_get_name(conflict->package2),
|
||||||
|
alpm_pkg_get_version(conflict->package2));
|
||||||
} else {
|
} else {
|
||||||
char *reason = alpm_dep_compute_string(conflict->reason);
|
char *reason = alpm_dep_compute_string(conflict->reason);
|
||||||
colon_printf(_("%s and %s are in conflict (%s)\n"),
|
colon_printf(_("%s-%s and %s-%s are in conflict (%s)\n"),
|
||||||
conflict->package1, conflict->package2, reason);
|
alpm_pkg_get_name(conflict->package1),
|
||||||
|
alpm_pkg_get_version(conflict->package1),
|
||||||
|
alpm_pkg_get_name(conflict->package2),
|
||||||
|
alpm_pkg_get_version(conflict->package2),
|
||||||
|
reason);
|
||||||
free(reason);
|
free(reason);
|
||||||
}
|
}
|
||||||
alpm_conflict_free(conflict);
|
alpm_conflict_free(conflict);
|
||||||
|
|
Loading…
Add table
Reference in a new issue