summaryrefslogtreecommitdiffstats
path: root/src/pacman/query.c
diff options
context:
space:
mode:
authorNathan Jones <nathanj@insightbb.com>2007-05-14 07:21:42 +0200
committerDan McGee <dan@archlinux.org>2007-05-14 07:22:15 +0200
commit5c930c318e7b80af3a322ddc7ddf9fe100e9c16b (patch)
treef0a5480fe7d324f8c66041ed36699c9168259f58 /src/pacman/query.c
parent14c768365cc32659d0adf0887f93c39d340089fc (diff)
downloadpacman-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/query.c')
-rw-r--r--src/pacman/query.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/pacman/query.c b/src/pacman/query.c
index dcb7c6bb..bb4cfb9d 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -146,7 +146,17 @@ int pacman_query(alpm_list_t *targets)
alpm_list_t *grp;
pmpkg_t *pkg = alpm_list_getdata(i);
- printf("local/%s %s", 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("local/%s %s [%.2f MB]", alpm_pkg_get_name(pkg),
+ alpm_pkg_get_version(pkg), mbsize);
+ } else {
+ printf("local/%s %s", alpm_pkg_get_name(pkg),
+ alpm_pkg_get_version(pkg));
+ }
if((grp = alpm_pkg_get_groups(pkg)) != NULL) {
group = alpm_list_getdata(grp);