diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2007-09-06 09:30:35 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2007-09-06 09:30:35 +0000 |
commit | 2040dc02c0235615eb575704931c8bc020781eae (patch) | |
tree | 81987f3bdea7032f102e9572cc077157944b42d8 /urpm/msg.pm | |
parent | 7ba761dec0070ad2ae1aa7849a4d7d6cf1d9e2dc (diff) | |
download | urpmi-2040dc02c0235615eb575704931c8bc020781eae.tar urpmi-2040dc02c0235615eb575704931c8bc020781eae.tar.gz urpmi-2040dc02c0235615eb575704931c8bc020781eae.tar.bz2 urpmi-2040dc02c0235615eb575704931c8bc020781eae.tar.xz urpmi-2040dc02c0235615eb575704931c8bc020781eae.zip |
- urpmi
o display size that will be installed - removed
- urpmi, urpme
o use best unit (KB, MB...) to display size will be installed - removed
for this, use ->selected_size from perl-URPM
and import formatXiB from drakx common.pm
Diffstat (limited to 'urpm/msg.pm')
-rw-r--r-- | urpm/msg.pm | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/urpm/msg.pm b/urpm/msg.pm index e8a1a503..b5063d1e 100644 --- a/urpm/msg.pm +++ b/urpm/msg.pm @@ -15,7 +15,7 @@ BEGIN { (our $VERSION) = q($Revision$) =~ /(\d+)/; our @ISA = 'Exporter'; -our @EXPORT = qw(N P translate bug_log message_input toMb sys_log); +our @EXPORT = qw(N P translate bug_log message_input toMb formatXiB sys_log); #- I18N. use Locale::gettext; @@ -119,6 +119,29 @@ sub toMb { int $nb + 0.5; } +# duplicated from svn+ssh://svn.mandriva.com/svn/soft/drakx/trunk/perl-install/common.pm +sub formatXiB { + my ($newnb, $o_newbase) = @_; + warn "$newnb x\n"; + my $newbase = $o_newbase || 1; + my ($nb, $base); + my $decr = sub { + ($nb, $base) = ($newnb, $newbase); + $base >= 1024 ? ($newbase = $base / 1024) : ($newnb = $nb / 1024); + }; + my $suffix; + foreach (N("B"), N("KB"), N("MB"), N("GB"), N("TB")) { + $decr->(); + if ($newnb < 1 && $newnb * $newbase < 1) { + $suffix = $_; + last; + } + } + my $v = $nb * $base; + my $s = $v < 10 && int(10 * $v - 10 * int($v)); + int($v) . ($s ? ".$s" : '') . ($suffix || N("TB")); +} + sub localtime2changelog { scalar(localtime($_[0])) =~ /(.*) \S+ (\d{4})$/ && "$1 $2" } 1; |