even more code cleanup
This commit is contained in:
parent
719ff509c4
commit
510d57b577
1 changed files with 95 additions and 98 deletions
|
@ -79,7 +79,7 @@ void sync_free(pmsyncpkg_t *sync)
|
||||||
/* Test for existence of a package in a PMList* of pmsyncpkg_t*
|
/* Test for existence of a package in a PMList* of pmsyncpkg_t*
|
||||||
* If found, return a pointer to the respective pmsyncpkg_t*
|
* If found, return a pointer to the respective pmsyncpkg_t*
|
||||||
*/
|
*/
|
||||||
static pmsyncpkg_t* find_pkginsync(char *needle, PMList *haystack)
|
static pmsyncpkg_t *find_pkginsync(char *needle, PMList *haystack)
|
||||||
{
|
{
|
||||||
PMList *i;
|
PMList *i;
|
||||||
pmsyncpkg_t *sync = NULL;
|
pmsyncpkg_t *sync = NULL;
|
||||||
|
@ -182,7 +182,7 @@ int sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync)
|
||||||
pm_errno = PM_ERR_MEMORY;
|
pm_errno = PM_ERR_MEMORY;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
sync->data = pm_list_add(sync->data, dummy);
|
sync->data = pm_list_add(NULL, dummy);
|
||||||
trans->packages = pm_list_add(trans->packages, sync);
|
trans->packages = pm_list_add(trans->packages, sync);
|
||||||
}
|
}
|
||||||
_alpm_log(PM_LOG_FLOW2, "%s-%s elected for upgrade (to be replaced by %s-%s)",
|
_alpm_log(PM_LOG_FLOW2, "%s-%s elected for upgrade (to be replaced by %s-%s)",
|
||||||
|
@ -209,7 +209,7 @@ int sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync)
|
||||||
spkg = db_get_pkgfromcache(j->data, local->name);
|
spkg = db_get_pkgfromcache(j->data, local->name);
|
||||||
}
|
}
|
||||||
if(spkg == NULL) {
|
if(spkg == NULL) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "%s: not found in sync db -- skipping.", local->name);
|
_alpm_log(PM_LOG_DEBUG, "%s: not found in sync db -- skipping", local->name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -417,8 +417,9 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
|
||||||
|
|
||||||
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;
|
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
pmsyncpkg_t *sync;
|
||||||
|
pmpkg_t *local;
|
||||||
|
|
||||||
_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);
|
||||||
|
@ -427,8 +428,9 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
|
||||||
* if so, then just ignore it
|
* if so, then just ignore it
|
||||||
*/
|
*/
|
||||||
for(j = trans->packages; j && !found; j = j->next) {
|
for(j = trans->packages; j && !found; j = j->next) {
|
||||||
pmsyncpkg_t *sync = j->data;
|
sync = j->data;
|
||||||
if(sync->type == PM_SYNC_TYPE_REPLACE) {
|
if(sync->type == PM_SYNC_TYPE_REPLACE) {
|
||||||
|
PMList *k;
|
||||||
for(k = sync->data; k && !found; k = k->next) {
|
for(k = sync->data; k && !found; k = k->next) {
|
||||||
pmpkg_t *p = k->data;
|
pmpkg_t *p = k->data;
|
||||||
if(!strcmp(p->name, miss->depend.name)) {
|
if(!strcmp(p->name, miss->depend.name)) {
|
||||||
|
@ -439,18 +441,28 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(found) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* if we didn't find it in any sync->replaces lists, then it's a conflict */
|
sync = find_pkginsync(miss->target, trans->packages);
|
||||||
if(!found) {
|
local = db_get_pkgfromcache(db_local, miss->depend.name);
|
||||||
int solved = 0;
|
|
||||||
pmsyncpkg_t *sync = find_pkginsync(miss->target, trans->packages);
|
/* check if this package also "provides" the package it's conflicting with
|
||||||
for(j = sync->pkg->provides; j && j->data && !solved; j = j->next) {
|
*/
|
||||||
|
for(j = sync->pkg->provides; j && j->data && !found; j = j->next) {
|
||||||
if(!strcmp(j->data, miss->depend.name)) {
|
if(!strcmp(j->data, miss->depend.name)) {
|
||||||
/* this package also "provides" the package it's conflicting with,
|
found = 1;
|
||||||
* so just treat it like a "replaces" item so the REQUIREDBY
|
}
|
||||||
|
}
|
||||||
|
if(found) {
|
||||||
|
/* so just treat it like a "replaces" item so the REQUIREDBY
|
||||||
* fields are inherited properly.
|
* fields are inherited properly.
|
||||||
*/
|
*/
|
||||||
if(db_get_pkgfromcache(db_local, miss->depend.name) == NULL) {
|
if(local) {
|
||||||
|
/* nothing to do for now: it will be handled later
|
||||||
|
* (not the same behavior as in pacman 2.x) */
|
||||||
|
} else {
|
||||||
char *rmpkg = NULL;
|
char *rmpkg = NULL;
|
||||||
/* hmmm, depend.name isn't installed, so it must be conflicting
|
/* hmmm, depend.name isn't installed, so it must be conflicting
|
||||||
* with another package in our final list. For example:
|
* with another package in our final list. For example:
|
||||||
|
@ -477,48 +489,36 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
|
||||||
/* something's not right, bail out with a conflict error */
|
/* something's not right, bail out with a conflict error */
|
||||||
}
|
}
|
||||||
if(rmpkg) {
|
if(rmpkg) {
|
||||||
for(k = trans->packages; k; k = k->next) {
|
pmsyncpkg_t *rsync = find_pkginsync(rmpkg, trans->packages);
|
||||||
pmsyncpkg_t *sync = k->data;
|
|
||||||
if(!strcmp(sync->pkg->name, rmpkg)) {
|
|
||||||
pmsyncpkg_t *spkg;
|
pmsyncpkg_t *spkg;
|
||||||
|
_alpm_log(PM_LOG_DEBUG, "removing %s from target list", rmpkg);
|
||||||
trans->packages = _alpm_list_remove(trans->packages, sync, ptr_cmp, (void **)&spkg);
|
trans->packages = _alpm_list_remove(trans->packages, sync, ptr_cmp, (void **)&spkg);
|
||||||
FREESYNC(spkg);
|
FREESYNC(spkg);
|
||||||
_alpm_log(PM_LOG_DEBUG, "removing %s from target list", rmpkg);
|
|
||||||
/* ORE - shouldn't "solved" be set to 1 here */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
solved = 1;
|
|
||||||
FREE(rmpkg);
|
FREE(rmpkg);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(!solved) {
|
|
||||||
/* It's a conflict -- see if they want to remove it
|
/* It's a conflict -- see if they want to remove it
|
||||||
*/
|
*/
|
||||||
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "resolving package %s conflict", miss->target);
|
_alpm_log(PM_LOG_DEBUG, "resolving package %s conflict", miss->target);
|
||||||
|
if(local) {
|
||||||
if(db_get_pkgfromcache(db_local, miss->depend.name)) {
|
|
||||||
int doremove = 0;
|
int doremove = 0;
|
||||||
if(!pm_list_is_strin(miss->depend.name, asked)) {
|
if(!pm_list_is_strin(miss->depend.name, asked)) {
|
||||||
QUESTION(trans, PM_TRANS_CONV_CONFLICT_PKG, miss->target, miss->depend.name, NULL, &doremove);
|
QUESTION(trans, PM_TRANS_CONV_CONFLICT_PKG, miss->target, miss->depend.name, NULL, &doremove);
|
||||||
asked = pm_list_add(asked, strdup(miss->depend.name));
|
asked = pm_list_add(asked, strdup(miss->depend.name));
|
||||||
if(doremove) {
|
if(doremove) {
|
||||||
/* remove miss->depend.name */
|
/* remove miss->depend.name */
|
||||||
for(k = trans->packages; k; k = k->next) {
|
|
||||||
pmsyncpkg_t *s = k->data;
|
|
||||||
if(!strcmp(s->pkg->name, miss->target)) {
|
|
||||||
pmpkg_t *q = pkg_new(miss->depend.name, NULL);
|
pmpkg_t *q = pkg_new(miss->depend.name, NULL);
|
||||||
if(s->type != PM_SYNC_TYPE_REPLACE) {
|
q->requiredby = _alpm_list_strdup(local->requiredby);
|
||||||
|
if(sync->type != PM_SYNC_TYPE_REPLACE) {
|
||||||
/* switch this sync type to REPLACE */
|
/* switch this sync type to REPLACE */
|
||||||
s->type = PM_SYNC_TYPE_REPLACE;
|
sync->type = PM_SYNC_TYPE_REPLACE;
|
||||||
FREEPKG(s->data);
|
FREEPKG(sync->data);
|
||||||
}
|
}
|
||||||
/* append to the replaces list */
|
/* append to the replaces list */
|
||||||
s->data = pm_list_add(s->data, q);
|
sync->data = pm_list_add(sync->data, q);
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
/* abort */
|
/* abort */
|
||||||
_alpm_log(PM_LOG_ERROR, "unresolvable package conflicts detected");
|
_alpm_log(PM_LOG_ERROR, "unresolvable package conflicts detected");
|
||||||
|
@ -548,8 +548,6 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
if(errorout) {
|
if(errorout) {
|
||||||
pm_errno = PM_ERR_CONFLICTING_DEPS;
|
pm_errno = PM_ERR_CONFLICTING_DEPS;
|
||||||
goto error;
|
goto error;
|
||||||
|
@ -591,8 +589,7 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
|
||||||
int errorout = 0;
|
int errorout = 0;
|
||||||
for(i = deps; i; i = i->next) {
|
for(i = deps; i; i = i->next) {
|
||||||
pmdepmissing_t *miss = i->data;
|
pmdepmissing_t *miss = i->data;
|
||||||
pmsyncpkg_t *spkg = find_pkginsync(miss->depend.name, trans->packages);
|
if(!find_pkginsync(miss->depend.name, trans->packages)) {
|
||||||
if(spkg == NULL) {
|
|
||||||
if(!errorout) {
|
if(!errorout) {
|
||||||
errorout = 1;
|
errorout = 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue