libopkg: pkg_hash: prefer to-be-installed packages
[project/opkg-lede.git] / libopkg / pkg_hash.c
index c58703f60e663de224b93aabaa61901cd841e560..11b1a06bc83c759efe37c500c0212a3fd20ad8c8 100644 (file)
@@ -26,6 +26,7 @@
 #include "parse_util.h"
 #include "pkg_parse.h"
 #include "opkg_utils.h"
+#include "opkg_cmd.h"
 #include "sprintf_alloc.h"
 #include "file_util.h"
 #include "libbb/libbb.h"
@@ -416,6 +417,13 @@ pkg_t *pkg_hash_fetch_best_installation_candidate(abstract_pkg_t * apkg,
                        if (strcmp(matching->name, apkg->name) == 0)
                                score++;
 
+                       for (j = 0; j < opkg_cli_argc; ++j) {
+                               if (!strcmp(matching->name, opkg_cli_argv[j])) {
+                                       score++;
+                                       break;
+                               }
+                       }
+
                        opkg_msg(DEBUG, "Candidate: %s %s (score %d).\n",
                                 matching->name, pkg_get_string(matching, PKG_VERSION),
                                 score);