diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | urpm/msg.pm | 25 | ||||
-rw-r--r-- | urpme | 8 | ||||
-rwxr-xr-x | urpmi | 4 |
4 files changed, 30 insertions, 10 deletions
@@ -2,6 +2,9 @@ o fix rpmdb locking with --root o handle --searchmedia <media1>,...,<mediaN> o do auto upgrade mandriva kernels (ie remove kernel*-latest to skip.list) + o display size that will be installed - removed +- urpmi, urpme + o use best unit (KB, MB...) to display size will be installed - removed Version 4.10.6 - 28 August 2007, by Pascal "Pixel" Rigaux 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; @@ -122,15 +122,11 @@ if ($test && $auto) { #- Warning : the following message is parsed in urpm::parallel_* my $msg = N("Checking to remove the following packages"); print STDOUT "$msg:\n$list\n"; -} elsif (($parallel || @toremove > @l) && !$auto) { - my $sum = 0; - foreach (@toremove) { - $sum += $state->{rejected}{$_}{size}; - } +} elsif (($parallel || @toremove > @l) && !$auto || 1) { my $msg = P("To satisfy dependencies, the following package will be removed", "To satisfy dependencies, the following %d packages will be removed", - scalar(@toremove), scalar(@toremove)) . N(" (%d MB)", toMb($sum)); + scalar(@toremove), scalar(@toremove)) . sprintf(" (%s)", formatXiB(-$urpm->selected_size($state))); print STDOUT "$msg:\n$list\n"; message_input(P("Remove %d package?", "Remove %d packages?", scalar(@toremove), scalar(@toremove)) . N(" (y/N) "), $force && $yesexpr, boolean => 1) =~ /[$yesexpr]/ or exit 0; } @@ -575,7 +575,6 @@ my @to_install; #- check if there is at least one package to install that #- has not been given by the user. my $ask_user = $env || $search_result eq 'substring'; -my $sum = 0; my @root_only; foreach my $pkg (sort { $a->name cmp $b->name } @{$urpm->{depslist}}[keys %{$state->{selected}}]) { @@ -587,7 +586,6 @@ foreach my $pkg (sort { $a->name cmp $b->name } @{$urpm->{depslist}}[keys %{$sta if (!$env && $install_src && $pkg->arch ne 'src') { push @root_only, $fullname; } elsif ($install_src || $pkg->arch ne 'src') { - $sum += $pkg->size; if ($state->{selected}{$pkg->id}{suggested}) { $fullname = N("%s (suggested)", $fullname); } @@ -607,7 +605,7 @@ if (@root_only && !$env) { my $msg2 = P("Proceed with the installation of one package?", "Proceed with the installation of the %d packages?", $urpm->{nb_install}, $urpm->{nb_install}) - . N(" (%d MB)", toMb($sum)); + . sprintf(" (%s)", formatXiB($urpm->selected_size($state))); my $p = join "\n", @to_install; if ($env && !$options{debug__do_not_install}) { print "$msg\n$p\n$msg2\n"; |