[pacman-dev] [PATCH] [RFC] pacman -Si/-Qi: Autodetect best fitting file size unit
I've tracked this back to e223366 and it looks like this just forces KiB because back then humanize_size didn't exist, but the size was just divided by 1024 to keep it somewhat readable. When humanize_size got introduced in 3c8a448 this was just carried over. Signed-off-by: Florian Pritz <bluewind@xinu.at> --- Similar to this -Su also forces units to MiB, but I'm unsure if this should be changed since -Su outputs a nice table and having everything in the same unit makes comparing packages easier. Any input on this patch and the -Su situation would be welcome. src/pacman/package.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pacman/package.c b/src/pacman/package.c index eab2873..b10207b 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -165,7 +165,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) deplist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg), cols); deplist_display(_("Replaces :"), alpm_pkg_get_replaces(pkg), cols); - size = humanize_size(alpm_pkg_get_size(pkg), 'K', 2, &label); + size = humanize_size(alpm_pkg_get_size(pkg), '\0', 2, &label); if(from == ALPM_PKG_FROM_SYNCDB) { printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Download Size :"), config->colstr.nocolor, size, label); @@ -174,7 +174,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) config->colstr.nocolor, size, label); } - size = humanize_size(alpm_pkg_get_isize(pkg), 'K', 2, &label); + size = humanize_size(alpm_pkg_get_isize(pkg), '\0', 2, &label); printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Installed Size :"), config->colstr.nocolor, size, label); -- 1.8.4
On 17/10/13 21:55, Florian Pritz wrote:
I've tracked this back to e223366 and it looks like this just forces KiB because back then humanize_size didn't exist, but the size was just divided by 1024 to keep it somewhat readable. When humanize_size got introduced in 3c8a448 this was just carried over.
Signed-off-by: Florian Pritz <bluewind@xinu.at> ---
Similar to this -Su also forces units to MiB, but I'm unsure if this should be changed since -Su outputs a nice table and having everything in the same unit makes comparing packages easier.
Any input on this patch and the -Su situation would be welcome.
I'd be fine with this patch but think -Su should stay the same. Any other comments here?
src/pacman/package.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/pacman/package.c b/src/pacman/package.c index eab2873..b10207b 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -165,7 +165,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) deplist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg), cols); deplist_display(_("Replaces :"), alpm_pkg_get_replaces(pkg), cols);
- size = humanize_size(alpm_pkg_get_size(pkg), 'K', 2, &label); + size = humanize_size(alpm_pkg_get_size(pkg), '\0', 2, &label); if(from == ALPM_PKG_FROM_SYNCDB) { printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Download Size :"), config->colstr.nocolor, size, label); @@ -174,7 +174,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) config->colstr.nocolor, size, label); }
- size = humanize_size(alpm_pkg_get_isize(pkg), 'K', 2, &label); + size = humanize_size(alpm_pkg_get_isize(pkg), '\0', 2, &label); printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Installed Size :"), config->colstr.nocolor, size, label);
On Fri, Oct 18, 2013 at 10:01:10PM +1000, Allan McRae wrote:
On 17/10/13 21:55, Florian Pritz wrote:
I've tracked this back to e223366 and it looks like this just forces KiB because back then humanize_size didn't exist, but the size was just divided by 1024 to keep it somewhat readable. When humanize_size got introduced in 3c8a448 this was just carried over.
Signed-off-by: Florian Pritz <bluewind@xinu.at> ---
Similar to this -Su also forces units to MiB, but I'm unsure if this should be changed since -Su outputs a nice table and having everything in the same unit makes comparing packages easier.
Any input on this patch and the -Su situation would be welcome.
I'd be fine with this patch but think -Su should stay the same. Any other comments here?
I dislike this because it can lead to the installed and download sizes having different units, e.g. $ ./pacman -Si sage-mathematics ... Download Size : 370.22 MiB Installed Size : 2.21 GiB ... And this could probably only get weirder when you have multiple packages in the output. Having a consistent unit size here when humanize_size was introduced was likely an intentional non-change.
src/pacman/package.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/pacman/package.c b/src/pacman/package.c index eab2873..b10207b 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -165,7 +165,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) deplist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg), cols); deplist_display(_("Replaces :"), alpm_pkg_get_replaces(pkg), cols);
- size = humanize_size(alpm_pkg_get_size(pkg), 'K', 2, &label); + size = humanize_size(alpm_pkg_get_size(pkg), '\0', 2, &label); if(from == ALPM_PKG_FROM_SYNCDB) { printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Download Size :"), config->colstr.nocolor, size, label); @@ -174,7 +174,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) config->colstr.nocolor, size, label); }
- size = humanize_size(alpm_pkg_get_isize(pkg), 'K', 2, &label); + size = humanize_size(alpm_pkg_get_isize(pkg), '\0', 2, &label); printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Installed Size :"), config->colstr.nocolor, size, label);
I've tracked this back to e223366 and it looks like this just forces KiB because back then humanize_size didn't exist, but the size was just divided by 1024 to keep it somewhat readable. When humanize_size got introduced in 3c8a448 this was just carried over. The unit detected for "Download Size" is reused for "Installed Size" to make it easier to read. Signed-off-by: Florian Pritz <bluewind@xinu.at> --- v2: use same unit for both sizes src/pacman/package.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pacman/package.c b/src/pacman/package.c index eab2873..decb435 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -165,7 +165,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) deplist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg), cols); deplist_display(_("Replaces :"), alpm_pkg_get_replaces(pkg), cols); - size = humanize_size(alpm_pkg_get_size(pkg), 'K', 2, &label); + size = humanize_size(alpm_pkg_get_size(pkg), '\0', 2, &label); if(from == ALPM_PKG_FROM_SYNCDB) { printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Download Size :"), config->colstr.nocolor, size, label); @@ -174,7 +174,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) config->colstr.nocolor, size, label); } - size = humanize_size(alpm_pkg_get_isize(pkg), 'K', 2, &label); + size = humanize_size(alpm_pkg_get_isize(pkg), label[0], 2, &label); printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Installed Size :"), config->colstr.nocolor, size, label); -- 1.8.4
On Fri, Oct 18, 2013 at 05:09:08PM +0200, Florian Pritz wrote:
I've tracked this back to e223366 and it looks like this just forces KiB because back then humanize_size didn't exist, but the size was just divided by 1024 to keep it somewhat readable. When humanize_size got introduced in 3c8a448 this was just carried over.
The unit detected for "Download Size" is reused for "Installed Size" to make it easier to read.
Signed-off-by: Florian Pritz <bluewind@xinu.at> ---
Just a thought, but maybe have this customizable. Possibly a conf file option to use a certain unit or not use human_size at all.
v2: use same unit for both sizes
src/pacman/package.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/pacman/package.c b/src/pacman/package.c index eab2873..decb435 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -165,7 +165,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) deplist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg), cols); deplist_display(_("Replaces :"), alpm_pkg_get_replaces(pkg), cols);
- size = humanize_size(alpm_pkg_get_size(pkg), 'K', 2, &label); + size = humanize_size(alpm_pkg_get_size(pkg), '\0', 2, &label); if(from == ALPM_PKG_FROM_SYNCDB) { printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Download Size :"), config->colstr.nocolor, size, label); @@ -174,7 +174,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) config->colstr.nocolor, size, label); }
- size = humanize_size(alpm_pkg_get_isize(pkg), 'K', 2, &label); + size = humanize_size(alpm_pkg_get_isize(pkg), label[0], 2, &label); printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Installed Size :"), config->colstr.nocolor, size, label);
-- 1.8.4
-- William Giokas | KaiSforza | http://kaictl.net/ GnuPG Key: 0x73CD09CF Fingerprint: F73F 50EF BBE2 9846 8306 E6B8 6902 06D8 73CD 09CF
On 19/10/13 05:34, William Giokas wrote:
On Fri, Oct 18, 2013 at 05:09:08PM +0200, Florian Pritz wrote:
I've tracked this back to e223366 and it looks like this just forces KiB because back then humanize_size didn't exist, but the size was just divided by 1024 to keep it somewhat readable. When humanize_size got introduced in 3c8a448 this was just carried over.
The unit detected for "Download Size" is reused for "Installed Size" to make it easier to read.
Signed-off-by: Florian Pritz <bluewind@xinu.at> ---
Just a thought, but maybe have this customizable. Possibly a conf file option to use a certain unit or not use human_size at all.
No - this is not worth a configure option.
v2: use same unit for both sizes
src/pacman/package.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/pacman/package.c b/src/pacman/package.c index eab2873..decb435 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -165,7 +165,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) deplist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg), cols); deplist_display(_("Replaces :"), alpm_pkg_get_replaces(pkg), cols);
- size = humanize_size(alpm_pkg_get_size(pkg), 'K', 2, &label); + size = humanize_size(alpm_pkg_get_size(pkg), '\0', 2, &label); if(from == ALPM_PKG_FROM_SYNCDB) { printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Download Size :"), config->colstr.nocolor, size, label); @@ -174,7 +174,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) config->colstr.nocolor, size, label); }
- size = humanize_size(alpm_pkg_get_isize(pkg), 'K', 2, &label); + size = humanize_size(alpm_pkg_get_isize(pkg), label[0], 2, &label); printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Installed Size :"), config->colstr.nocolor, size, label);
-- 1.8.4
On 19/10/13 01:09, Florian Pritz wrote:
I've tracked this back to e223366 and it looks like this just forces KiB because back then humanize_size didn't exist, but the size was just divided by 1024 to keep it somewhat readable. When humanize_size got introduced in 3c8a448 this was just carried over.
The unit detected for "Download Size" is reused for "Installed Size" to make it easier to read.
Signed-off-by: Florian Pritz <bluewind@xinu.at> ---
Test suite failure: FAIL: test/pacman/tests/query006 ================================ 1..1 # Running 'query006' # ==> Generating test environment # ==> Running test # ==> Checking rules 1..6 ok 1 - PACMAN_RETCODE=0 ok 2 - PACMAN_OUTPUT=^Name.*overflow ok 3 - PACMAN_OUTPUT=^Description.*Overflow size and date values if possible not ok 4 - PACMAN_OUTPUT=^Installed Size.*9765625.00 KiB ok 5 - PACMAN_OUTPUT=^Build Date.* 2065 ok 6 - PACMAN_OUTPUT=^Install Date.* 2286 not ok 1 - Query info on a package (overflow long values) FAIL: test/pacman/tests/query006.py 1 - Query info on a package (overflow long values)
v2: use same unit for both sizes
src/pacman/package.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/pacman/package.c b/src/pacman/package.c index eab2873..decb435 100644 --- a/src/pacman/package.c +++ b/src/pacman/package.c @@ -165,7 +165,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) deplist_display(_("Conflicts With :"), alpm_pkg_get_conflicts(pkg), cols); deplist_display(_("Replaces :"), alpm_pkg_get_replaces(pkg), cols);
- size = humanize_size(alpm_pkg_get_size(pkg), 'K', 2, &label); + size = humanize_size(alpm_pkg_get_size(pkg), '\0', 2, &label); if(from == ALPM_PKG_FROM_SYNCDB) { printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Download Size :"), config->colstr.nocolor, size, label); @@ -174,7 +174,7 @@ void dump_pkg_full(alpm_pkg_t *pkg, int extra) config->colstr.nocolor, size, label); }
- size = humanize_size(alpm_pkg_get_isize(pkg), 'K', 2, &label); + size = humanize_size(alpm_pkg_get_isize(pkg), label[0], 2, &label); printf("%s%s%s %6.2f %s\n", config->colstr.title, _("Installed Size :"), config->colstr.nocolor, size, label);
participants (4)
-
Allan McRae
-
Dave Reisner
-
Florian Pritz
-
William Giokas