summaryrefslogtreecommitdiff
path: root/lib/libalpm
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2006-01-15 15:55:16 +0000
committerAurelien Foret <aurelien@archlinux.org>2006-01-15 15:55:16 +0000
commit6dd2ecf4fa19346193e4ea69419c1b1004fb66e8 (patch)
tree94d206e257e204f41a5344a2b56e4f31e94a06d2 /lib/libalpm
parent83839f95132624f385c66eb9a4fc354c21ae7025 (diff)
downloadpacman-6dd2ecf4fa19346193e4ea69419c1b1004fb66e8.tar.xz
pulled out conflict checkings from checkdeps() in its own function: checkconflicts()
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/add.c70
-rw-r--r--lib/libalpm/conflict.c172
-rw-r--r--lib/libalpm/conflict.h1
-rw-r--r--lib/libalpm/deps.c334
-rw-r--r--lib/libalpm/remove.c5
-rw-r--r--lib/libalpm/sync.c46
6 files changed, 314 insertions, 314 deletions
diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
index cde16141..d38eed7b 100644
--- a/lib/libalpm/add.c
+++ b/lib/libalpm/add.c
@@ -197,69 +197,33 @@ int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
ASSERT(db != NULL, RET_ERR(PM_ERR_DB_NULL, -1));
- if(data) {
- *data = NULL;
- }
-
/* Check dependencies
*/
if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) {
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);
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((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
- FREELIST(lp);
- FREELIST(*data);
- RET_ERR(PM_ERR_MEMORY, -1);
- }
- *miss = *(pmdepmissing_t*)i->data;
- *data = pm_list_add(*data, miss);
- }
- }
- }
- if(errorout) {
+ if(data) {
+ *data = lp;
+ } else {
FREELIST(lp);
- RET_ERR(PM_ERR_UNSATISFIED_DEPS, -1);
}
+ RET_ERR(PM_ERR_UNSATISFIED_DEPS, -1);
+ }
- /* no unsatisfied deps, so look for conflicts */
- _alpm_log(PM_LOG_FLOW2, "looking for conflicts");
- for(i = lp; i; i = i->next) {
- pmdepmissing_t* miss = (pmdepmissing_t *)i->data;
- if(miss->type == PM_DEP_TYPE_CONFLICT) {
- if(!errorout) {
- errorout = 1;
- }
- if(data) {
- if((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
- 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);
+ /* no unsatisfied deps, so look for conflicts */
+ _alpm_log(PM_LOG_FLOW1, "looking for conflicts");
+ lp = checkconflicts(db, trans->packages);
+ if(lp != NULL) {
+ if(data) {
+ *data = lp;
+ } else {
+ FREELIST(lp);
}
+ RET_ERR(PM_ERR_CONFLICTING_DEPS, -1);
}
/* re-order w.r.t. dependencies */
@@ -284,6 +248,8 @@ int add_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
if(lp != NULL) {
if(data) {
*data = lp;
+ } else {
+ FREELIST(lp);
}
FREELIST(skiplist);
RET_ERR(PM_ERR_FILE_CONFLICTS, -1);
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index b8412432..4e7cb12a 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -29,8 +29,180 @@
#include <sys/stat.h>
/* pacman */
#include "util.h"
+#include "log.h"
+#include "cache.h"
+#include "deps.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 *i, *j, *k;
diff --git a/lib/libalpm/conflict.h b/lib/libalpm/conflict.h
index 98559836..5d57ea8c 100644
--- a/lib/libalpm/conflict.h
+++ b/lib/libalpm/conflict.h
@@ -23,6 +23,7 @@
#include "db.h"
+PMList *checkconflicts(pmdb_t *db, PMList *packages);
PMList *db_find_conflicts(pmdb_t *db, PMList *targets, char *root, PMList **skip_list);
#endif /* _ALPM_CONFLICT_H */
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index d60b4778..ff6fc505 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -37,6 +37,25 @@
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.
*
* Example (PM_TRANS_TYPE_ADD):
@@ -121,13 +140,11 @@ PMList *sortbydeps(PMList *targets, int mode)
/* Returns a PMList* of missing_t pointers.
*
- * conflicts are always name only, but dependencies can include versions
- * with depmod operators.
+ * dependencies can include versions with depmod operators.
*
*/
PMList *checkdeps(pmdb_t *db, unsigned char op, PMList *packages)
{
- pmpkg_t *info = NULL;
pmdepend_t depend;
PMList *i, *j, *k;
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) {
+ /* DEPENDENCIES -- look for unsatisfied dependencies */
for(i = packages; i; i = i->next) {
pmpkg_t *tp = i->data;
if(tp == NULL) {
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) {
/* split into name/version pairs */
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) {
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 */
@@ -658,106 +532,102 @@ int resolvedeps(pmdb_t *local, PMList *dbs_sync, pmpkg_t *syncpkg, PMList *list,
RET_ERR(???, -1);
} 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 */
- 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;
- }
+
+ /* 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;
}
}
- if(provisio_match) {
- continue;
- }
+ }
+ if(provisio_match) {
+ 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;
- }
+ /* 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;
}
}
- /* 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);
- if(provides) {
- sync = provides->data;
- }
- FREELISTPTR(provides);
+ }
+ /* 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);
+ if(provides) {
+ sync = provides->data;
}
- if(sync == NULL) {
- _alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\" (\"%s\" is not in the package set)",
- miss->target, miss->depend.name);
- pm_errno = PM_ERR_UNRESOLVABLE_DEPS;
- goto error;
+ FREELISTPTR(provides);
+ }
+ if(sync == NULL) {
+ _alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\" (\"%s\" is not in the package set)",
+ miss->target, miss->depend.name);
+ 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) {
+ /* this dep is already in the target list */
+ 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) {
+ /* 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 = 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);
+ for(j = handle->ignorepkg; j && !found; j = j->next) {
+ if(!strcmp(j->data, sync->name)) {
found = 1;
}
}
if(found) {
- /* this dep is already in the target list */
- continue;
- }
-
- found = 0;
- for(j = trail; j; j = j->next) {
- pmpkg_t *tmp = j->data;
- if(tmp && !strcmp(tmp->name, sync->name)) {
- found = 1;
- }
+ pmpkg_t *dummypkg = pkg_new(miss->target, NULL);
+ QUESTION(trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, dummypkg, sync, NULL, &usedep);
+ FREEPKG(dummypkg);
}
- if(!found) {
- /* 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) {
- pmpkg_t *dummypkg = pkg_new(miss->target, NULL);
- QUESTION(trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, dummypkg, sync, NULL, &usedep);
- FREEPKG(dummypkg);
- }
- if(usedep) {
- trail = pm_list_add(trail, sync);
- if(resolvedeps(local, dbs_sync, sync, list, trail, trans)) {
- goto error;
- }
- _alpm_log(PM_LOG_DEBUG, "pulling dependency %s (needed by %s)",
- sync->name, syncpkg->name);
- list = pm_list_add(list, sync);
- } else {
- _alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\"", miss->target);
- pm_errno = PM_ERR_UNRESOLVABLE_DEPS;
+ if(usedep) {
+ trail = pm_list_add(trail, sync);
+ if(resolvedeps(local, dbs_sync, sync, list, trail, trans)) {
goto error;
}
+ _alpm_log(PM_LOG_DEBUG, "pulling dependency %s (needed by %s)",
+ sync->name, syncpkg->name);
+ list = pm_list_add(list, sync);
} else {
- /* cycle detected -- skip it */
- _alpm_log(PM_LOG_DEBUG, "dependency cycle detected: %s", sync->name);
+ _alpm_log(PM_LOG_ERROR, "cannot resolve dependencies for \"%s\"", miss->target);
+ pm_errno = PM_ERR_UNRESOLVABLE_DEPS;
+ goto error;
}
+ } else {
+ /* cycle detected -- skip it */
+ _alpm_log(PM_LOG_DEBUG, "dependency cycle detected: %s", sync->name);
}
}
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 5b7fd418..3e810203 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -83,7 +83,8 @@ int remove_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
EVENT(trans, PM_TRANS_EVT_CHECKDEPS_START, NULL, NULL);
_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) {
while(lp) {
PMList *j;
@@ -101,6 +102,8 @@ int remove_prepare(pmtrans_t *trans, pmdb_t *db, PMList **data)
} else {
if(data) {
*data = lp;
+ } else {
+ FREELIST(lp);
}
RET_ERR(PM_ERR_UNSATISFIED_DEPS, -1);
}
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index d6ebcfbd..d9df821f 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -38,6 +38,7 @@
#include "db.h"
#include "cache.h"
#include "deps.h"
+#include "conflict.h"
#include "trans.h"
#include "sync.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 */
+ _alpm_log(PM_LOG_FLOW1, "checking for package upgrades");
for(i = db_get_pkgcache(db_local); i; i = i->next) {
int cmp;
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 */
EVENT(trans, PM_TRANS_EVT_INTERCONFLICTS_START, NULL, NULL);
+
+ _alpm_log(PM_LOG_FLOW1, "looking for unresolvable dependencies");
deps = checkdeps(db_local, PM_TRANS_TYPE_UPGRADE, list);
if(deps) {
- int errorout = 0;
-
- _alpm_log(PM_LOG_FLOW1, "looking for unresolvable dependencies");
- for(i = deps; 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((miss = (pmdepmissing_t *)malloc(sizeof(pmdepmissing_t))) == NULL) {
- FREELIST(*data);
- 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;
- goto error;
+ if(data) {
+ *data = deps;
+ deps = NULL;
}
+ pm_errno = PM_ERR_UNSATISFIED_DEPS;
+ goto error;
+ }
+
+ /* no unresolvable deps, so look for conflicts */
+ _alpm_log(PM_LOG_FLOW1, "looking for conflicts");
+ deps = checkconflicts(db_local, list);
+ if(deps) {
+ int errorout = 0;
- /* no unresolvable deps, so look for conflicts */
- _alpm_log(PM_LOG_FLOW1, "looking for conflicts");
for(i = deps; i && !errorout; i = i->next) {
pmdepmissing_t *miss = i->data;
PMList *k;
int found = 0;
- if(miss->type != PM_DEP_TYPE_CONFLICT) {
- continue;
- }
-
_alpm_log(PM_LOG_FLOW2, "package %s is conflicting with %s",
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;
goto error;
}
+ FREELIST(deps);
}
FREELISTPTR(list);
}