[pacman-dev] [PATCH] Group optional dependencies by installation status

Drew DeVault sircmpwn at gmail.com
Thu Jul 11 14:43:34 EDT 2013


Not sure how expensive alpm_db_get_pkg is, so it might be worthwhile to
use something other than make_optstring to accomplish this if we want to
avoid calling it four times per package.

Signed-off-by: Drew DeVault <sir at cmpwn.com>
---
 src/pacman/util.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/src/pacman/util.c b/src/pacman/util.c
index 23c4009..c1d3dab 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -1243,10 +1243,19 @@ void display_optdepends(alpm_pkg_t *pkg)
 
     optdeps = alpm_pkg_get_optdepends(pkg);
 
-    /* turn optdepends list into a text list */
+    /* turn optdepends list into a text list, with uninstalled
dependencies last */
     for(i = optdeps; i; i = alpm_list_next(i)) {
         alpm_depend_t *optdep = i->data;
-        optstrings = alpm_list_add(optstrings, make_optstring(optdep));
+        if(alpm_db_get_pkg(alpm_get_localdb(config->handle),
optdep->name) != 0) {
+            optstrings = alpm_list_add(optstrings, make_optstring(optdep));
+        }
+    }
+
+    for(i = optdeps; i; i = alpm_list_next(i)) {
+        alpm_depend_t *optdep = i->data;
+        if(alpm_db_get_pkg(alpm_get_localdb(config->handle),
optdep->name) == 0) {
+            optstrings = alpm_list_add(optstrings, make_optstring(optdep));
+        }
     }
 
     if(optstrings) {
-- 
1.8.3.2



More information about the pacman-dev mailing list