summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2012-08-12 21:03:04 +1000
committerAllan McRae <allan@archlinux.org>2012-12-14 12:35:34 +1000
commit8e736e1c9a4fb4ba375fe1f02be9e956f5f472d9 (patch)
treed5d88a75c9a47a7bd8e33eaf48157c3e10e7229d /src
parent62f1c590fc26efe7047f7dcbeac8a0910cfb50a5 (diff)
Display install status of optdependencies
When a packages (new) optdepends are printed in install (update), add a note of their current installation status. Packages currently installed are labelled with [installed] and packages to be installed in this transaction are labelled [pending]. Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r--src/pacman/util.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 5ed450ec..78cdf264 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -1200,6 +1200,22 @@ static int depend_cmp(const void *d1, const void *d2)
return ret;
}
+static char *make_optstring(alpm_depend_t *optdep)
+{
+ char *optstring = alpm_dep_compute_string(optdep);
+ char *status = NULL;
+ if(alpm_db_get_pkg(alpm_get_localdb(config->handle), optdep->name)) {
+ status = _(" [installed]");
+ } else if(alpm_pkg_find(alpm_trans_get_add(config->handle), optdep->name)) {
+ status = _(" [pending]");
+ }
+ if(status) {
+ optstring = realloc(optstring, strlen(optstring) + strlen(status) + 1);
+ strcpy(optstring + strlen(optstring), status);
+ }
+ return optstring;
+}
+
void display_new_optdepends(alpm_pkg_t *oldpkg, alpm_pkg_t *newpkg)
{
alpm_list_t *i, *old, *new, *optdeps, *optstrings = NULL;
@@ -1211,7 +1227,7 @@ void display_new_optdepends(alpm_pkg_t *oldpkg, alpm_pkg_t *newpkg)
/* turn optdepends list into a text list */
for(i = optdeps; i; i = alpm_list_next(i)) {
alpm_depend_t *optdep = i->data;
- optstrings = alpm_list_add(optstrings, alpm_dep_compute_string(optdep));
+ optstrings = alpm_list_add(optstrings, make_optstring(optdep));
}
if(optstrings) {
@@ -1233,7 +1249,7 @@ void display_optdepends(alpm_pkg_t *pkg)
/* turn optdepends list into a text list */
for(i = optdeps; i; i = alpm_list_next(i)) {
alpm_depend_t *optdep = i->data;
- optstrings = alpm_list_add(optstrings, alpm_dep_compute_string(optdep));
+ optstrings = alpm_list_add(optstrings, make_optstring(optdep));
}
if(optstrings) {