[pacman-dev,2/4] libalpm: resolvedep(): don't compare names twice

Message ID 20190908214529.3512-2-morganamilo@gmail.com
State New
Headers show
Series
  • [pacman-dev,1/4] libalpm: fix incorrect documentation
Related show

Commit Message

Morgan Adamiec Sept. 8, 2019, 9:45 p.m. UTC
If we failed to get the pkg from pkgcache then we know no satisfying
package exists by name. So only compare provides.
---
 lib/libalpm/deps.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Andrew Gregory Sept. 10, 2019, 3:46 p.m. UTC | #1
On 09/08/19 at 10:45pm, morganamilo wrote:
> If we failed to get the pkg from pkgcache then we know no satisfying
> package exists by name. So only compare provides.
> ---
>  lib/libalpm/deps.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
> index ce7869c3..322c4e7e 100644
> --- a/lib/libalpm/deps.c
> +++ b/lib/libalpm/deps.c
> @@ -698,7 +698,8 @@ static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
>  		for(j = _alpm_db_get_pkgcache(db); j; j = j->next) {
>  			alpm_pkg_t *pkg = j->data;
>  			if((pkg->name_hash != dep->name_hash || strcmp(pkg->name, dep->name) != 0)

Unrelated to this patch, but we probably shouldn't be filtering out
name matches here.  A package could provide a different version of
itself.

> -					&& _alpm_depcmp(pkg, dep) && !alpm_pkg_find(excluding, pkg->name)) {
> +					&& _alpm_depcmp_provides(dep, alpm_pkg_get_provides(pkg))
> +					&& !alpm_pkg_find(excluding, pkg->name)) {
>  				if(alpm_pkg_should_ignore(handle, pkg)) {
>  					alpm_question_install_ignorepkg_t question = {
>  						.type = ALPM_QUESTION_INSTALL_IGNOREPKG,
> -- 
> 2.23.0

Patch

diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c
index ce7869c3..322c4e7e 100644
--- a/lib/libalpm/deps.c
+++ b/lib/libalpm/deps.c
@@ -698,7 +698,8 @@  static alpm_pkg_t *resolvedep(alpm_handle_t *handle, alpm_depend_t *dep,
 		for(j = _alpm_db_get_pkgcache(db); j; j = j->next) {
 			alpm_pkg_t *pkg = j->data;
 			if((pkg->name_hash != dep->name_hash || strcmp(pkg->name, dep->name) != 0)
-					&& _alpm_depcmp(pkg, dep) && !alpm_pkg_find(excluding, pkg->name)) {
+					&& _alpm_depcmp_provides(dep, alpm_pkg_get_provides(pkg))
+					&& !alpm_pkg_find(excluding, pkg->name)) {
 				if(alpm_pkg_should_ignore(handle, pkg)) {
 					alpm_question_install_ignorepkg_t question = {
 						.type = ALPM_QUESTION_INSTALL_IGNOREPKG,