From 836962fda4d61d54b85e0bddb7fa1e3e3e417e28 Mon Sep 17 00:00:00 2001 From: YangYunYi Date: Tue, 10 Jun 2025 17:44:10 +0800 Subject: [PATCH] install the pkg that match the name first when epkg install pkg, if there are multiple provides to choose, it will priority the one with the same name as the input, rather than the first one. For example, eplg install groff-x11, in this casse, groff-x11 should be installed instead of groff. --- src/depends.rs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/depends.rs b/src/depends.rs index b173797..5bd23e1 100644 --- a/src/depends.rs +++ b/src/depends.rs @@ -162,12 +162,16 @@ impl PackageManager { // Policy Step 2: If not satisfied by an existing package, try to install the first provider. if !provider_list_to_check.is_empty() { - let first_provider_to_try = &provider_list_to_check[0]; - log::debug!( - "Capability '{}': No existing package found or suitable. Attempting to install first provider: '{}'", - capability_or_pkg_name, - first_provider_to_try - ); + if if provider_list_to_check.contains(&capability_or_pkg_name) { + let first_provider_to_try = capability_or_pkg_name.clone(); + } else { + let first_provider_to_try = &provider_list_to_check[0]; + log::debug!( + "Capability '{}': No existing package found or suitable. Attempting to install first provider: '{}'", + capability_or_pkg_name, + first_provider_to_try + ); + } // `add_one_package_installing` returns Some(pkgkey) if it successfully adds the package // or if the package (with the correct version/arch) is already in `packages_map`. -- Gitee