summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-09-06 09:30:35 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-09-06 09:30:35 +0000
commit2040dc02c0235615eb575704931c8bc020781eae (patch)
tree81987f3bdea7032f102e9572cc077157944b42d8
parent7ba761dec0070ad2ae1aa7849a4d7d6cf1d9e2dc (diff)
downloadurpmi-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
-rw-r--r--NEWS3
-rw-r--r--urpm/msg.pm25
-rw-r--r--urpme8
-rwxr-xr-xurpmi4
4 files changed, 30 insertions, 10 deletions
diff --git a/NEWS b/NEWS
index 1de8eac0..fbb6ce04 100644
--- a/NEWS
+++ b/NEWS
@@ -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;
diff --git a/urpme b/urpme
index 7ab603e1..05e94e31 100644
--- a/urpme
+++ b/urpme
@@ -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;
}
diff --git a/urpmi b/urpmi
index 8b6b6105..2d64d111 100755
--- a/urpmi
+++ b/urpmi
@@ -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";