[OpenWrt-Devel] [PATCH] opkg: check for reverse conflicts on install

Peter Stadler peter.stadler at student.uibk.ac.at
Tue Mar 3 08:28:44 EST 2020


Do not install a package if another package that is already installed
lists the new package (or one of its providees) as conflicting.
Without checking for reverse conflicts, the conflicting packages need
cyclic conflicts, which are not supported by `make menuconfig`.

Signed-off-by: Peter Stadler <peter.stadler at student.uibk.ac.at>
---
 libopkg/pkg_depends.c | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)

diff --git a/libopkg/pkg_depends.c b/libopkg/pkg_depends.c
index 3abdcd3..9f62faf 100644
--- a/libopkg/pkg_depends.c
+++ b/libopkg/pkg_depends.c
@@ -292,6 +292,8 @@ static int is_pkg_a_replaces(pkg_t * pkg_scout, pkg_t * pkg)
 
 pkg_vec_t *pkg_hash_fetch_conflicts(pkg_t * pkg)
 {
+	pkg_vec_t * installed_pkgs;
+	pkg_t *installed_pkg;
 	pkg_vec_t *installed_conflicts, *test_vec;
 	compound_depend_t *conflicts, *conflict;
 	depend_t **possible_satisfiers;
@@ -312,17 +314,14 @@ pkg_vec_t *pkg_hash_fetch_conflicts(pkg_t * pkg)
 	}
 
 	conflicts = pkg_get_ptr(pkg, PKG_CONFLICTS);
-	if (!conflicts) {
-		return (pkg_vec_t *) NULL;
-	}
 	installed_conflicts = pkg_vec_alloc();
 
 	/* foreach conflict */
-	for (conflict = conflicts; conflict->type; conflict++ ) {
-		possible_satisfiers = conflicts->possibilities;
+	for (conflict = conflicts; conflict && conflict->type; conflict++ ) {
+		possible_satisfiers = conflict->possibilities;
 
 		/* foreach possible satisfier */
-		for (j = 0; j < conflicts->possibility_count; j++) {
+		for (j = 0; j < conflict->possibility_count; j++) {
 			possible_satisfier = possible_satisfiers[j];
 			if (!possible_satisfier)
 				opkg_msg(ERROR,
@@ -355,9 +354,19 @@ pkg_vec_t *pkg_hash_fetch_conflicts(pkg_t * pkg)
 				}
 			}
 		}
-		conflicts++;
 	}
 
+	/* reverse conflicts */
+	installed_pkgs = pkg_vec_alloc();
+	pkg_hash_fetch_all_installed(installed_pkgs);
+	for (j = 0; j < installed_pkgs->len; j++) {
+		installed_pkg = installed_pkgs->pkgs[j];
+		if (pkg_conflicts(installed_pkg, pkg)) {
+			pkg_vec_insert(installed_conflicts, installed_pkg);
+		}
+	}
+	pkg_vec_free(installed_pkgs);
+
 	if (installed_conflicts->len)
 		return installed_conflicts;
 	pkg_vec_free(installed_conflicts);
-- 
2.24.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list