mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-23 00:08:50 -05:00
pulled out conflict checkings from checkdeps() in its own function: checkconflicts()
This commit is contained in:
parent
83839f9513
commit
6dd2ecf4fa
@ -197,70 +197,34 @@ int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
|
|||||||
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
||||||
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
|
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
|
||||||
|
|
||||||
if(data) {
|
|
||||||
*data = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check dependencies
|
/* Check dependencies
|
||||||
*/
|
*/
|
||||||
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
|
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
|
||||||
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
|
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
|
||||||
|
|
||||||
_alpm_log(PM_LOG_FLOW1, "looking for conflicts or unsatisfied dependencies");
|
/* look for unsatisfied dependencies */
|
||||||
|
_alpm_log(PM_LOG_FLOW1, "looking for unsatisfied dependencies");
|
||||||
lp = checkdeps(db, trans->type, trans->packages);
|
lp = checkdeps(db, trans->type, trans->packages);
|
||||||
if(lp != NULL) {
|
if(lp != NULL) {
|
||||||
PMList *i;
|
|
||||||
int errorout = 0;
|
|
||||||
|
|
||||||
/* look for unsatisfied dependencies */
|
|
||||||
_alpm_log(PM_LOG_FLOW2, "looking for unsatisfied dependencies");
|
|
||||||
for(i = lp; i; i = i->next) {
|
|
||||||
pmdepmissing_t* miss = i->data;
|
|
||||||
|
|
||||||
if(miss->type == PM_DEP_TYPE_DEPEND || miss->type == PM_DEP_TYPE_REQUIRED) {
|
|
||||||
if(!errorout) {
|
|
||||||
errorout = 1;
|
|
||||||
}
|
|
||||||
if(data) {
|
if(data) {
|
||||||
if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
|
*data = lp;
|
||||||
|
} else {
|
||||||
FREELIST(lp);
|
FREELIST(lp);
|
||||||
FREELIST(*data);
|
|
||||||
RET_ERR(PM_ERR_MEMORY, -1);
|
|
||||||
}
|
}
|
||||||
*miss = *(pmdepmissing_t*)i->data;
|
|
||||||
*data = pm_list_add(*data, miss);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(errorout) {
|
|
||||||
FREELIST(lp);
|
|
||||||
RET_ERR(PM_ERR_UNSATISFIED_DEPS, -1);
|
RET_ERR(PM_ERR_UNSATISFIED_DEPS, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no unsatisfied deps, so look for conflicts */
|
/* no unsatisfied deps, so look for conflicts */
|
||||||
_alpm_log(PM_LOG_FLOW2, "looking for conflicts");
|
_alpm_log(PM_LOG_FLOW1, "looking for conflicts");
|
||||||
for(i = lp; i; i = i->next) {
|
lp = checkconflicts(db, trans->packages);
|
||||||
pmdepmissing_t* miss = (pmdepmissing_t *)i->data;
|
if(lp != NULL) {
|
||||||
if(miss->type == PM_DEP_TYPE_CONFLICT) {
|
|
||||||
if(!errorout) {
|
|
||||||
errorout = 1;
|
|
||||||
}
|
|
||||||
if(data) {
|
if(data) {
|
||||||
if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
|
*data = lp;
|
||||||
|
} else {
|
||||||
FREELIST(lp);
|
FREELIST(lp);
|
||||||
FREELIST(*data);
|
|
||||||
RET_ERR(PM_ERR_MEMORY, -1);
|
|
||||||
}
|
}
|
||||||
*miss = *(pmdepmissing_t*)i->data;
|
|
||||||
*data = pm_list_add(*data, miss);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FREELIST(lp);
|
|
||||||
if(errorout) {
|
|
||||||
RET_ERR(PM_ERR_CONFLICTING_DEPS, -1);
|
RET_ERR(PM_ERR_CONFLICTING_DEPS, -1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* re-order w.r.t. dependencies */
|
/* re-order w.r.t. dependencies */
|
||||||
_alpm_log(PM_LOG_FLOW1, "sorting by dependencies");
|
_alpm_log(PM_LOG_FLOW1, "sorting by dependencies");
|
||||||
@ -284,6 +248,8 @@ int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
|
|||||||
if(lp != NULL) {
|
if(lp != NULL) {
|
||||||
if(data) {
|
if(data) {
|
||||||
*data = lp;
|
*data = lp;
|
||||||
|
} else {
|
||||||
|
FREELIST(lp);
|
||||||
}
|
}
|
||||||
FREELIST(skiplist);
|
FREELIST(skiplist);
|
||||||
RET_ERR(PM_ERR_FILE_CONFLICTS, -1);
|
RET_ERR(PM_ERR_FILE_CONFLICTS, -1);
|
||||||
|
@ -29,8 +29,180 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
/* pacman */
|
/* pacman */
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "log.h"
|
||||||
|
#include "cache.h"
|
||||||
|
#include "deps.h"
|
||||||
#include "conflict.h"
|
#include "conflict.h"
|
||||||
|
|
||||||
|
/* Returns a PMList* of missing_t pointers.
|
||||||
|
*
|
||||||
|
* conflicts are always name only
|
||||||
|
*/
|
||||||
|
PMList *checkconflicts(pmdb_t *db, PMList *packages)
|
||||||
|
{
|
||||||
|
pmpkg_t *info = NULL;
|
||||||
|
PMList *i, *j, *k;
|
||||||
|
PMList *baddeps = NULL;
|
||||||
|
pmdepmissing_t *miss = NULL;
|
||||||
|
|
||||||
|
if(db == NULL) {
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(i = packages; i; i = i->next) {
|
||||||
|
pmpkg_t *tp = i->data;
|
||||||
|
if(tp == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for(j = tp->conflicts; j; j = j->next) {
|
||||||
|
if(!strcmp(tp->name, j->data)) {
|
||||||
|
/* a package cannot conflict with itself -- that's just not nice */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
/* CHECK 1: check targets against database */
|
||||||
|
for(k = db_get_pkgcache(db); k; k = k->next) {
|
||||||
|
pmpkg_t *dp = (pmpkg_t *)k->data;
|
||||||
|
if(!strcmp(dp->name, tp->name)) {
|
||||||
|
/* a package cannot conflict with itself -- that's just not nice */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(!strcmp(j->data, dp->name)) {
|
||||||
|
/* conflict */
|
||||||
|
MALLOC(miss, sizeof(pmdepmissing_t));
|
||||||
|
miss->type = PM_DEP_TYPE_CONFLICT;
|
||||||
|
miss->depend.mod = PM_DEP_MOD_ANY;
|
||||||
|
miss->depend.version[0] = '\0';
|
||||||
|
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
||||||
|
STRNCPY(miss->depend.name, dp->name, PKG_NAME_LEN);
|
||||||
|
if(!pm_list_is_in(miss, baddeps)) {
|
||||||
|
_alpm_log(PM_LOG_FLOW2, "checkdeps: targs vs db: adding %s as a conflict for %s",
|
||||||
|
dp->name, tp->name);
|
||||||
|
baddeps = pm_list_add(baddeps, miss);
|
||||||
|
} else {
|
||||||
|
FREE(miss);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* see if dp provides something in tp's conflict list */
|
||||||
|
PMList *m;
|
||||||
|
for(m = dp->provides; m; m = m->next) {
|
||||||
|
if(!strcmp(m->data, j->data)) {
|
||||||
|
/* confict */
|
||||||
|
MALLOC(miss, sizeof(pmdepmissing_t));
|
||||||
|
miss->type = PM_DEP_TYPE_CONFLICT;
|
||||||
|
miss->depend.mod = PM_DEP_MOD_ANY;
|
||||||
|
miss->depend.version[0] = '\0';
|
||||||
|
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
||||||
|
STRNCPY(miss->depend.name, dp->name, PKG_NAME_LEN);
|
||||||
|
if(!pm_list_is_in(miss, baddeps)) {
|
||||||
|
_alpm_log(PM_LOG_FLOW2, "checkdeps: targs vs db: adding %s as a conflict for %s",
|
||||||
|
dp->name, tp->name);
|
||||||
|
baddeps = pm_list_add(baddeps, miss);
|
||||||
|
} else {
|
||||||
|
FREE(miss);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* CHECK 2: check targets against targets */
|
||||||
|
for(k = packages; k; k = k->next) {
|
||||||
|
pmpkg_t *otp = (pmpkg_t *)k->data;
|
||||||
|
if(!strcmp(otp->name, tp->name)) {
|
||||||
|
/* a package cannot conflict with itself -- that's just not nice */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(!strcmp(otp->name, (char *)j->data)) {
|
||||||
|
/* otp is listed in tp's conflict list */
|
||||||
|
MALLOC(miss, sizeof(pmdepmissing_t));
|
||||||
|
miss->type = PM_DEP_TYPE_CONFLICT;
|
||||||
|
miss->depend.mod = PM_DEP_MOD_ANY;
|
||||||
|
miss->depend.version[0] = '\0';
|
||||||
|
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
||||||
|
STRNCPY(miss->depend.name, otp->name, PKG_NAME_LEN);
|
||||||
|
if(!pm_list_is_in(miss, baddeps)) {
|
||||||
|
_alpm_log(PM_LOG_FLOW2, "checkdeps: targs vs targs: adding %s as a conflict for %s",
|
||||||
|
otp->name, tp->name);
|
||||||
|
baddeps = pm_list_add(baddeps, miss);
|
||||||
|
} else {
|
||||||
|
FREE(miss);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* see if otp provides something in tp's conflict list */
|
||||||
|
PMList *m;
|
||||||
|
for(m = otp->provides; m; m = m->next) {
|
||||||
|
if(!strcmp(m->data, j->data)) {
|
||||||
|
MALLOC(miss, sizeof(pmdepmissing_t));
|
||||||
|
miss->type = PM_DEP_TYPE_CONFLICT;
|
||||||
|
miss->depend.mod = PM_DEP_MOD_ANY;
|
||||||
|
miss->depend.version[0] = '\0';
|
||||||
|
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
||||||
|
STRNCPY(miss->depend.name, otp->name, PKG_NAME_LEN);
|
||||||
|
if(!pm_list_is_in(miss, baddeps)) {
|
||||||
|
_alpm_log(PM_LOG_FLOW2, "checkdeps: targs vs targs: adding %s as a conflict for %s",
|
||||||
|
otp->name, tp->name);
|
||||||
|
baddeps = pm_list_add(baddeps, miss);
|
||||||
|
} else {
|
||||||
|
FREE(miss);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* CHECK 3: check database against targets */
|
||||||
|
for(k = db_get_pkgcache(db); k; k = k->next) {
|
||||||
|
info = k->data;
|
||||||
|
if(!strcmp(info->name, tp->name)) {
|
||||||
|
/* a package cannot conflict with itself -- that's just not nice */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for(j = info->conflicts; j; j = j->next) {
|
||||||
|
if(!strcmp((char *)j->data, tp->name)) {
|
||||||
|
MALLOC(miss, sizeof(pmdepmissing_t));
|
||||||
|
miss->type = PM_DEP_TYPE_CONFLICT;
|
||||||
|
miss->depend.mod = PM_DEP_MOD_ANY;
|
||||||
|
miss->depend.version[0] = '\0';
|
||||||
|
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
||||||
|
STRNCPY(miss->depend.name, info->name, PKG_NAME_LEN);
|
||||||
|
if(!pm_list_is_in(miss, baddeps)) {
|
||||||
|
_alpm_log(PM_LOG_FLOW2, "checkdeps: db vs targs: adding %s as a conflict for %s",
|
||||||
|
info->name, tp->name);
|
||||||
|
baddeps = pm_list_add(baddeps, miss);
|
||||||
|
} else {
|
||||||
|
FREE(miss);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* see if the db package conflicts with something we provide */
|
||||||
|
PMList *m;
|
||||||
|
for(m = info->conflicts; m; m = m->next) {
|
||||||
|
PMList *n;
|
||||||
|
for(n = tp->provides; n; n = n->next) {
|
||||||
|
if(!strcmp(m->data, n->data)) {
|
||||||
|
MALLOC(miss, sizeof(pmdepmissing_t));
|
||||||
|
miss->type = PM_DEP_TYPE_CONFLICT;
|
||||||
|
miss->depend.mod = PM_DEP_MOD_ANY;
|
||||||
|
miss->depend.version[0] = '\0';
|
||||||
|
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
||||||
|
STRNCPY(miss->depend.name, info->name, PKG_NAME_LEN);
|
||||||
|
if(!pm_list_is_in(miss, baddeps)) {
|
||||||
|
_alpm_log(PM_LOG_FLOW2, "checkdeps: db vs targs: adding %s as a conflict for %s",
|
||||||
|
info->name, tp->name);
|
||||||
|
baddeps = pm_list_add(baddeps, miss);
|
||||||
|
} else {
|
||||||
|
FREE(miss);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(baddeps);
|
||||||
|
}
|
||||||
|
|
||||||
PMList *db_find_conflicts(pmdb_t *db, PMList *targets, char *root, PMList **skip_list)
|
PMList *db_find_conflicts(pmdb_t *db, PMList *targets, char *root, PMList **skip_list)
|
||||||
{
|
{
|
||||||
PMList *i, *j, *k;
|
PMList *i, *j, *k;
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
|
||||||
|
PMList *checkconflicts(pmdb_t *db, PMList *packages);
|
||||||
PMList *db_find_conflicts(pmdb_t *db, PMList *targets, char *root, PMList **skip_list);
|
PMList *db_find_conflicts(pmdb_t *db, PMList *targets, char *root, PMList **skip_list);
|
||||||
|
|
||||||
#endif /* _ALPM_CONFLICT_H */
|
#endif /* _ALPM_CONFLICT_H */
|
||||||
|
@ -37,6 +37,25 @@
|
|||||||
|
|
||||||
extern pmhandle_t *handle;
|
extern pmhandle_t *handle;
|
||||||
|
|
||||||
|
static pmdepmissing_t *depmissing_new(const char *target, unsigned char type, unsigned char depmod,
|
||||||
|
const char *depname, const char *depversion)
|
||||||
|
{
|
||||||
|
pmdepmissing_t *miss;
|
||||||
|
|
||||||
|
miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t));
|
||||||
|
if(miss == NULL) {
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
STRNCPY(miss->target, target, PKG_NAME_LEN);
|
||||||
|
miss->type = type;
|
||||||
|
miss->depend.mod = depmod;
|
||||||
|
STRNCPY(miss->depend.name, depname, PKG_NAME_LEN);
|
||||||
|
STRNCPY(miss->depend.version, depversion, PKG_VERSION_LEN);
|
||||||
|
|
||||||
|
return(miss);
|
||||||
|
}
|
||||||
|
|
||||||
/* Re-order a list of target packages with respect to their dependencies.
|
/* Re-order a list of target packages with respect to their dependencies.
|
||||||
*
|
*
|
||||||
* Example (PM_TRANS_TYPE_ADD):
|
* Example (PM_TRANS_TYPE_ADD):
|
||||||
@ -121,13 +140,11 @@ PMList *sortbydeps(PMList *targets, int mode)
|
|||||||
|
|
||||||
/* Returns a PMList* of missing_t pointers.
|
/* Returns a PMList* of missing_t pointers.
|
||||||
*
|
*
|
||||||
* conflicts are always name only, but dependencies can include versions
|
* dependencies can include versions with depmod operators.
|
||||||
* with depmod operators.
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
|
PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
|
||||||
{
|
{
|
||||||
pmpkg_t *info = NULL;
|
|
||||||
pmdepend_t depend;
|
pmdepend_t depend;
|
||||||
PMList *i, *j, *k;
|
PMList *i, *j, *k;
|
||||||
int cmp;
|
int cmp;
|
||||||
@ -218,158 +235,13 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(op == PM_TRANS_TYPE_ADD || op == PM_TRANS_TYPE_UPGRADE) {
|
if(op == PM_TRANS_TYPE_ADD || op == PM_TRANS_TYPE_UPGRADE) {
|
||||||
|
/* DEPENDENCIES -- look for unsatisfied dependencies */
|
||||||
for(i = packages; i; i = i->next) {
|
for(i = packages; i; i = i->next) {
|
||||||
pmpkg_t *tp = i->data;
|
pmpkg_t *tp = i->data;
|
||||||
if(tp == NULL) {
|
if(tp == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CONFLICTS */
|
|
||||||
for(j = tp->conflicts; j; j = j->next) {
|
|
||||||
if(!strcmp(tp->name, j->data)) {
|
|
||||||
/* a package cannot conflict with itself -- that's just not nice */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/* CHECK 1: check targets against database */
|
|
||||||
for(k = db_get_pkgcache(db); k; k = k->next) {
|
|
||||||
pmpkg_t *dp = (pmpkg_t *)k->data;
|
|
||||||
if(!strcmp(dp->name, tp->name)) {
|
|
||||||
/* a package cannot conflict with itself -- that's just not nice */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(!strcmp(j->data, dp->name)) {
|
|
||||||
/* conflict */
|
|
||||||
MALLOC(miss, sizeof(pmdepmissing_t));
|
|
||||||
miss->type = PM_DEP_TYPE_CONFLICT;
|
|
||||||
miss->depend.mod = PM_DEP_MOD_ANY;
|
|
||||||
miss->depend.version[0] = '\0';
|
|
||||||
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
|
||||||
STRNCPY(miss->depend.name, dp->name, PKG_NAME_LEN);
|
|
||||||
if(!pm_list_is_in(miss, baddeps)) {
|
|
||||||
_alpm_log(PM_LOG_FLOW2, "checkdeps: targs vs db: adding %s as a conflict for %s",
|
|
||||||
dp->name, tp->name);
|
|
||||||
baddeps = pm_list_add(baddeps, miss);
|
|
||||||
} else {
|
|
||||||
FREE(miss);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* see if dp provides something in tp's conflict list */
|
|
||||||
PMList *m;
|
|
||||||
for(m = dp->provides; m; m = m->next) {
|
|
||||||
if(!strcmp(m->data, j->data)) {
|
|
||||||
/* confict */
|
|
||||||
MALLOC(miss, sizeof(pmdepmissing_t));
|
|
||||||
miss->type = PM_DEP_TYPE_CONFLICT;
|
|
||||||
miss->depend.mod = PM_DEP_MOD_ANY;
|
|
||||||
miss->depend.version[0] = '\0';
|
|
||||||
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
|
||||||
STRNCPY(miss->depend.name, dp->name, PKG_NAME_LEN);
|
|
||||||
if(!pm_list_is_in(miss, baddeps)) {
|
|
||||||
_alpm_log(PM_LOG_FLOW2, "checkdeps: targs vs db: adding %s as a conflict for %s",
|
|
||||||
dp->name, tp->name);
|
|
||||||
baddeps = pm_list_add(baddeps, miss);
|
|
||||||
} else {
|
|
||||||
FREE(miss);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* CHECK 2: check targets against targets */
|
|
||||||
for(k = packages; k; k = k->next) {
|
|
||||||
pmpkg_t *otp = (pmpkg_t *)k->data;
|
|
||||||
if(!strcmp(otp->name, tp->name)) {
|
|
||||||
/* a package cannot conflict with itself -- that's just not nice */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(!strcmp(otp->name, (char *)j->data)) {
|
|
||||||
/* otp is listed in tp's conflict list */
|
|
||||||
MALLOC(miss, sizeof(pmdepmissing_t));
|
|
||||||
miss->type = PM_DEP_TYPE_CONFLICT;
|
|
||||||
miss->depend.mod = PM_DEP_MOD_ANY;
|
|
||||||
miss->depend.version[0] = '\0';
|
|
||||||
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
|
||||||
STRNCPY(miss->depend.name, otp->name, PKG_NAME_LEN);
|
|
||||||
if(!pm_list_is_in(miss, baddeps)) {
|
|
||||||
_alpm_log(PM_LOG_FLOW2, "checkdeps: targs vs targs: adding %s as a conflict for %s",
|
|
||||||
otp->name, tp->name);
|
|
||||||
baddeps = pm_list_add(baddeps, miss);
|
|
||||||
} else {
|
|
||||||
FREE(miss);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* see if otp provides something in tp's conflict list */
|
|
||||||
PMList *m;
|
|
||||||
for(m = otp->provides; m; m = m->next) {
|
|
||||||
if(!strcmp(m->data, j->data)) {
|
|
||||||
MALLOC(miss, sizeof(pmdepmissing_t));
|
|
||||||
miss->type = PM_DEP_TYPE_CONFLICT;
|
|
||||||
miss->depend.mod = PM_DEP_MOD_ANY;
|
|
||||||
miss->depend.version[0] = '\0';
|
|
||||||
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
|
||||||
STRNCPY(miss->depend.name, otp->name, PKG_NAME_LEN);
|
|
||||||
if(!pm_list_is_in(miss, baddeps)) {
|
|
||||||
_alpm_log(PM_LOG_FLOW2, "checkdeps: targs vs targs: adding %s as a conflict for %s",
|
|
||||||
otp->name, tp->name);
|
|
||||||
baddeps = pm_list_add(baddeps, miss);
|
|
||||||
} else {
|
|
||||||
FREE(miss);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* CHECK 3: check database against targets */
|
|
||||||
for(k = db_get_pkgcache(db); k; k = k->next) {
|
|
||||||
info = k->data;
|
|
||||||
if(!strcmp(info->name, tp->name)) {
|
|
||||||
/* a package cannot conflict with itself -- that's just not nice */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for(j = info->conflicts; j; j = j->next) {
|
|
||||||
if(!strcmp((char *)j->data, tp->name)) {
|
|
||||||
MALLOC(miss, sizeof(pmdepmissing_t));
|
|
||||||
miss->type = PM_DEP_TYPE_CONFLICT;
|
|
||||||
miss->depend.mod = PM_DEP_MOD_ANY;
|
|
||||||
miss->depend.version[0] = '\0';
|
|
||||||
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
|
||||||
STRNCPY(miss->depend.name, info->name, PKG_NAME_LEN);
|
|
||||||
if(!pm_list_is_in(miss, baddeps)) {
|
|
||||||
_alpm_log(PM_LOG_FLOW2, "checkdeps: db vs targs: adding %s as a conflict for %s",
|
|
||||||
info->name, tp->name);
|
|
||||||
baddeps = pm_list_add(baddeps, miss);
|
|
||||||
} else {
|
|
||||||
FREE(miss);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* see if the db package conflicts with something we provide */
|
|
||||||
PMList *m;
|
|
||||||
for(m = info->conflicts; m; m = m->next) {
|
|
||||||
PMList *n;
|
|
||||||
for(n = tp->provides; n; n = n->next) {
|
|
||||||
if(!strcmp(m->data, n->data)) {
|
|
||||||
MALLOC(miss, sizeof(pmdepmissing_t));
|
|
||||||
miss->type = PM_DEP_TYPE_CONFLICT;
|
|
||||||
miss->depend.mod = PM_DEP_MOD_ANY;
|
|
||||||
miss->depend.version[0] = '\0';
|
|
||||||
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
|
||||||
STRNCPY(miss->depend.name, info->name, PKG_NAME_LEN);
|
|
||||||
if(!pm_list_is_in(miss, baddeps)) {
|
|
||||||
_alpm_log(PM_LOG_FLOW2, "checkdeps: db vs targs: adding %s as a conflict for %s",
|
|
||||||
info->name, tp->name);
|
|
||||||
baddeps = pm_list_add(baddeps, miss);
|
|
||||||
} else {
|
|
||||||
FREE(miss);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* DEPENDENCIES -- look for unsatisfied dependencies */
|
|
||||||
for(j = tp->depends; j; j = j->next) {
|
for(j = tp->depends; j; j = j->next) {
|
||||||
/* split into name/version pairs */
|
/* split into name/version pairs */
|
||||||
splitdep((char *)j->data, &depend);
|
splitdep((char *)j->data, &depend);
|
||||||
@ -650,6 +522,8 @@ int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list,
|
|||||||
for(i = deps; i; i = i->next) {
|
for(i = deps; i; i = i->next) {
|
||||||
int found = 0;
|
int found = 0;
|
||||||
pmdepmissing_t *miss = i->data;
|
pmdepmissing_t *miss = i->data;
|
||||||
|
pmpkg_t *sync = NULL;
|
||||||
|
int provisio_match = 0;
|
||||||
|
|
||||||
/* XXX: conflicts are now treated specially in the _add and _sync functions */
|
/* XXX: conflicts are now treated specially in the _add and _sync functions */
|
||||||
|
|
||||||
@ -658,9 +532,6 @@ int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list,
|
|||||||
RET_ERR(???, -1);
|
RET_ERR(???, -1);
|
||||||
} else*/
|
} else*/
|
||||||
|
|
||||||
if(miss->type == PM_DEP_TYPE_DEPEND) {
|
|
||||||
pmpkg_t *sync = NULL;
|
|
||||||
int provisio_match = 0;
|
|
||||||
|
|
||||||
/* check if one of the packages in *list already provides this dependency */
|
/* check if one of the packages in *list already provides this dependency */
|
||||||
for(j = list; j; j = j->next) {
|
for(j = list; j; j = j->next) {
|
||||||
@ -759,7 +630,6 @@ int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list,
|
|||||||
_alpm_log(PM_LOG_DEBUG, "dependency cycle detected: %s", sync->name);
|
_alpm_log(PM_LOG_DEBUG, "dependency cycle detected: %s", sync->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
FREELIST(deps);
|
FREELIST(deps);
|
||||||
|
|
||||||
|
@ -83,7 +83,8 @@ int remove_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
|
|||||||
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
|
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
|
||||||
|
|
||||||
_alpm_log(PM_LOG_FLOW1, "looking for unsatisfied dependencies");
|
_alpm_log(PM_LOG_FLOW1, "looking for unsatisfied dependencies");
|
||||||
if((lp = checkdeps(db, trans->type, trans->packages)) != NULL) {
|
lp = checkdeps(db, trans->type, trans->packages);
|
||||||
|
if(lp != NULL) {
|
||||||
if(trans->flags & PM_TRANS_FLAG_CASCADE) {
|
if(trans->flags & PM_TRANS_FLAG_CASCADE) {
|
||||||
while(lp) {
|
while(lp) {
|
||||||
PMList *j;
|
PMList *j;
|
||||||
@ -101,6 +102,8 @@ int remove_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
|
|||||||
} else {
|
} else {
|
||||||
if(data) {
|
if(data) {
|
||||||
*data = lp;
|
*data = lp;
|
||||||
|
} else {
|
||||||
|
FREELIST(lp);
|
||||||
}
|
}
|
||||||
RET_ERR(PM_ERR_UNSATISFIED_DEPS, -1);
|
RET_ERR(PM_ERR_UNSATISFIED_DEPS, -1);
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "db.h"
|
#include "db.h"
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "deps.h"
|
#include "deps.h"
|
||||||
|
#include "conflict.h"
|
||||||
#include "trans.h"
|
#include "trans.h"
|
||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "versioncmp.h"
|
#include "versioncmp.h"
|
||||||
@ -196,6 +197,7 @@ int sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* match installed packages with the sync dbs and compare versions */
|
/* match installed packages with the sync dbs and compare versions */
|
||||||
|
_alpm_log(PM_LOG_FLOW1, "checking for package upgrades");
|
||||||
for(i = db_get_pkgcache(db_local); i; i = i->next) {
|
for(i = db_get_pkgcache(db_local); i; i = i->next) {
|
||||||
int cmp;
|
int cmp;
|
||||||
int replace = 0;
|
int replace = 0;
|
||||||
@ -402,44 +404,29 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
|
|||||||
|
|
||||||
/* check for inter-conflicts and whatnot */
|
/* check for inter-conflicts and whatnot */
|
||||||
EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL);
|
EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL);
|
||||||
deps = checkdeps(db_local, PM_TRANS_TYPE_UPGRADE, list);
|
|
||||||
if(deps) {
|
|
||||||
int errorout = 0;
|
|
||||||
|
|
||||||
_alpm_log(PM_LOG_FLOW1, "looking for unresolvable dependencies");
|
_alpm_log(PM_LOG_FLOW1, "looking for unresolvable dependencies");
|
||||||
for(i = deps; i; i = i->next) {
|
deps = checkdeps(db_local, PM_TRANS_TYPE_UPGRADE, list);
|
||||||
pmdepmissing_t *miss = i->data;
|
if(deps) {
|
||||||
if(miss->type == PM_DEP_TYPE_DEPEND || miss->type == PM_DEP_TYPE_REQUIRED) {
|
|
||||||
if(!errorout) {
|
|
||||||
errorout = 1;
|
|
||||||
}
|
|
||||||
if(data) {
|
if(data) {
|
||||||
if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
|
*data = deps;
|
||||||
FREELIST(*data);
|
deps = NULL;
|
||||||
pm_errno = PM_ERR_MEMORY;
|
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
*miss = *(pmdepmissing_t *)i->data;
|
|
||||||
*data = pm_list_add(*data, miss);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(errorout) {
|
|
||||||
pm_errno = PM_ERR_UNSATISFIED_DEPS;
|
pm_errno = PM_ERR_UNSATISFIED_DEPS;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no unresolvable deps, so look for conflicts */
|
/* no unresolvable deps, so look for conflicts */
|
||||||
_alpm_log(PM_LOG_FLOW1, "looking for conflicts");
|
_alpm_log(PM_LOG_FLOW1, "looking for conflicts");
|
||||||
|
deps = checkconflicts(db_local, list);
|
||||||
|
if(deps) {
|
||||||
|
int errorout = 0;
|
||||||
|
|
||||||
for(i = deps; i && !errorout; i = i->next) {
|
for(i = deps; i && !errorout; i = i->next) {
|
||||||
pmdepmissing_t *miss = i->data;
|
pmdepmissing_t *miss = i->data;
|
||||||
PMList *k;
|
PMList *k;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
|
||||||
if(miss->type != PM_DEP_TYPE_CONFLICT) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
_alpm_log(PM_LOG_FLOW2, "package %s is conflicting with %s",
|
_alpm_log(PM_LOG_FLOW2, "package %s is conflicting with %s",
|
||||||
miss->target, miss->depend.name);
|
miss->target, miss->depend.name);
|
||||||
|
|
||||||
@ -634,6 +621,7 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
|
|||||||
pm_errno = PM_ERR_UNSATISFIED_DEPS;
|
pm_errno = PM_ERR_UNSATISFIED_DEPS;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
FREELIST(deps);
|
||||||
}
|
}
|
||||||
FREELISTPTR(list);
|
FREELISTPTR(list);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user