New VerbosePkgLists option
If enabled, displays package lists for upgrade, sync and remove operations formatted as a table. Falls back to default list display if insufficient terminal columns are available. Example output: :: Starting full system upgrade... :: Replace libjpeg with testing/libjpeg-turbo? [Y/n] resolving dependencies... looking for inter-conflicts... Remove (1): Name Old Version Size libjpeg 8.3.0-1 0.83 MB Total Removed Size: 0.83 MB Targets (5): Name Old Version New Version Size libjpeg-turbo 1.1.0-1 0.20 MB linux-firmware 20110201-1 20110227-1 8.23 MB ncurses 5.7-4 5.8-1 0.92 MB ppl 0.11.1-1 0.11.2-1 2.74 MB v4l-utils 0.8.1-1 0.8.3-1 0.23 MB Total Download Size: 12.32 MB Total Installed Size: 58.82 MB Signed-off-by: Jakob Gruber <jakob.gruber@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
0152266dd3
commit
e95be3379a
5 changed files with 99 additions and 8 deletions
|
@ -174,6 +174,10 @@ Options
|
||||||
Performs an approximate check for adequate available disk space before
|
Performs an approximate check for adequate available disk space before
|
||||||
installing packages.
|
installing packages.
|
||||||
|
|
||||||
|
*VerbosePkgLists*::
|
||||||
|
Displays name, version and size of target packages formatted
|
||||||
|
as a table for upgrade, sync and remove operations.
|
||||||
|
|
||||||
Repository Sections
|
Repository Sections
|
||||||
-------------------
|
-------------------
|
||||||
Each repository section defines a section name and at least one location where
|
Each repository section defines a section name and at least one location where
|
||||||
|
|
|
@ -33,6 +33,7 @@ Architecture = auto
|
||||||
#UseDelta
|
#UseDelta
|
||||||
#TotalDownload
|
#TotalDownload
|
||||||
#CheckSpace
|
#CheckSpace
|
||||||
|
#VerbosePkgLists
|
||||||
|
|
||||||
#
|
#
|
||||||
# REPOSITORIES
|
# REPOSITORIES
|
||||||
|
|
|
@ -69,11 +69,15 @@ typedef struct __config_t {
|
||||||
unsigned int ask;
|
unsigned int ask;
|
||||||
|
|
||||||
/* conf file options */
|
/* conf file options */
|
||||||
unsigned short chomp; /* I Love Candy! */
|
/* I Love Candy! */
|
||||||
|
unsigned short chomp;
|
||||||
|
/* format target pkg lists as table */
|
||||||
|
unsigned short verbosepkglists;
|
||||||
/* When downloading, display the amount downloaded, rate, ETA, and percent
|
/* When downloading, display the amount downloaded, rate, ETA, and percent
|
||||||
* downloaded of the total download list */
|
* downloaded of the total download list */
|
||||||
unsigned short totaldownload;
|
unsigned short totaldownload;
|
||||||
unsigned short cleanmethod; /* select -Sc behavior */
|
/* select -Sc behavior */
|
||||||
|
unsigned short cleanmethod;
|
||||||
alpm_list_t *holdpkg;
|
alpm_list_t *holdpkg;
|
||||||
alpm_list_t *syncfirst;
|
alpm_list_t *syncfirst;
|
||||||
char *xfercommand;
|
char *xfercommand;
|
||||||
|
|
|
@ -988,6 +988,9 @@ static int _parse_options(const char *key, char *value,
|
||||||
} else if(strcmp(key, "ILoveCandy") == 0) {
|
} else if(strcmp(key, "ILoveCandy") == 0) {
|
||||||
config->chomp = 1;
|
config->chomp = 1;
|
||||||
pm_printf(PM_LOG_DEBUG, "config: chomp\n");
|
pm_printf(PM_LOG_DEBUG, "config: chomp\n");
|
||||||
|
} else if(strcmp(key, "VerbosePkgLists") == 0) {
|
||||||
|
config->verbosepkglists = 1;
|
||||||
|
pm_printf(PM_LOG_DEBUG, "config: verbosepkglists\n");
|
||||||
} else if(strcmp(key, "UseDelta") == 0) {
|
} else if(strcmp(key, "UseDelta") == 0) {
|
||||||
alpm_option_set_usedelta(1);
|
alpm_option_set_usedelta(1);
|
||||||
pm_printf(PM_LOG_DEBUG, "config: usedelta\n");
|
pm_printf(PM_LOG_DEBUG, "config: usedelta\n");
|
||||||
|
|
|
@ -629,6 +629,58 @@ void list_display_linebreak(const char *title, const alpm_list_t *list)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* creates a header row for use with table_display */
|
||||||
|
static alpm_list_t *create_verbose_header(int install)
|
||||||
|
{
|
||||||
|
alpm_list_t *res = NULL;
|
||||||
|
char *str;
|
||||||
|
|
||||||
|
pm_asprintf(&str, "%s", _("Name"));
|
||||||
|
res = alpm_list_add(res, str);
|
||||||
|
pm_asprintf(&str, "%s", _("Old Version"));
|
||||||
|
res = alpm_list_add(res, str);
|
||||||
|
if(install) {
|
||||||
|
pm_asprintf(&str, "%s", _("New Version"));
|
||||||
|
res = alpm_list_add(res, str);
|
||||||
|
}
|
||||||
|
pm_asprintf(&str, "%s", _("Size"));
|
||||||
|
res = alpm_list_add(res, str);
|
||||||
|
|
||||||
|
return(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* returns package info as list of strings */
|
||||||
|
static alpm_list_t *create_verbose_row(pmpkg_t *pkg, int install)
|
||||||
|
{
|
||||||
|
char *str;
|
||||||
|
double size;
|
||||||
|
const char *label;
|
||||||
|
alpm_list_t *ret = NULL;
|
||||||
|
pmdb_t *ldb = alpm_option_get_localdb();
|
||||||
|
|
||||||
|
/* a row consists of the package name, */
|
||||||
|
pm_asprintf(&str, "%s", alpm_pkg_get_name(pkg));
|
||||||
|
ret = alpm_list_add(ret, str);
|
||||||
|
|
||||||
|
/* old and new versions */
|
||||||
|
if(install) {
|
||||||
|
pmpkg_t *oldpkg = alpm_db_get_pkg(ldb, alpm_pkg_get_name(pkg));
|
||||||
|
pm_asprintf(&str, "%s",
|
||||||
|
oldpkg != NULL ? alpm_pkg_get_version(oldpkg) : "");
|
||||||
|
ret = alpm_list_add(ret, str);
|
||||||
|
}
|
||||||
|
|
||||||
|
pm_asprintf(&str, "%s", alpm_pkg_get_version(pkg));
|
||||||
|
ret = alpm_list_add(ret, str);
|
||||||
|
|
||||||
|
/* and size */
|
||||||
|
size = humanize_size(alpm_pkg_get_size(pkg), 'M', 1, &label);
|
||||||
|
pm_asprintf(&str, "%.2f %s", size, label);
|
||||||
|
ret = alpm_list_add(ret, str);
|
||||||
|
|
||||||
|
return(ret);
|
||||||
|
}
|
||||||
|
|
||||||
/* prepare a list of pkgs to display */
|
/* prepare a list of pkgs to display */
|
||||||
void display_targets(const alpm_list_t *pkgs, int install)
|
void display_targets(const alpm_list_t *pkgs, int install)
|
||||||
{
|
{
|
||||||
|
@ -637,12 +689,13 @@ void display_targets(const alpm_list_t *pkgs, int install)
|
||||||
double size;
|
double size;
|
||||||
const alpm_list_t *i;
|
const alpm_list_t *i;
|
||||||
off_t isize = 0, dlsize = 0;
|
off_t isize = 0, dlsize = 0;
|
||||||
alpm_list_t *targets = NULL;
|
alpm_list_t *j, *lp, *header = NULL, *targets = NULL;
|
||||||
|
|
||||||
if(!pkgs) {
|
if(!pkgs) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* gather pkg infos */
|
||||||
for(i = pkgs; i; i = alpm_list_next(i)) {
|
for(i = pkgs; i; i = alpm_list_next(i)) {
|
||||||
pmpkg_t *pkg = alpm_list_getdata(i);
|
pmpkg_t *pkg = alpm_list_getdata(i);
|
||||||
|
|
||||||
|
@ -651,16 +704,30 @@ void display_targets(const alpm_list_t *pkgs, int install)
|
||||||
}
|
}
|
||||||
isize += alpm_pkg_get_isize(pkg);
|
isize += alpm_pkg_get_isize(pkg);
|
||||||
|
|
||||||
pm_asprintf(&str, "%s-%s", alpm_pkg_get_name(pkg),
|
if(config->verbosepkglists) {
|
||||||
alpm_pkg_get_version(pkg));
|
targets = alpm_list_add(targets, create_verbose_row(pkg, install));
|
||||||
targets = alpm_list_add(targets, str);
|
} else {
|
||||||
|
pm_asprintf(&str, "%s-%s", alpm_pkg_get_name(pkg),
|
||||||
|
alpm_pkg_get_version(pkg));
|
||||||
|
targets = alpm_list_add(targets, str);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* print to screen */
|
||||||
title = install ? _("Targets (%d):") : _("Remove (%d):");
|
title = install ? _("Targets (%d):") : _("Remove (%d):");
|
||||||
pm_asprintf(&str, title, alpm_list_count(pkgs));
|
pm_asprintf(&str, title, alpm_list_count(pkgs));
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
list_display(str, targets);
|
if(config->verbosepkglists) {
|
||||||
|
header = create_verbose_header(install);
|
||||||
|
if(table_display(str, header, targets) != 0) {
|
||||||
|
config->verbosepkglists = 0;
|
||||||
|
display_targets(pkgs, install);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
list_display(str, targets);
|
||||||
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
if(install) {
|
if(install) {
|
||||||
|
@ -675,8 +742,20 @@ void display_targets(const alpm_list_t *pkgs, int install)
|
||||||
printf(_("Total Removed Size: %.2f %s\n"), size, label);
|
printf(_("Total Removed Size: %.2f %s\n"), size, label);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
/* cleanup */
|
||||||
|
if(config->verbosepkglists) {
|
||||||
|
/* targets is a list of lists of strings, free inner lists here */
|
||||||
|
for(j = alpm_list_first(targets); j; j = alpm_list_next(j)) {
|
||||||
|
lp = alpm_list_getdata(j);
|
||||||
|
FREELIST(lp);
|
||||||
|
}
|
||||||
|
alpm_list_free(targets);
|
||||||
|
FREELIST(header);
|
||||||
|
} else {
|
||||||
|
FREELIST(targets);
|
||||||
|
}
|
||||||
free(str);
|
free(str);
|
||||||
FREELIST(targets);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static off_t pkg_get_size(pmpkg_t *pkg)
|
static off_t pkg_get_size(pmpkg_t *pkg)
|
||||||
|
|
Loading…
Add table
Reference in a new issue