buildReplaces: do not add duplicated replacees
authorAlejandro del Castillo <alejandro.delcastillo@ni.com>
Mon, 21 Mar 2016 22:33:59 +0000 (17:33 -0500)
committerJo-Philipp Wich <jo@mein.io>
Wed, 15 Mar 2017 02:16:13 +0000 (03:16 +0100)
If package A both replaces and conflicts package B, it is added
unconditionally to the replaced_by vector of package B. Add check to
only add it if it's not there to avoid inaccurate warnings of the type:

Multiple replacers for X, using first one

Signed-off-by: Alejandro del Castillo <alejandro.delcastillo@ni.com>
libopkg/pkg_depends.c

index 6979f14..711283a 100644 (file)
@@ -707,8 +707,10 @@ void parse_replacelist(pkg_t *pkg, char *list)
                /* if a package pkg both replaces and conflicts old_abpkg,
                 * then add it to the replaced_by vector so that old_abpkg
                 * will be upgraded to ab_pkg automatically */
-               if (pkg_conflicts_abstract(pkg, old_abpkg))
-                       abstract_pkg_vec_insert(old_abpkg->replaced_by, ab_pkg);
+               if (pkg_conflicts_abstract(pkg, old_abpkg)) {
+                       if (!abstract_pkg_vec_contains(old_abpkg->replaced_by, ab_pkg))
+                               abstract_pkg_vec_insert(old_abpkg->replaced_by, ab_pkg);
+               }
 
                replaces = tmp;
                replaces[count - 1] = old_abpkg;