[pacman-dev] [PATCH] Match providers when showing optdep install status

Lukas Fleischer lfleischer at archlinux.org
Wed May 20 11:10:32 UTC 2015


Use alpm_find_satisfier() instead of alpm_db_get_pkg() when retrieving
the install status of a package to make sure we spot providers as well.

Signed-off-by: Lukas Fleischer <lfleischer at archlinux.org>
---
 src/pacman/package.c | 3 ++-
 src/pacman/util.c    | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/pacman/package.c b/src/pacman/package.c
index 33184bd..2fd0a9c 100644
--- a/src/pacman/package.c
+++ b/src/pacman/package.c
@@ -57,11 +57,12 @@ static void deplist_display(const char *title,
 static void optdeplist_display(alpm_pkg_t *pkg, unsigned short cols)
 {
 	alpm_list_t *i, *text = NULL;
+	alpm_db_t *localdb = alpm_get_localdb(config->handle);
 	for(i = alpm_pkg_get_optdepends(pkg); i; i = alpm_list_next(i)) {
 		alpm_depend_t *optdep = i->data;
 		char *depstring = alpm_dep_compute_string(optdep);
 		if(alpm_pkg_get_origin(pkg) == ALPM_PKG_FROM_LOCALDB) {
-			if(alpm_db_get_pkg(alpm_get_localdb(config->handle), optdep->name)) {
+			if(alpm_find_satisfier(alpm_db_get_pkgcache(localdb), optdep->name)) {
 				const char *installed = _(" [installed]");
 				depstring = realloc(depstring, strlen(depstring) + strlen(installed) + 1);
 				strcpy(depstring + strlen(depstring), installed);
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 5d68360..b086bb8 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -1205,9 +1205,10 @@ static int depend_cmp(const void *d1, const void *d2)
 
 static char *make_optstring(alpm_depend_t *optdep)
 {
+	alpm_db_t *localdb = alpm_get_localdb(config->handle);
 	char *optstring = alpm_dep_compute_string(optdep);
 	char *status = NULL;
-	if(alpm_db_get_pkg(alpm_get_localdb(config->handle), optdep->name)) {
+	if(alpm_find_satisfier(alpm_db_get_pkgcache(localdb), optdep->name)) {
 		status = _(" [installed]");
 	} else if(alpm_pkg_find(alpm_trans_get_add(config->handle), optdep->name)) {
 		status = _(" [pending]");
-- 
2.4.1


More information about the pacman-dev mailing list