summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/cache.c14
-rw-r--r--lib/libalpm/conflict.c78
-rw-r--r--lib/libalpm/deps.c142
-rw-r--r--lib/libalpm/deps.h4
-rw-r--r--lib/libalpm/package.c17
-rw-r--r--lib/libalpm/package.h2
-rw-r--r--lib/libalpm/remove.c16
-rw-r--r--lib/libalpm/sync.c35
8 files changed, 111 insertions, 197 deletions
diff --git a/lib/libalpm/cache.c b/lib/libalpm/cache.c
index 8c8e7669..709ba383 100644
--- a/lib/libalpm/cache.c
+++ b/lib/libalpm/cache.c
@@ -145,21 +145,11 @@ int db_remove_pkgfromcache(pmdb_t *db, pmpkg_t *pkg)
pmpkg_t *db_get_pkgfromcache(pmdb_t *db, char *target)
{
- PMList *i;
-
- if(db == NULL || target == NULL || strlen(target) == 0) {
+ if(db == NULL) {
return(NULL);
}
- for(i = db_get_pkgcache(db); i; i = i->next) {
- pmpkg_t *info = i->data;
-
- if(strcmp(info->name, target) == 0) {
- return(info);
- }
- }
-
- return(NULL);
+ return(pkg_isin(target, db_get_pkgcache(db)));
}
/* Returns a new group cache from db.
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index 749cad24..94e65326 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -69,15 +69,10 @@ PMList *checkconflicts(pmdb_t *db, PMList *packages)
}
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(!dep_isin(miss, baddeps)) {
- _alpm_log(PM_LOG_DEBUG, "checkconflict: targs vs db: adding %s as a conflict for %s",
- dp->name, tp->name);
+ _alpm_log(PM_LOG_DEBUG, "targs vs db: adding %s as a conflict for %s",
+ dp->name, tp->name);
+ miss = depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, dp->name, NULL);
+ if(!depmiss_isin(miss, baddeps)) {
baddeps = pm_list_add(baddeps, miss);
} else {
FREE(miss);
@@ -88,15 +83,10 @@ PMList *checkconflicts(pmdb_t *db, PMList *packages)
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(!dep_isin(miss, baddeps)) {
- _alpm_log(PM_LOG_DEBUG, "checkconflict: targs vs db: adding %s as a conflict for %s",
- dp->name, tp->name);
+ _alpm_log(PM_LOG_DEBUG, "targs vs db: found %s as a conflict for %s",
+ dp->name, tp->name);
+ miss = depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, dp->name, NULL);
+ if(!depmiss_isin(miss, baddeps)) {
baddeps = pm_list_add(baddeps, miss);
} else {
FREE(miss);
@@ -114,15 +104,10 @@ PMList *checkconflicts(pmdb_t *db, PMList *packages)
}
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(!dep_isin(miss, baddeps)) {
- _alpm_log(PM_LOG_DEBUG, "checkconflict: targs vs targs: adding %s as a conflict for %s",
- otp->name, tp->name);
+ _alpm_log(PM_LOG_DEBUG, "targs vs targs: found %s as a conflict for %s",
+ otp->name, tp->name);
+ miss = depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, otp->name, NULL);
+ if(!depmiss_isin(miss, baddeps)) {
baddeps = pm_list_add(baddeps, miss);
} else {
FREE(miss);
@@ -132,15 +117,10 @@ PMList *checkconflicts(pmdb_t *db, PMList *packages)
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(!dep_isin(miss, baddeps)) {
- _alpm_log(PM_LOG_DEBUG, "checkconflict: targs vs targs: adding %s as a conflict for %s",
- otp->name, tp->name);
+ _alpm_log(PM_LOG_DEBUG, "targs vs targs: found %s as a conflict for %s",
+ otp->name, tp->name);
+ miss = depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, otp->name, NULL);
+ if(!depmiss_isin(miss, baddeps)) {
baddeps = pm_list_add(baddeps, miss);
} else {
FREE(miss);
@@ -159,15 +139,10 @@ PMList *checkconflicts(pmdb_t *db, PMList *packages)
}
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(!dep_isin(miss, baddeps)) {
- _alpm_log(PM_LOG_DEBUG, "checkconflict: db vs targs: adding %s as a conflict for %s",
- info->name, tp->name);
+ _alpm_log(PM_LOG_DEBUG, "db vs targs: found %s as a conflict for %s",
+ info->name, tp->name);
+ miss = depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, info->name, NULL);
+ if(!depmiss_isin(miss, baddeps)) {
baddeps = pm_list_add(baddeps, miss);
} else {
FREE(miss);
@@ -179,15 +154,10 @@ PMList *checkconflicts(pmdb_t *db, PMList *packages)
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(!dep_isin(miss, baddeps)) {
- _alpm_log(PM_LOG_DEBUG, "checkconflict: db vs targs: adding %s as a conflict for %s",
- info->name, tp->name);
+ _alpm_log(PM_LOG_DEBUG, "db vs targs: adding %s as a conflict for %s",
+ info->name, tp->name);
+ miss = depmiss_new(tp->name, PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, info->name, NULL);
+ if(!depmiss_isin(miss, baddeps)) {
baddeps = pm_list_add(baddeps, miss);
} else {
FREE(miss);
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index e7520560..41e1b46d 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -37,23 +37,8 @@
extern pmhandle_t *handle;
-int dep_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);
-}
-
-static pmdepmissing_t *depmissing_new(const char *target, unsigned char type, unsigned char depmod,
- const char *depname, const char *depversion)
+pmdepmissing_t *depmiss_new(const char *target, unsigned char type, unsigned char depmod,
+ const char *depname, const char *depversion)
{
pmdepmissing_t *miss;
@@ -66,11 +51,30 @@ static pmdepmissing_t *depmissing_new(const char *target, unsigned char type, un
miss->type = type;
miss->depend.mod = depmod;
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);
}
+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.
*
* Example (PM_TRANS_TYPE_ADD):
@@ -126,7 +130,7 @@ PMList *sortbydeps(PMList *targets, int mode)
for(k = i->next; k; k = k->next) {
q = (pmpkg_t *)k->data;
if(!strcmp(dep.name, q->name)) {
- if(!pkg_isin(q, tmptargs)) {
+ if(!pkg_isin(q->name, tmptargs)) {
change = 1;
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);
}
}
@@ -193,7 +197,7 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
/* hmmm... package isn't installed.. */
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 */
continue;
}
@@ -234,13 +238,9 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
FREE(ver);
}
if(!found) {
- MALLOC(miss, sizeof(pmdepmissing_t));
- miss->type = PM_DEP_TYPE_REQUIRED;
- miss->depend.mod = depend.mod;
- 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)) {
+ _alpm_log(PM_LOG_DEBUG, "checkdeps: found %s as required by %s", depend.name, p->name);
+ miss = depmiss_new(p->name, PM_DEP_TYPE_REQUIRED, depend.mod, depend.name, depend.version);
+ if(!depmiss_isin(miss, baddeps)) {
baddeps = pm_list_add(baddeps, miss);
} else {
FREE(miss);
@@ -348,13 +348,10 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
}
/* else if still not found... */
if(!found) {
- MALLOC(miss, sizeof(pmdepmissing_t));
- miss->type = PM_DEP_TYPE_DEPEND;
- miss->depend.mod = depend.mod;
- STRNCPY(miss->target, tp->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)) {
+ _alpm_log(PM_LOG_DEBUG, "checkdeps: found %s as a dependency for %s",
+ depend.name, tp->name);
+ miss = depmiss_new(tp->name, PM_DEP_TYPE_DEPEND, depend.mod, depend.name, depend.version);
+ if(!depmiss_isin(miss, baddeps)) {
baddeps = pm_list_add(baddeps, miss);
} else {
FREE(miss);
@@ -372,13 +369,9 @@ PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
for(j = tp->requiredby; j; j = j->next) {
if(!pm_list_is_strin((char *)j->data, packages)) {
- MALLOC(miss, sizeof(pmdepmissing_t));
- miss->type = PM_DEP_TYPE_REQUIRED;
- miss->depend.mod = PM_DEP_MOD_ANY;
- 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)) {
+ _alpm_log(PM_LOG_DEBUG, "checkdeps: found %s as required by %s", (char *)j->data, tp->name);
+ miss = depmiss_new(tp->name, PM_DEP_TYPE_REQUIRED, PM_DEP_MOD_ANY, j->data, NULL);
+ if(!depmiss_isin(miss, baddeps)) {
baddeps = pm_list_add(baddeps, miss);
} else {
FREE(miss);
@@ -469,11 +462,12 @@ PMList* removedeps(pmdb_t *db, PMList *targs)
dep = db_get_pkgfromcache(db, ((pmpkg_t *)k->data)->name);
if(dep == NULL) {
_alpm_log(PM_LOG_ERROR, "dep is NULL!");
+ /* wtf */
continue;
}
FREELISTPTR(k);
}
- if(pkg_isin(dep, targs)) {
+ if(pkg_isin(dep->name, targs)) {
continue;
}
@@ -486,7 +480,7 @@ PMList* removedeps(pmdb_t *db, PMList *targs)
/* see if other packages need it */
for(k = dep->requiredby; k && !needed; k = k->next) {
pmpkg_t *dummy = db_get_pkgfromcache(db, k->data);
- if(!pkg_isin(dummy, targs)) {
+ if(!pkg_isin(dummy->name, targs)) {
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)
{
- PMList *i, *j, *k;
+ PMList *i, *j;
PMList *targ;
PMList *deps = NULL;
@@ -538,7 +532,6 @@ int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list,
int found = 0;
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 */
@@ -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 */
- for(j = list; j; j = j->next) {
- pmpkg_t *sp = (pmpkg_t*)j->data;
- for(k = sp->provides; k; k = k->next) {
- if(!strcmp(miss->depend.name, k->data)) {
- _alpm_log(PM_LOG_DEBUG, "%s provides dependency %s -- skipping", sp->name, miss->depend.name);
- provisio_match = 1;
- }
+ for(j = list; j && !found; j = j->next) {
+ pmpkg_t *sp = (pmpkg_t *)j->data;
+ if(pm_list_is_strin(miss->depend.name, sp->provides)) {
+ _alpm_log(PM_LOG_DEBUG, "%s provides dependency %s -- skipping",
+ sp->name, miss->depend.name);
+ found = 1;
}
}
- if(provisio_match) {
+ if(found) {
continue;
}
/* find the package in one of the repositories */
/* check literals */
for(j = dbs_sync; !sync && j; j = j->next) {
- PMList *k;
- 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;
- }
- }
+ sync = db_get_pkgfromcache(j->data, miss->depend.name);
}
/* check provides */
for(j = dbs_sync; !sync && j; j = j->next) {
PMList *provides;
- pmdb_t *dbs = j->data;
- provides = _alpm_db_whatprovides(dbs, miss->depend.name);
+ provides = _alpm_db_whatprovides(j->data, miss->depend.name);
if(provides) {
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;
goto error;
}
- found = 0;
- 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) {
+ if(pkg_isin(sync->name, 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;
}
- found = 0;
- for(j = trail; j; j = j->next) {
- pmpkg_t *tmp = j->data;
- if(tmp && !strcmp(tmp->name, sync->name)) {
- found = 1;
- }
- }
- if(!found) {
+ if(!pkg_isin(sync->name, trail)) {
/* check pmo_ignorepkg and pmo_s_ignore to make sure we haven't pulled in
* something we're not supposed to.
*/
int usedep = 1;
- found = 0;
- for(j = handle->ignorepkg; j && !found; j = j->next) {
- if(!strcmp(j->data, sync->name)) {
- found = 1;
- }
- }
- if(found) {
+ if(pm_list_is_strin(sync->name, handle->ignorepkg)) {
pmpkg_t *dummypkg = pkg_new(miss->target, NULL);
QUESTION(trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, dummypkg, sync, NULL, &usedep);
FREEPKG(dummypkg);
diff --git a/lib/libalpm/deps.h b/lib/libalpm/deps.h
index 99032833..9451d8b4 100644
--- a/lib/libalpm/deps.h
+++ b/lib/libalpm/deps.h
@@ -36,7 +36,9 @@ typedef struct __pmdepmissing_t {
pmdepend_t depend;
} 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 *checkdeps(pmdb_t *db, unsigned char op, PMList *packages);
int splitdep(char *depstr, pmdepend_t *depend);
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index eda87f18..bf5585d2 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -373,30 +373,23 @@ error:
/* Test for existence of a package in a PMList*
* 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;
if(needle == NULL || haystack == NULL) {
- return(0);
+ return(NULL);
}
for(lp = haystack; lp; lp = lp->next) {
pmpkg_t *info = lp->data;
- if(info && !strcmp(info->name, needle->name)) {
- if(!strcmp(info->version, needle->version)) {
- return(1);
- }
- return(-1);
+ if(info && !strcmp(info->name, needle)) {
+ return(lp->data);
}
}
- return(0);
+ return(NULL);
}
int pkg_splitname(char *target, char *name, char *version)
diff --git a/lib/libalpm/package.h b/lib/libalpm/package.h
index 7bc5418a..155a2f6c 100644
--- a/lib/libalpm/package.h
+++ b/lib/libalpm/package.h
@@ -90,7 +90,7 @@ pmpkg_t* pkg_new(const char *name, const char *version);
pmpkg_t *pkg_dup(pmpkg_t *pkg);
void pkg_free(pmpkg_t *pkg);
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);
#endif /* _ALPM_PACKAGE_H */
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 966df1b6..898969ee 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -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(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) {
_alpm_log(PM_LOG_ERROR, "could not find %s in database", name);
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);
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)) {
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);
if(depinfo == NULL) {
/* look for a provides package */
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 3441681e..1c88b978 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -118,8 +118,9 @@ PMList *sync_load_dbarchive(char *archive)
goto error;
}
- /* readdir tmp_dir */
+ /* ORE - readdir tmp_dir */
/* for each subdir, parse %s/desc and %s/depends */
+ /* then db_write it */
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) {
sync = j->data;
if(sync->type == PM_SYNC_TYPE_REPLACE) {
- for(k = sync->data; k && !replace; k = k->next) {
- if(!strcmp(((pmpkg_t *)k->data)->name, spkg->name)) {
- replace = 1;
- }
+ if(pkg_isin(spkg->name, sync->data)) {
+ replace = 1;
}
}
}
if(replace) {
_alpm_log(PM_LOG_DEBUG, "%s is already elected for removal -- skipping",
- local->name);
+ spkg->name);
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");
for(i = trans->packages; i; i = i->next) {
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) {
/* pm_errno is set by resolvedeps */
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) {
sync = j->data;
if(sync->type == PM_SYNC_TYPE_REPLACE) {
- PMList *k;
- for(k = sync->data; k && !found; k = k->next) {
- 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(pkg_isin(miss->depend.name, sync->data)) {
+ found = 1;
}
}
}
if(found) {
+ _alpm_log(PM_LOG_DEBUG, "%s is already elected for removal -- skipping",
+ miss->depend.name);
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
*/
- for(j = sync->pkg->provides; j && j->data && !found; j = j->next) {
- if(!strcmp(j->data, miss->depend.name)) {
- found = 1;
- }
- }
- if(found) {
+ if(pm_list_is_strin(miss->depend.name, sync->pkg->provides)) {
/* so just treat it like a "replaces" item so the REQUIREDBY
* 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 *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, rsync, ptr_cmp, (void **)&spkg);
FREESYNC(spkg);
FREE(rmpkg);
continue;
@@ -653,7 +642,7 @@ int sync_commit(pmtrans_t *trans, pmdb_t *db_local, PMList **data)
PMList *j;
for(j = sync->data; j; j = j->next) {
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) {
goto error;
}