From db7fb64d9ce196916f36c9b5316c99694d531d32 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 9 Jan 2022 19:52:40 +0000 Subject: [PATCH] libopkg: pkg_hash: prefer to-be-installed packages Increase PROVIDES candidate score also in case the package name matches a to-be-installed package listed. Signed-off-by: Daniel Golle --- libopkg/opkg_cmd.c | 5 +++++ libopkg/opkg_cmd.h | 2 ++ libopkg/pkg_hash.c | 8 ++++++++ 3 files changed, 15 insertions(+) diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c index 7a9ee37..b6c45f5 100644 --- a/libopkg/opkg_cmd.c +++ b/libopkg/opkg_cmd.c @@ -41,6 +41,9 @@ #include "opkg_configure.h" #include "xsystem.h" +int opkg_cli_argc = 0; +char **opkg_cli_argv = NULL; + static void print_pkg(pkg_t * pkg) { char *version = pkg_version_str_alloc(pkg); @@ -1427,5 +1430,7 @@ opkg_cmd_t *opkg_cmd_find(const char *name) int opkg_cmd_exec(opkg_cmd_t * cmd, int argc, const char **argv) { + opkg_cli_argc = argc; + opkg_cli_argv = argv; return (cmd->fun) (argc, argv); } diff --git a/libopkg/opkg_cmd.h b/libopkg/opkg_cmd.h index e23d773..8831bd3 100644 --- a/libopkg/opkg_cmd.h +++ b/libopkg/opkg_cmd.h @@ -32,4 +32,6 @@ opkg_cmd_t *opkg_cmd_find(const char *name); int opkg_cmd_exec(opkg_cmd_t * cmd, int argc, const char **argv); extern int opkg_state_changed; +extern int opkg_cli_argc; +extern char **opkg_cli_argv; #endif diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c index c58703f..11b1a06 100644 --- a/libopkg/pkg_hash.c +++ b/libopkg/pkg_hash.c @@ -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); -- 2.30.2