mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-23 00:08:50 -05:00
more code cleanup yet
This commit is contained in:
parent
c7bcaeb7e8
commit
cf94007aed
@ -145,21 +145,11 @@ int db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg)
|
|||||||
|
|
||||||
pmpkg_t *db_get_pkgfromcache(pmdb_t *db, char *target)
|
pmpkg_t *db_get_pkgfromcache(pmdb_t *db, char *target)
|
||||||
{
|
{
|
||||||
PMList *i;
|
if(db == NULL) {
|
||||||
|
|
||||||
if(db == NULL || target == NULL || strlen(target) == 0) {
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(i = db_get_pkgcache(db); i; i = i->next) {
|
return(pkg_isin(target, db_get_pkgcache(db)));
|
||||||
pmpkg_t *info = i->data;
|
|
||||||
|
|
||||||
if(strcmp(info->name, target) == 0) {
|
|
||||||
return(info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns a new group cache from db.
|
/* Returns a new group cache from db.
|
||||||
|
@ -69,15 +69,10 @@ PMList *checkconflicts(pmdb_t *db, PMList *packages)
|
|||||||
}
|
}
|
||||||
if(!strcmp(j->data, dp->name)) {
|
if(!strcmp(j->data, dp->name)) {
|
||||||
/* conflict */
|
/* conflict */
|
||||||
MALLOC(miss, sizeof(pmdepmissing_t));
|
_alpm_log(PM_LOG_DEBUG, "targs vs db: adding %s as a conflict for %s",
|
||||||
miss->type = PM_DEP_TYPE_CONFLICT;
|
dp->name, tp->name);
|
||||||
miss->depend.mod = PM_DEP_MOD_ANY;
|
miss = depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, dp->name, NULL);
|
||||||
miss->depend.version[0] = '\0';
|
if(!depmiss_isin(miss, baddeps)) {
|
||||||
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
|
||||||
STRNCPY(miss->depend.name, dp->name, PKG_NAME_LEN);
|
|
||||||
if(!dep_isin(miss, baddeps)) {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "checkconflict: 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);
|
||||||
@ -88,15 +83,10 @@ PMList *checkconflicts(pmdb_t *db, PMList *packages)
|
|||||||
for(m = dp->provides; m; m = m->next) {
|
for(m = dp->provides; m; m = m->next) {
|
||||||
if(!strcmp(m->data, j->data)) {
|
if(!strcmp(m->data, j->data)) {
|
||||||
/* confict */
|
/* confict */
|
||||||
MALLOC(miss, sizeof(pmdepmissing_t));
|
_alpm_log(PM_LOG_DEBUG, "targs vs db: found %s as a conflict for %s",
|
||||||
miss->type = PM_DEP_TYPE_CONFLICT;
|
dp->name, tp->name);
|
||||||
miss->depend.mod = PM_DEP_MOD_ANY;
|
miss = depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, dp->name, NULL);
|
||||||
miss->depend.version[0] = '\0';
|
if(!depmiss_isin(miss, baddeps)) {
|
||||||
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
|
||||||
STRNCPY(miss->depend.name, dp->name, PKG_NAME_LEN);
|
|
||||||
if(!dep_isin(miss, baddeps)) {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "checkconflict: 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);
|
||||||
@ -114,15 +104,10 @@ PMList *checkconflicts(pmdb_t *db, PMList *packages)
|
|||||||
}
|
}
|
||||||
if(!strcmp(otp->name, (char *)j->data)) {
|
if(!strcmp(otp->name, (char *)j->data)) {
|
||||||
/* otp is listed in tp's conflict list */
|
/* otp is listed in tp's conflict list */
|
||||||
MALLOC(miss, sizeof(pmdepmissing_t));
|
_alpm_log(PM_LOG_DEBUG, "targs vs targs: found %s as a conflict for %s",
|
||||||
miss->type = PM_DEP_TYPE_CONFLICT;
|
otp->name, tp->name);
|
||||||
miss->depend.mod = PM_DEP_MOD_ANY;
|
miss = depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, otp->name, NULL);
|
||||||
miss->depend.version[0] = '\0';
|
if(!depmiss_isin(miss, baddeps)) {
|
||||||
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
|
||||||
STRNCPY(miss->depend.name, otp->name, PKG_NAME_LEN);
|
|
||||||
if(!dep_isin(miss, baddeps)) {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "checkconflict: 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);
|
||||||
@ -132,15 +117,10 @@ PMList *checkconflicts(pmdb_t *db, PMList *packages)
|
|||||||
PMList *m;
|
PMList *m;
|
||||||
for(m = otp->provides; m; m = m->next) {
|
for(m = otp->provides; m; m = m->next) {
|
||||||
if(!strcmp(m->data, j->data)) {
|
if(!strcmp(m->data, j->data)) {
|
||||||
MALLOC(miss, sizeof(pmdepmissing_t));
|
_alpm_log(PM_LOG_DEBUG, "targs vs targs: found %s as a conflict for %s",
|
||||||
miss->type = PM_DEP_TYPE_CONFLICT;
|
otp->name, tp->name);
|
||||||
miss->depend.mod = PM_DEP_MOD_ANY;
|
miss = depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, otp->name, NULL);
|
||||||
miss->depend.version[0] = '\0';
|
if(!depmiss_isin(miss, baddeps)) {
|
||||||
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
|
||||||
STRNCPY(miss->depend.name, otp->name, PKG_NAME_LEN);
|
|
||||||
if(!dep_isin(miss, baddeps)) {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "checkconflict: 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);
|
||||||
@ -159,15 +139,10 @@ PMList *checkconflicts(pmdb_t *db, PMList *packages)
|
|||||||
}
|
}
|
||||||
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));
|
_alpm_log(PM_LOG_DEBUG, "db vs targs: found %s as a conflict for %s",
|
||||||
miss->type = PM_DEP_TYPE_CONFLICT;
|
info->name, tp->name);
|
||||||
miss->depend.mod = PM_DEP_MOD_ANY;
|
miss = depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, info->name, NULL);
|
||||||
miss->depend.version[0] = '\0';
|
if(!depmiss_isin(miss, baddeps)) {
|
||||||
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
|
||||||
STRNCPY(miss->depend.name, info->name, PKG_NAME_LEN);
|
|
||||||
if(!dep_isin(miss, baddeps)) {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "checkconflict: 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);
|
||||||
@ -179,15 +154,10 @@ PMList *checkconflicts(pmdb_t *db, PMList *packages)
|
|||||||
PMList *n;
|
PMList *n;
|
||||||
for(n = tp->provides; n; n = n->next) {
|
for(n = tp->provides; n; n = n->next) {
|
||||||
if(!strcmp(m->data, n->data)) {
|
if(!strcmp(m->data, n->data)) {
|
||||||
MALLOC(miss, sizeof(pmdepmissing_t));
|
_alpm_log(PM_LOG_DEBUG, "db vs targs: adding %s as a conflict for %s",
|
||||||
miss->type = PM_DEP_TYPE_CONFLICT;
|
info->name, tp->name);
|
||||||
miss->depend.mod = PM_DEP_MOD_ANY;
|
miss = depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, info->name, NULL);
|
||||||
miss->depend.version[0] = '\0';
|
if(!depmiss_isin(miss, baddeps)) {
|
||||||
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
|
||||||
STRNCPY(miss->depend.name, info->name, PKG_NAME_LEN);
|
|
||||||
if(!dep_isin(miss, baddeps)) {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "checkconflict: 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);
|
||||||
|
@ -37,23 +37,8 @@
|
|||||||
|
|
||||||
extern pmhandle_t *handle;
|
extern pmhandle_t *handle;
|
||||||
|
|
||||||
int dep_isin(pmdepmissing_t *needle, PMList *haystack)
|
pmdepmissing_t *depmiss_new(const char *target, unsigned char type, unsigned char depmod,
|
||||||
{
|
const char *depname, const char *depversion)
|
||||||
PMList *i;
|
|
||||||
|
|
||||||
for(i = haystack; i; i = i->next) {
|
|
||||||
pmdepmissing_t *miss = i->data;
|
|
||||||
if(!memcmp(needle, miss, sizeof(pmdepmissing_t))
|
|
||||||
&& !memcmp(&needle->depend, &miss->depend, sizeof(pmdepend_t))) {
|
|
||||||
return(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static pmdepmissing_t *depmissing_new(const char *target, unsigned char type, unsigned char depmod,
|
|
||||||
const char *depname, const char *depversion)
|
|
||||||
{
|
{
|
||||||
pmdepmissing_t *miss;
|
pmdepmissing_t *miss;
|
||||||
|
|
||||||
@ -66,11 +51,30 @@ static pmdepmissing_t *depmissing_new(const char *target, unsigned char type, un
|
|||||||
miss->type = type;
|
miss->type = type;
|
||||||
miss->depend.mod = depmod;
|
miss->depend.mod = depmod;
|
||||||
STRNCPY(miss->depend.name, depname, PKG_NAME_LEN);
|
STRNCPY(miss->depend.name, depname, PKG_NAME_LEN);
|
||||||
STRNCPY(miss->depend.version, depversion, PKG_VERSION_LEN);
|
if(depversion) {
|
||||||
|
STRNCPY(miss->depend.version, depversion, PKG_VERSION_LEN);
|
||||||
|
} else {
|
||||||
|
miss->depend.version[0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return(miss);
|
return(miss);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int depmiss_isin(pmdepmissing_t *needle, PMList *haystack)
|
||||||
|
{
|
||||||
|
PMList *i;
|
||||||
|
|
||||||
|
for(i = haystack; i; i = i->next) {
|
||||||
|
pmdepmissing_t *miss = i->data;
|
||||||
|
if(!memcmp(needle, miss, sizeof(pmdepmissing_t))
|
||||||
|
&& !memcmp(&needle->depend, &miss->depend, sizeof(pmdepend_t))) {
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
/* 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):
|
||||||
@ -126,7 +130,7 @@ PMList *sortbydeps(PMList *targets, int mode)
|
|||||||
for(k = i->next; k; k = k->next) {
|
for(k = i->next; k; k = k->next) {
|
||||||
q = (pmpkg_t *)k->data;
|
q = (pmpkg_t *)k->data;
|
||||||
if(!strcmp(dep.name, q->name)) {
|
if(!strcmp(dep.name, q->name)) {
|
||||||
if(!pkg_isin(q, tmptargs)) {
|
if(!pkg_isin(q->name, tmptargs)) {
|
||||||
change = 1;
|
change = 1;
|
||||||
tmptargs = pm_list_add(tmptargs, q);
|
tmptargs = pm_list_add(tmptargs, q);
|
||||||
}
|
}
|
||||||
@ -134,7 +138,7 @@ PMList *sortbydeps(PMList *targets, int mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!pkg_isin(p, tmptargs)) {
|
if(!pkg_isin(p->name, tmptargs)) {
|
||||||
tmptargs = pm_list_add(tmptargs, p);
|
tmptargs = pm_list_add(tmptargs, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,7 +197,7 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
|
|||||||
/* hmmm... package isn't installed.. */
|
/* hmmm... package isn't installed.. */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(pkg_isin(p, packages)) {
|
if(pkg_isin(p->name, packages)) {
|
||||||
/* this package is also in the upgrade list, so don't worry about it */
|
/* this package is also in the upgrade list, so don't worry about it */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -234,13 +238,9 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
|
|||||||
FREE(ver);
|
FREE(ver);
|
||||||
}
|
}
|
||||||
if(!found) {
|
if(!found) {
|
||||||
MALLOC(miss, sizeof(pmdepmissing_t));
|
_alpm_log(PM_LOG_DEBUG, "checkdeps: found %s as required by %s", depend.name, p->name);
|
||||||
miss->type = PM_DEP_TYPE_REQUIRED;
|
miss = depmiss_new(p->name, PM_DEP_TYPE_REQUIRED, depend.mod, depend.name, depend.version);
|
||||||
miss->depend.mod = depend.mod;
|
if(!depmiss_isin(miss, baddeps)) {
|
||||||
STRNCPY(miss->target, p->name, PKG_NAME_LEN);
|
|
||||||
STRNCPY(miss->depend.name, depend.name, PKG_NAME_LEN);
|
|
||||||
STRNCPY(miss->depend.version, depend.version, PKG_VERSION_LEN);
|
|
||||||
if(!dep_isin(miss, baddeps)) {
|
|
||||||
baddeps = pm_list_add(baddeps, miss);
|
baddeps = pm_list_add(baddeps, miss);
|
||||||
} else {
|
} else {
|
||||||
FREE(miss);
|
FREE(miss);
|
||||||
@ -348,13 +348,10 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
|
|||||||
}
|
}
|
||||||
/* else if still not found... */
|
/* else if still not found... */
|
||||||
if(!found) {
|
if(!found) {
|
||||||
MALLOC(miss, sizeof(pmdepmissing_t));
|
_alpm_log(PM_LOG_DEBUG, "checkdeps: found %s as a dependency for %s",
|
||||||
miss->type = PM_DEP_TYPE_DEPEND;
|
depend.name, tp->name);
|
||||||
miss->depend.mod = depend.mod;
|
miss = depmiss_new(tp->name, PM_DEP_TYPE_DEPEND, depend.mod, depend.name, depend.version);
|
||||||
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
if(!depmiss_isin(miss, baddeps)) {
|
||||||
STRNCPY(miss->depend.name, depend.name, PKG_NAME_LEN);
|
|
||||||
STRNCPY(miss->depend.version, depend.version, PKG_VERSION_LEN);
|
|
||||||
if(!dep_isin(miss, baddeps)) {
|
|
||||||
baddeps = pm_list_add(baddeps, miss);
|
baddeps = pm_list_add(baddeps, miss);
|
||||||
} else {
|
} else {
|
||||||
FREE(miss);
|
FREE(miss);
|
||||||
@ -372,13 +369,9 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
|
|||||||
|
|
||||||
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));
|
_alpm_log(PM_LOG_DEBUG, "checkdeps: found %s as required by %s", (char *)j->data, tp->name);
|
||||||
miss->type = PM_DEP_TYPE_REQUIRED;
|
miss = depmiss_new(tp->name, PM_DEP_TYPE_REQUIRED, PM_DEP_MOD_ANY, j->data, NULL);
|
||||||
miss->depend.mod = PM_DEP_MOD_ANY;
|
if(!depmiss_isin(miss, baddeps)) {
|
||||||
miss->depend.version[0] = '\0';
|
|
||||||
STRNCPY(miss->target, tp->name, PKG_NAME_LEN);
|
|
||||||
STRNCPY(miss->depend.name, (char *)j->data, PKG_NAME_LEN);
|
|
||||||
if(!dep_isin(miss, baddeps)) {
|
|
||||||
baddeps = pm_list_add(baddeps, miss);
|
baddeps = pm_list_add(baddeps, miss);
|
||||||
} else {
|
} else {
|
||||||
FREE(miss);
|
FREE(miss);
|
||||||
@ -469,11 +462,12 @@ PMList* removedeps(pmdb_t *db, PMList *targs)
|
|||||||
dep = db_get_pkgfromcache(db, ((pmpkg_t *)k->data)->name);
|
dep = db_get_pkgfromcache(db, ((pmpkg_t *)k->data)->name);
|
||||||
if(dep == NULL) {
|
if(dep == NULL) {
|
||||||
_alpm_log(PM_LOG_ERROR, "dep is NULL!");
|
_alpm_log(PM_LOG_ERROR, "dep is NULL!");
|
||||||
|
/* wtf */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
FREELISTPTR(k);
|
FREELISTPTR(k);
|
||||||
}
|
}
|
||||||
if(pkg_isin(dep, targs)) {
|
if(pkg_isin(dep->name, targs)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,7 +480,7 @@ PMList* removedeps(pmdb_t *db, PMList *targs)
|
|||||||
/* see if other packages need it */
|
/* see if other packages need it */
|
||||||
for(k = dep->requiredby; k && !needed; k = k->next) {
|
for(k = dep->requiredby; k && !needed; k = k->next) {
|
||||||
pmpkg_t *dummy = db_get_pkgfromcache(db, k->data);
|
pmpkg_t *dummy = db_get_pkgfromcache(db, k->data);
|
||||||
if(!pkg_isin(dummy, targs)) {
|
if(!pkg_isin(dummy->name, targs)) {
|
||||||
needed = 1;
|
needed = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -518,7 +512,7 @@ PMList* removedeps(pmdb_t *db, PMList *targs)
|
|||||||
*/
|
*/
|
||||||
int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list, PMList *trail, pmtrans_t *trans)
|
int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list, PMList *trail, pmtrans_t *trans)
|
||||||
{
|
{
|
||||||
PMList *i, *j, *k;
|
PMList *i, *j;
|
||||||
PMList *targ;
|
PMList *targ;
|
||||||
PMList *deps = NULL;
|
PMList *deps = NULL;
|
||||||
|
|
||||||
@ -538,7 +532,6 @@ int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list,
|
|||||||
int found = 0;
|
int found = 0;
|
||||||
pmdepmissing_t *miss = i->data;
|
pmdepmissing_t *miss = i->data;
|
||||||
pmpkg_t *sync = NULL;
|
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 */
|
||||||
|
|
||||||
@ -549,36 +542,27 @@ int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list,
|
|||||||
|
|
||||||
|
|
||||||
/* 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 && !found; j = j->next) {
|
||||||
pmpkg_t *sp = (pmpkg_t*)j->data;
|
pmpkg_t *sp = (pmpkg_t *)j->data;
|
||||||
for(k = sp->provides; k; k = k->next) {
|
if(pm_list_is_strin(miss->depend.name, sp->provides)) {
|
||||||
if(!strcmp(miss->depend.name, k->data)) {
|
_alpm_log(PM_LOG_DEBUG, "%s provides dependency %s -- skipping",
|
||||||
_alpm_log(PM_LOG_DEBUG, "%s provides dependency %s -- skipping", sp->name, miss->depend.name);
|
sp->name, miss->depend.name);
|
||||||
provisio_match = 1;
|
found = 1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(provisio_match) {
|
if(found) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* find the package in one of the repositories */
|
/* find the package in one of the repositories */
|
||||||
/* check literals */
|
/* check literals */
|
||||||
for(j = dbs_sync; !sync && j; j = j->next) {
|
for(j = dbs_sync; !sync && j; j = j->next) {
|
||||||
PMList *k;
|
sync = db_get_pkgfromcache(j->data, miss->depend.name);
|
||||||
pmdb_t *dbs = j->data;
|
|
||||||
for(k = db_get_pkgcache(dbs); !sync && k; k = k->next) {
|
|
||||||
pmpkg_t *pkg = k->data;
|
|
||||||
if(!strcmp(miss->depend.name, pkg->name)) {
|
|
||||||
sync = pkg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* check provides */
|
/* check provides */
|
||||||
for(j = dbs_sync; !sync && j; j = j->next) {
|
for(j = dbs_sync; !sync && j; j = j->next) {
|
||||||
PMList *provides;
|
PMList *provides;
|
||||||
pmdb_t *dbs = j->data;
|
provides = _alpm_db_whatprovides(j->data, miss->depend.name);
|
||||||
provides = _alpm_db_whatprovides(dbs, miss->depend.name);
|
|
||||||
if(provides) {
|
if(provides) {
|
||||||
sync = provides->data;
|
sync = provides->data;
|
||||||
}
|
}
|
||||||
@ -590,39 +574,19 @@ int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list,
|
|||||||
pm_errno = PM_ERR_UNRESOLVABLE_DEPS;
|
pm_errno = PM_ERR_UNRESOLVABLE_DEPS;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
found = 0;
|
if(pkg_isin(sync->name, list)) {
|
||||||
for(j = list; j && !found; j = j->next) {
|
|
||||||
pmpkg_t *tmp = j->data;
|
|
||||||
if(tmp && !strcmp(tmp->name, sync->name)) {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "dependency %s is already in the target list - skipping",
|
|
||||||
sync->name);
|
|
||||||
found = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(found) {
|
|
||||||
/* this dep is already in the target list */
|
/* this dep is already in the target list */
|
||||||
|
_alpm_log(PM_LOG_DEBUG, "dependency %s is already in the target list -- skipping",
|
||||||
|
sync->name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
found = 0;
|
if(!pkg_isin(sync->name, trail)) {
|
||||||
for(j = trail; j; j = j->next) {
|
|
||||||
pmpkg_t *tmp = j->data;
|
|
||||||
if(tmp && !strcmp(tmp->name, sync->name)) {
|
|
||||||
found = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!found) {
|
|
||||||
/* check pmo_ignorepkg and pmo_s_ignore to make sure we haven't pulled in
|
/* check pmo_ignorepkg and pmo_s_ignore to make sure we haven't pulled in
|
||||||
* something we're not supposed to.
|
* something we're not supposed to.
|
||||||
*/
|
*/
|
||||||
int usedep = 1;
|
int usedep = 1;
|
||||||
found = 0;
|
if(pm_list_is_strin(sync->name, handle->ignorepkg)) {
|
||||||
for(j = handle->ignorepkg; j && !found; j = j->next) {
|
|
||||||
if(!strcmp(j->data, sync->name)) {
|
|
||||||
found = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(found) {
|
|
||||||
pmpkg_t *dummypkg = pkg_new(miss->target, NULL);
|
pmpkg_t *dummypkg = pkg_new(miss->target, NULL);
|
||||||
QUESTION(trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, dummypkg, sync, NULL, &usedep);
|
QUESTION(trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, dummypkg, sync, NULL, &usedep);
|
||||||
FREEPKG(dummypkg);
|
FREEPKG(dummypkg);
|
||||||
|
@ -36,7 +36,9 @@ typedef struct __pmdepmissing_t {
|
|||||||
pmdepend_t depend;
|
pmdepend_t depend;
|
||||||
} pmdepmissing_t;
|
} pmdepmissing_t;
|
||||||
|
|
||||||
int dep_isin(pmdepmissing_t *needle, PMList *haystack);
|
pmdepmissing_t *depmiss_new(const char *target, unsigned char type, unsigned char depmod,
|
||||||
|
const char *depname, const char *depversion);
|
||||||
|
int depmiss_isin(pmdepmissing_t *needle, PMList *haystack);
|
||||||
PMList *sortbydeps(PMList *targets, int mode);
|
PMList *sortbydeps(PMList *targets, int mode);
|
||||||
PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages);
|
PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages);
|
||||||
int splitdep(char *depstr, pmdepend_t *depend);
|
int splitdep(char *depstr, pmdepend_t *depend);
|
||||||
|
@ -373,30 +373,23 @@ error:
|
|||||||
|
|
||||||
/* Test for existence of a package in a PMList*
|
/* Test for existence of a package in a PMList*
|
||||||
* of pmpkg_t*
|
* of pmpkg_t*
|
||||||
*
|
|
||||||
* returns: 0 for no match
|
|
||||||
* 1 for identical match
|
|
||||||
* -1 for name-only match (version mismatch)
|
|
||||||
*/
|
*/
|
||||||
int pkg_isin(pmpkg_t *needle, PMList *haystack)
|
pmpkg_t *pkg_isin(char *needle, PMList *haystack)
|
||||||
{
|
{
|
||||||
PMList *lp;
|
PMList *lp;
|
||||||
|
|
||||||
if(needle == NULL || haystack == NULL) {
|
if(needle == NULL || haystack == NULL) {
|
||||||
return(0);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(lp = haystack; lp; lp = lp->next) {
|
for(lp = haystack; lp; lp = lp->next) {
|
||||||
pmpkg_t *info = lp->data;
|
pmpkg_t *info = lp->data;
|
||||||
|
|
||||||
if(info && !strcmp(info->name, needle->name)) {
|
if(info && !strcmp(info->name, needle)) {
|
||||||
if(!strcmp(info->version, needle->version)) {
|
return(lp->data);
|
||||||
return(1);
|
|
||||||
}
|
|
||||||
return(-1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(0);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int pkg_splitname(char *target, char *name, char *version)
|
int pkg_splitname(char *target, char *name, char *version)
|
||||||
|
@ -90,7 +90,7 @@ pmpkg_t* pkg_new(const char *name, const char *version);
|
|||||||
pmpkg_t *pkg_dup(pmpkg_t *pkg);
|
pmpkg_t *pkg_dup(pmpkg_t *pkg);
|
||||||
void pkg_free(pmpkg_t *pkg);
|
void pkg_free(pmpkg_t *pkg);
|
||||||
pmpkg_t *pkg_load(char *pkgfile);
|
pmpkg_t *pkg_load(char *pkgfile);
|
||||||
int pkg_isin(pmpkg_t *needle, PMList *haystack);
|
pmpkg_t *pkg_isin(char *needle, PMList *haystack);
|
||||||
int pkg_splitname(char *target, char *name, char *version);
|
int pkg_splitname(char *target, char *name, char *version);
|
||||||
|
|
||||||
#endif /* _ALPM_PACKAGE_H */
|
#endif /* _ALPM_PACKAGE_H */
|
||||||
|
@ -56,16 +56,15 @@ int remove_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
|
|||||||
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
||||||
ASSERT(name != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
|
ASSERT(name != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
|
||||||
|
|
||||||
|
if(pkg_isin(name, trans->packages)) {
|
||||||
|
RET_ERR(PM_ERR_TRANS_DUP_TARGET, -1);
|
||||||
|
}
|
||||||
|
|
||||||
if((info = db_scan(db, name, INFRQ_ALL)) == NULL) {
|
if((info = db_scan(db, name, INFRQ_ALL)) == NULL) {
|
||||||
_alpm_log(PM_LOG_ERROR, "could not find %s in database", name);
|
_alpm_log(PM_LOG_ERROR, "could not find %s in database", name);
|
||||||
RET_ERR(PM_ERR_PKG_NOT_FOUND, -1);
|
RET_ERR(PM_ERR_PKG_NOT_FOUND, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pkg_isin(info, trans->packages)) {
|
|
||||||
FREEPKG(info);
|
|
||||||
RET_ERR(PM_ERR_TRANS_DUP_TARGET, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
_alpm_log(PM_LOG_FLOW2, "adding %s in the targets list", info->name);
|
_alpm_log(PM_LOG_FLOW2, "adding %s in the targets list", info->name);
|
||||||
trans->packages = pm_list_add(trans->packages, info);
|
trans->packages = pm_list_add(trans->packages, info);
|
||||||
|
|
||||||
@ -264,6 +263,13 @@ int remove_commit(pmtrans_t *trans, pmdb_t *db)
|
|||||||
if(splitdep((char*)lp->data, &depend)) {
|
if(splitdep((char*)lp->data, &depend)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
/* if this dependency is in the transaction targets, no need to update
|
||||||
|
* its requiredby info: it is in the process of being removed (if not
|
||||||
|
* already done!)
|
||||||
|
*/
|
||||||
|
if(pkg_isin(depend.name, trans->packages)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
depinfo = db_get_pkgfromcache(db, depend.name);
|
depinfo = db_get_pkgfromcache(db, depend.name);
|
||||||
if(depinfo == NULL) {
|
if(depinfo == NULL) {
|
||||||
/* look for a provides package */
|
/* look for a provides package */
|
||||||
|
@ -118,8 +118,9 @@ PMList *sync_load_dbarchive(char *archive)
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* readdir tmp_dir */
|
/* ORE - readdir tmp_dir */
|
||||||
/* for each subdir, parse %s/desc and %s/depends */
|
/* for each subdir, parse %s/desc and %s/depends */
|
||||||
|
/* then db_write it */
|
||||||
|
|
||||||
tar_close(tar);
|
tar_close(tar);
|
||||||
|
|
||||||
@ -217,16 +218,14 @@ int sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync)
|
|||||||
for(j = trans->packages; j && !replace; j = j->next) {
|
for(j = trans->packages; j && !replace; j = j->next) {
|
||||||
sync = j->data;
|
sync = j->data;
|
||||||
if(sync->type == PM_SYNC_TYPE_REPLACE) {
|
if(sync->type == PM_SYNC_TYPE_REPLACE) {
|
||||||
for(k = sync->data; k && !replace; k = k->next) {
|
if(pkg_isin(spkg->name, sync->data)) {
|
||||||
if(!strcmp(((pmpkg_t *)k->data)->name, spkg->name)) {
|
replace = 1;
|
||||||
replace = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(replace) {
|
if(replace) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "%s is already elected for removal -- skipping",
|
_alpm_log(PM_LOG_DEBUG, "%s is already elected for removal -- skipping",
|
||||||
local->name);
|
spkg->name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -377,7 +376,6 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
|
|||||||
_alpm_log(PM_LOG_FLOW1, "resolving targets dependencies");
|
_alpm_log(PM_LOG_FLOW1, "resolving targets dependencies");
|
||||||
for(i = trans->packages; i; i = i->next) {
|
for(i = trans->packages; i; i = i->next) {
|
||||||
pmpkg_t *spkg = ((pmsyncpkg_t *)i->data)->pkg;
|
pmpkg_t *spkg = ((pmsyncpkg_t *)i->data)->pkg;
|
||||||
_alpm_log(PM_LOG_DEBUG, "resolving dependencies for %s", spkg->name);
|
|
||||||
if(resolvedeps(db_local, dbs_sync, spkg, list, trail, trans) == -1) {
|
if(resolvedeps(db_local, dbs_sync, spkg, list, trail, trans) == -1) {
|
||||||
/* pm_errno is set by resolvedeps */
|
/* pm_errno is set by resolvedeps */
|
||||||
goto error;
|
goto error;
|
||||||
@ -430,18 +428,14 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
|
|||||||
for(j = trans->packages; j && !found; j = j->next) {
|
for(j = trans->packages; j && !found; j = j->next) {
|
||||||
sync = j->data;
|
sync = j->data;
|
||||||
if(sync->type == PM_SYNC_TYPE_REPLACE) {
|
if(sync->type == PM_SYNC_TYPE_REPLACE) {
|
||||||
PMList *k;
|
if(pkg_isin(miss->depend.name, sync->data)) {
|
||||||
for(k = sync->data; k && !found; k = k->next) {
|
found = 1;
|
||||||
pmpkg_t *p = k->data;
|
|
||||||
if(!strcmp(p->name, miss->depend.name)) {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "%s is already elected for removal -- skipping",
|
|
||||||
miss->depend.name);
|
|
||||||
found = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(found) {
|
if(found) {
|
||||||
|
_alpm_log(PM_LOG_DEBUG, "%s is already elected for removal -- skipping",
|
||||||
|
miss->depend.name);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -450,12 +444,7 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
|
|||||||
|
|
||||||
/* check if this package also "provides" the package it's conflicting with
|
/* check if this package also "provides" the package it's conflicting with
|
||||||
*/
|
*/
|
||||||
for(j = sync->pkg->provides; j && j->data && !found; j = j->next) {
|
if(pm_list_is_strin(miss->depend.name, sync->pkg->provides)) {
|
||||||
if(!strcmp(j->data, miss->depend.name)) {
|
|
||||||
found = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(found) {
|
|
||||||
/* so just treat it like a "replaces" item so the REQUIREDBY
|
/* so just treat it like a "replaces" item so the REQUIREDBY
|
||||||
* fields are inherited properly.
|
* fields are inherited properly.
|
||||||
*/
|
*/
|
||||||
@ -492,7 +481,7 @@ int sync_prepare(pmtrans_t *trans, pmdb_t *db_local, PMList *dbs_sync, PMList **
|
|||||||
pmsyncpkg_t *rsync = find_pkginsync(rmpkg, trans->packages);
|
pmsyncpkg_t *rsync = find_pkginsync(rmpkg, trans->packages);
|
||||||
pmsyncpkg_t *spkg;
|
pmsyncpkg_t *spkg;
|
||||||
_alpm_log(PM_LOG_DEBUG, "removing %s from target list", rmpkg);
|
_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, rsync, ptr_cmp, (void **)&spkg);
|
||||||
FREESYNC(spkg);
|
FREESYNC(spkg);
|
||||||
FREE(rmpkg);
|
FREE(rmpkg);
|
||||||
continue;
|
continue;
|
||||||
@ -653,7 +642,7 @@ int sync_commit(pmtrans_t *trans, pmdb_t *db_local, PMList **data)
|
|||||||
PMList *j;
|
PMList *j;
|
||||||
for(j = sync->data; j; j = j->next) {
|
for(j = sync->data; j; j = j->next) {
|
||||||
pmpkg_t *pkg = j->data;
|
pmpkg_t *pkg = j->data;
|
||||||
if(!pkg_isin(pkg, tr->packages)) {
|
if(!pkg_isin(pkg->name, tr->packages)) {
|
||||||
if(trans_addtarget(tr, pkg->name) == -1) {
|
if(trans_addtarget(tr, pkg->name) == -1) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user