[pacman-dev] [PATCH] squelch output of installed new optdeps

Clemens Buchacher drizzd at aon.at
Sun Jul 15 18:33:44 EDT 2012


If an upgraded package version contains new optdeps, the user is
notified of that. If the new optdep is already installed, that
information is redundant.

Instead, do not output new optdeps if they are already installed.

Signed-off-by: Clemens Buchacher <drizzd at aon.at>
---
 src/pacman/util.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/pacman/util.c b/src/pacman/util.c
index 7f7f6a7..e774fa8 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -1192,6 +1192,20 @@ static int depend_cmp(const void *d1, const void *d2)
 	return ret;
 }
 
+static alpm_list_t *filter_out_installed(alpm_list_t *list)
+{
+	alpm_list_t *i, *not_installed = NULL;
+	alpm_db_t *db_local = alpm_get_localdb(config->handle);
+
+	for(i = list; i; i = alpm_list_next(i)) {
+		if(!alpm_db_get_pkg(db_local, i->data))
+			not_installed = alpm_list_add(not_installed, i->data);
+	}
+	alpm_list_free(list);
+
+	return not_installed;
+}
+
 void display_new_optdepends(alpm_pkg_t *oldpkg, alpm_pkg_t *newpkg)
 {
 	alpm_list_t *i, *old, *new, *optdeps, *optstrings = NULL;
@@ -1206,6 +1220,8 @@ void display_new_optdepends(alpm_pkg_t *oldpkg, alpm_pkg_t *newpkg)
 		optstrings = alpm_list_add(optstrings, alpm_dep_compute_string(optdep));
 	}
 
+	optstrings = filter_out_installed(optstrings);
+
 	if(optstrings) {
 		printf(_("New optional dependencies for %s\n"), alpm_pkg_get_name(newpkg));
 		unsigned short cols = getcols(fileno(stdout));
-- 
1.7.11.2



More information about the pacman-dev mailing list