summaryrefslogtreecommitdiff
path: root/lib/libalpm/conflict.c
diff options
context:
space:
mode:
authorNagy Gabor <ngaba@bibl.u-szeged.hu>2007-11-20 09:57:38 +0100
committerDan McGee <dan@archlinux.org>2007-11-25 16:14:16 -0600
commit72f40b3876263f7a8dcda1390026f43f599f8823 (patch)
treea595b8061ef2c44b56c71479e323ca7bef65f070 /lib/libalpm/conflict.c
parentd683033d3ea79956faf8786f784ce2e271179892 (diff)
downloadpacman-72f40b3876263f7a8dcda1390026f43f599f8823.tar.xz
_alpm_checkconflicts split
_alpm_innerconflicts: check for target<->target conflicts _alpm_outerconflicts: check for target<->localpkg conflicts This will be useful in sync.c clean-up and in testdb.c As an application the patch also fixes a misleading message (and a memleak) in add.c Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/conflict.c')
-rw-r--r--lib/libalpm/conflict.c29
1 files changed, 24 insertions, 5 deletions
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index 7268275e..7b21c38a 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -162,8 +162,24 @@ static void check_conflict(alpm_list_t *list1, alpm_list_t *list2,
}
}
-/* Returns a alpm_list_t* of pmconflict_t pointers. */
-alpm_list_t *_alpm_checkconflicts(pmdb_t *db, alpm_list_t *packages)
+/* Check for inter-conflicts */
+alpm_list_t *_alpm_innerconflicts(alpm_list_t *packages)
+{
+ alpm_list_t *baddeps = NULL;
+
+ ALPM_LOG_FUNC;
+
+ _alpm_log(PM_LOG_DEBUG, "check targets vs targets\n");
+ check_conflict(packages, packages, &baddeps, 0);
+
+ return(baddeps);
+}
+
+/* Check for target vs (db - target) conflicts
+ * In case of conflict the package1 field of pmdepconflict_t contains
+ * the target package, package2 field contains the local package
+ */
+alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages)
{
alpm_list_t *baddeps = NULL;
@@ -176,18 +192,21 @@ alpm_list_t *_alpm_checkconflicts(pmdb_t *db, alpm_list_t *packages)
alpm_list_t *dblist = alpm_list_diff(_alpm_db_get_pkgcache(db), packages,
_alpm_pkg_cmp);
- /* three checks to be done here for conflicts */
+ /* two checks to be done here for conflicts */
_alpm_log(PM_LOG_DEBUG, "check targets vs db\n");
check_conflict(packages, dblist, &baddeps, 1);
_alpm_log(PM_LOG_DEBUG, "check db vs targets\n");
check_conflict(dblist, packages, &baddeps, -1);
- _alpm_log(PM_LOG_DEBUG, "check targets vs targets\n");
- check_conflict(packages, packages, &baddeps, 0);
alpm_list_free(dblist);
return(baddeps);
}
+/* Check for transaction conflicts */
+alpm_list_t *_alpm_checkconflicts(pmdb_t *db, alpm_list_t *packages) {
+ return(alpm_list_join(_alpm_innerconflicts(packages), _alpm_outerconflicts(db, packages)));
+}
+
/* Returns a alpm_list_t* of file conflicts.
* Hooray for set-intersects!
* Pre-condition: both lists are sorted!