FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 09-11-2011, 07:29 PM
Benedikt Morbach
 
Default Show status on optdepends that are part of transaction

Signed-off-by: Benedikt Morbach <benedikt.morbach@googlemail.com>
---
src/pacman/util.c | 40 ++++++++++++++++++++++++++--------------
1 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/src/pacman/util.c b/src/pacman/util.c
index afe6840..1f54f65 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -1053,26 +1053,38 @@ alpm_list_t *optdep_string_list(const alpm_list_t *optlist, int include_installe
{
alpm_list_t *optstrings = NULL;
alpm_optdepend_t *optdep;
- alpm_db_t *db_local;
+ alpm_db_t *db_local = alpm_option_get_localdb(config->handle);

- db_local = alpm_option_get_localdb(config->handle);
+ /* calculate these outside the loop. */
+ alpm_list_t *pkgcache = alpm_db_get_pkgcache(db_local);
+ alpm_list_t *remove = alpm_trans_get_remove(config->handle);
+ alpm_list_t *add = alpm_trans_get_add(config->handle);

- /* turn optdepends list into a text list */
+ /* turn optdepends list into a text list. */
for( ; optlist; optlist = alpm_list_next(optlist)) {
optdep = alpm_list_getdata(optlist);
- if(include_installed && alpm_db_get_pkg(db_local, optdep->depend->name)) {
- const char * const installed = _(" [installed]");
- char *str, *tmp;
- tmp = alpm_optdep_compute_string(optdep);
- if((str = realloc(tmp, strlen(tmp) + strlen(installed) + 1)) != NULL) {
- strcpy(str + strlen(str), installed);
- optstrings = alpm_list_add(optstrings, str);
- } else {
- free(tmp);
- }
+ char *depstr = alpm_dep_compute_string(optdep->depend);
+ char *tmp, *str = alpm_optdep_compute_string(optdep);
+ const char *state = NULL;
+
+ if(alpm_find_satisfier(pkgcache, depstr) && alpm_find_satisfier(remove, depstr) == NULL) {
+ state = include_installed ? _(" [installed]") : NULL;
+ } else if(alpm_find_satisfier(add, depstr)) {
+ state = include_installed ? _(" [installing]") : NULL;
+ } else if(alpm_find_satisfier(remove, depstr)) {
+ state = _(" [removing]");
} else {
- optstrings = alpm_list_add(optstrings, alpm_optdep_compute_string(optdep));
+ optstrings = alpm_list_add(optstrings, str);
}
+
+ if(state) {
+ if((tmp = realloc(str, strlen(str) + strlen(state) + 1)) != NULL) {
+ strcpy(tmp + strlen(tmp), state);
+ str = tmp;
+ } /* if realloc fails, we only loose the state information, which is nonfatal. */
+ optstrings = alpm_list_add(optstrings, str);
+ }
+ free(depstr);
}
return optstrings;
}
--
1.7.6.1
 

Thread Tools




All times are GMT. The time now is 12:42 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org