diff options
author | Nathan Jones <nathanj@insightbb.com> | 2007-05-14 07:21:42 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2007-05-14 07:22:15 +0200 |
commit | 5c930c318e7b80af3a322ddc7ddf9fe100e9c16b (patch) | |
tree | f0a5480fe7d324f8c66041ed36699c9168259f58 /src/pacman/sync.c | |
parent | 14c768365cc32659d0adf0887f93c39d340089fc (diff) | |
download | pacman-5c930c318e7b80af3a322ddc7ddf9fe100e9c16b.tar.gz pacman-5c930c318e7b80af3a322ddc7ddf9fe100e9c16b.tar.xz |
Display size for packages
This patch adds a -z|--showsize option to the -Q and -S commands. The
option displays the size of individual packages. This is something that
I have wanted for a while, and there is a feature request for it.
Signed-off-by: Nathan Jones <nathanj@insightbb.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src/pacman/sync.c')
-rw-r--r-- | src/pacman/sync.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/pacman/sync.c b/src/pacman/sync.c index 1b629429..4f11bb4c 100644 --- a/src/pacman/sync.c +++ b/src/pacman/sync.c @@ -251,8 +251,19 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets) alpm_list_t *grp; pmpkg_t *pkg = alpm_list_getdata(j); - printf("%s/%s %s", alpm_db_get_name(db), alpm_pkg_get_name(pkg), - alpm_pkg_get_version(pkg)); + /* print the package size with the output if -z option passed */ + if(config->showsize) { + /* Convert byte size to MB */ + double mbsize = alpm_pkg_get_size(pkg) / (1024.0 * 1024.0); + + printf("%s/%s %s [%.2f MB]", alpm_db_get_name(db), + alpm_pkg_get_name(pkg), + alpm_pkg_get_version(pkg), mbsize); + } else { + printf("%s/%s %s", alpm_db_get_name(db), + alpm_pkg_get_name(pkg), + alpm_pkg_get_version(pkg)); + } if((grp = alpm_pkg_get_groups(pkg)) != NULL) { group = alpm_list_getdata(grp); |