guillaum.bouchard@gmail.com writes:
In extended table view, packages which are not explicitly installed are displayed in grey. This helps understanding why packages are updated.
This helps the package managment workflow. During update, we can quickly have a look at why packages are updated and easilly track and remove the explicit packages which are not longer required. During remove, it shows all the explicit packages which are also removed by a cascade removal. During install, it provides a feedback on how your action will affect the database.
When I tested this patch, it only seemed to work for adding and removing packages, there was no difference while performing upgrades. It looks like this is because the install reason for the upgraded package doesn't get set until commit_single_pkg(), which only runs after the user has confirmed the upgrade. Adding the line below makes the coloring work for upgrades as well. Also, the patch no longer applies cleanly because of commit 3f34e09. diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index f1add24..5ecf6ea 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -238,6 +238,7 @@ int SYMEXPORT alpm_sync_sysupgrade(alpm_handle_t *handle, int enable_downgrade) alpm_pkg_t *spkg = _alpm_db_get_pkgfromcache(sdb, lpkg->name); if(spkg) { if(check_literal(handle, lpkg, spkg, enable_downgrade)) { + spkg->reason = alpm_pkg_get_reason(lpkg); trans->add = alpm_list_add(trans->add, spkg); } /* jump to next local package */
This patch created a new colstr setting and associate it with BOLDBLACK (i.e. grey).
Signed-off-by: Guillaume Bouchard <guillaum.bouchard@gmail.com> --- src/pacman/conf.c | 1 + src/pacman/conf.h | 1 + src/pacman/util.c | 13 ++++++++++--- 3 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 5450f3b..785061b 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -76,6 +76,7 @@ void enable_colors(int colors) colstr->warn = BOLDYELLOW; colstr->err = BOLDRED; colstr->nocolor = NOCOLOR; + colstr->depend = BOLDBLACK; } }
diff --git a/src/pacman/conf.h b/src/pacman/conf.h index 9faf5de..2edbe16 100644 --- a/src/pacman/conf.h +++ b/src/pacman/conf.h @@ -32,6 +32,7 @@ typedef struct __colstr_t { const char *warn; const char *err; const char *nocolor; + const char *depend; } colstr_t;
typedef struct __config_t { diff --git a/src/pacman/util.c b/src/pacman/util.c index 58b0cec..7cbbd33 100644 --- a/src/pacman/util.c +++ b/src/pacman/util.c @@ -57,7 +57,8 @@ enum { CELL_NORMAL = 0, CELL_TITLE = (1 << 0), CELL_RIGHT_ALIGN = (1 << 1), - CELL_FREE = (1 << 3) + CELL_FREE = (1 << 3), + CELL_DEPEND = (1 << 4) };
int trans_init(alpm_transflag_t flags, int check_valid) @@ -488,7 +489,9 @@ static void table_print_line(const alpm_list_t *line, short col_padding,
if(cell->mode & CELL_TITLE) { printf("%s%*s%s", config->colstr.title, cell_width, str, config->colstr.nocolor); - } else { + } else if(cell->mode & CELL_DEPEND) { + printf("%s%*s%s", config->colstr.depend, cell_width, str, config->colstr.nocolor); + } else { printf("%*s", cell_width, str); } need_padding = 1; @@ -808,7 +811,11 @@ static alpm_list_t *create_verbose_row(pm_target_t *target) } else { pm_asprintf(&str, "%s", alpm_pkg_get_name(target->remove)); } - add_table_cell(&ret, str, CELL_NORMAL); + if(alpm_pkg_get_reason(target->remove ? target->remove : target->install) == ALPM_PKG_REASON_DEPEND) {
This is mainly a style thing but there is an if-else right before this line that checks for target->remove and target->install. I think folding the install reason check into the previous if-else flows better but there is no logical difference.
+ add_table_cell(&ret, str, CELL_DEPEND); + } else { + add_table_cell(&ret, str, CELL_NORMAL); + }
/* old and new versions */ pm_asprintf(&str, "%s",
Cheers, Chirantan -- Sent with my mu4e