libopkg: check installed reverse dependencies upon install/upgrade
[oweals/opkg-lede.git] / libopkg / pkg_hash.c
index 611f3b901f5e6bd03a9cef4e7ac376904d1dfcb2..a474a186687f3f61ea18ee024dc24ca171a01d51 100644 (file)
@@ -357,12 +357,33 @@ pkg_t *pkg_hash_fetch_best_installation_candidate(abstract_pkg_t * apkg,
                /* now check for supported architecture */
                {
                        int max_count = 0;
+                       int found_apkg = 0;
 
                        /* count packages matching max arch priority and keep track of last one */
                        for (j = 0; j < vec->len; j++) {
                                pkg_t *maybe = vec->pkgs[j];
                                arch_priority = pkg_get_arch_priority(maybe);
 
+                               /* check if this package actually provides the requested
+                                  abstract package */
+                               found_apkg = 0;
+                               provided_apkgs = pkg_get_ptr(maybe, PKG_PROVIDES);
+
+                               while (provided_apkgs && *provided_apkgs) {
+                                       if (!strcmp((*provided_apkgs)->name, apkg->name)) {
+                                               found_apkg = 1;
+                                               break;
+                                       }
+                                       provided_apkgs++;
+                               }
+
+                               if (found_apkg == 0) {
+                                       opkg_msg(DEBUG,
+                                               "%s version=%s skipped since it does not provide %s\n",
+                                               maybe->name, pkg_get_string(maybe, PKG_VERSION), apkg->name);
+                                       continue;
+                               }
+
                                opkg_msg(DEBUG,
                                         "%s arch=%s arch_priority=%d version=%s.\n",
                                         maybe->name, pkg_get_architecture(maybe),