1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-11 20:05:07 -05:00

checkdeps:

- merged missing chunks of code from pacman 2.9.7
- more debug logs
This commit is contained in:
Aurelien Foret 2006-01-14 15:05:59 +00:00
parent aeb0133974
commit cb9d23baf8

View File

@ -233,8 +233,12 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
/* CHECK 1: check targets against database */ /* CHECK 1: check targets against database */
for(k = db_get_pkgcache(db); k; k = k->next) { for(k = db_get_pkgcache(db); k; k = k->next) {
pmpkg_t *dp = (pmpkg_t *)k->data; 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)) { if(!strcmp(j->data, dp->name)) {
/* confict */ /* conflict */
MALLOC(miss, sizeof(pmdepmissing_t)); MALLOC(miss, sizeof(pmdepmissing_t));
miss->type = PM_DEP_TYPE_CONFLICT; miss->type = PM_DEP_TYPE_CONFLICT;
miss->depend.mod = PM_DEP_MOD_ANY; miss->depend.mod = PM_DEP_MOD_ANY;
@ -242,6 +246,8 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
STRNCPY(miss->target, tp->name, PKG_NAME_LEN); STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
STRNCPY(miss->depend.name, dp->name, PKG_NAME_LEN); STRNCPY(miss->depend.name, dp->name, PKG_NAME_LEN);
if(!pm_list_is_in(miss, baddeps)) { 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); baddeps = pm_list_add(baddeps, miss);
} else { } else {
FREE(miss); FREE(miss);
@ -259,6 +265,8 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
STRNCPY(miss->target, tp->name, PKG_NAME_LEN); STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
STRNCPY(miss->depend.name, dp->name, PKG_NAME_LEN); STRNCPY(miss->depend.name, dp->name, PKG_NAME_LEN);
if(!pm_list_is_in(miss, baddeps)) { 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); baddeps = pm_list_add(baddeps, miss);
} else { } else {
FREE(miss); FREE(miss);
@ -269,25 +277,56 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
} }
/* CHECK 2: check targets against targets */ /* CHECK 2: check targets against targets */
for(k = packages; k; k = k->next) { for(k = packages; k; k = k->next) {
pmpkg_t *a = (pmpkg_t *)k->data; pmpkg_t *otp = (pmpkg_t *)k->data;
if(!strcmp(a->name, (char *)j->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)); MALLOC(miss, sizeof(pmdepmissing_t));
miss->type = PM_DEP_TYPE_CONFLICT; miss->type = PM_DEP_TYPE_CONFLICT;
miss->depend.mod = PM_DEP_MOD_ANY; miss->depend.mod = PM_DEP_MOD_ANY;
miss->depend.version[0] = '\0'; miss->depend.version[0] = '\0';
STRNCPY(miss->target, tp->name, PKG_NAME_LEN); STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
STRNCPY(miss->depend.name, a->name, PKG_NAME_LEN); STRNCPY(miss->depend.name, otp->name, PKG_NAME_LEN);
if(!pm_list_is_in(miss, baddeps)) { 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); baddeps = pm_list_add(baddeps, miss);
} else { } else {
FREE(miss); 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 */ /* CHECK 3: check database against targets */
for(k = db_get_pkgcache(db); k; k = k->next) { for(k = db_get_pkgcache(db); k; k = k->next) {
info = k->data; 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) { for(j = info->conflicts; j; j = j->next) {
if(!strcmp((char *)j->data, tp->name)) { if(!strcmp((char *)j->data, tp->name)) {
MALLOC(miss, sizeof(pmdepmissing_t)); MALLOC(miss, sizeof(pmdepmissing_t));
@ -297,6 +336,8 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
STRNCPY(miss->target, tp->name, PKG_NAME_LEN); STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
STRNCPY(miss->depend.name, info->name, PKG_NAME_LEN); STRNCPY(miss->depend.name, info->name, PKG_NAME_LEN);
if(!pm_list_is_in(miss, baddeps)) { 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); baddeps = pm_list_add(baddeps, miss);
} else { } else {
FREE(miss); FREE(miss);
@ -315,6 +356,8 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
STRNCPY(miss->target, tp->name, PKG_NAME_LEN); STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
STRNCPY(miss->depend.name, info->name, PKG_NAME_LEN); STRNCPY(miss->depend.name, info->name, PKG_NAME_LEN);
if(!pm_list_is_in(miss, baddeps)) { 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); baddeps = pm_list_add(baddeps, miss);
} else { } else {
FREE(miss); FREE(miss);
@ -435,11 +478,11 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
} else if(op == PM_TRANS_TYPE_REMOVE) { } else if(op == PM_TRANS_TYPE_REMOVE) {
/* check requiredby fields */ /* check requiredby fields */
for(i = packages; i; i = i->next) { for(i = packages; i; i = i->next) {
pmpkg_t *tp; pmpkg_t *tp = i->data;
if(i->data == NULL) { if(tp == NULL) {
continue; continue;
} }
tp = (pmpkg_t*)i->data;
for(j = tp->requiredby; j; j = j->next) { for(j = tp->requiredby; j; j = j->next) {
if(!pm_list_is_strin((char *)j->data, packages)) { if(!pm_list_is_strin((char *)j->data, packages)) {
MALLOC(miss, sizeof(pmdepmissing_t)); MALLOC(miss, sizeof(pmdepmissing_t));
@ -619,8 +662,6 @@ int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list,
pmpkg_t *sync = NULL; pmpkg_t *sync = NULL;
int provisio_match = 0; int provisio_match = 0;
_alpm_log(PM_LOG_DEBUG, "resolving dependency %s", miss->depend.name);
/* 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) {
pmpkg_t *sp = (pmpkg_t*)j->data; pmpkg_t *sp = (pmpkg_t*)j->data;