pkg_hash: don't suggest incompatible packages
authorPaul Spooren <mail@aparcar.org>
Tue, 27 Oct 2020 02:39:57 +0000 (16:39 -1000)
committerDaniel Golle <daniel@makrotopia.org>
Fri, 30 Oct 2020 00:15:14 +0000 (00:15 +0000)
Up until now opkg would suggest packages with unsatisfied dependencies
as installable candidates. This is a frequent issue for the kmod feed in
snapshot images. In these cases opkg suggest a newer kmod version than
compatible with the installed kernel, because the same package is
available both in the kmods archive and the target specific packages
feed.

This commit fixes the issue by dropping all package problematic
candidates by checking if all their dependencies could be installed.

Signed-off-by: Paul Spooren <mail@aparcar.org>
libopkg/pkg_hash.c

index 52c64ff137ba49f38d7bc31d0601f3037ad8a10d..6715ebd112da012c12cdc552d271b96bde0505c9 100644 (file)
@@ -20,6 +20,7 @@
 #include "hash_table.h"
 #include "pkg.h"
 #include "opkg_message.h"
+#include "pkg_depends.h"
 #include "pkg_vec.h"
 #include "pkg_hash.h"
 #include "parse_util.h"
@@ -376,10 +377,23 @@ pkg_t *pkg_hash_fetch_best_installation_candidate(abstract_pkg_t * apkg,
                                if ((arch_priority > 0)
                                    &&
                                    (!pkg_vec_contains(matching_pkgs, maybe))) {
-                                       max_count++;
-                                       abstract_pkg_vec_insert(matching_apkgs,
-                                                               maybe->parent);
-                                       pkg_vec_insert(matching_pkgs, maybe);
+                                       char **unresolved = NULL;
+                                       pkg_vec_t *depends = pkg_vec_alloc();
+                                       pkg_hash_fetch_unsatisfied_dependencies(maybe, depends,
+                                               &unresolved);
+
+                                       if (!unresolved) {
+                                               max_count++;
+                                               abstract_pkg_vec_insert(matching_apkgs,
+                                                                       maybe->parent);
+                                               pkg_vec_insert(matching_pkgs, maybe);
+                                       } else {
+                                               char **tmp = unresolved;
+                                               while (tmp)
+                                                       free(*(tmp++));
+                                               free(unresolved);
+                                       }
+                                       pkg_vec_free(depends);
                                }
                        }