diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2007-09-07 14:08:04 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2007-09-07 14:08:04 +0000 |
commit | 379179afcd2a68ff3d315357031cfbf6563dfc98 (patch) | |
tree | fb4004b86c405e64721b82a1a5eb32f44a6df306 /urpm | |
parent | ddc3808f569c456ec97c80892f8d38fff285ee58 (diff) | |
download | urpmi-379179afcd2a68ff3d315357031cfbf6563dfc98.tar urpmi-379179afcd2a68ff3d315357031cfbf6563dfc98.tar.gz urpmi-379179afcd2a68ff3d315357031cfbf6563dfc98.tar.bz2 urpmi-379179afcd2a68ff3d315357031cfbf6563dfc98.tar.xz urpmi-379179afcd2a68ff3d315357031cfbf6563dfc98.zip |
- urpmi
o enhance "columns" display of packages to install (esp. fit on 80 columns)
Diffstat (limited to 'urpm')
-rw-r--r-- | urpm/msg.pm | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/urpm/msg.pm b/urpm/msg.pm index 247ede7b..dcb99056 100644 --- a/urpm/msg.pm +++ b/urpm/msg.pm @@ -119,6 +119,55 @@ sub toMb { int $nb + 0.5; } +my @format_line_field_sizes = (30, 12, 13, 7, 0); +my $format_line_format = ' ' . join(' ', map { '%-' . $_ . 's' } @format_line_field_sizes); + +sub format_line_selected_packages { + my ($urpm, $state, $pkgs) = @_; + + my (@pkgs, @lines, $prev_medium); + my $flush = sub { + push @lines, _format_line_selected_packages($state, $prev_medium, \@pkgs); + @pkgs = (); + }; + foreach my $pkg (@$pkgs) { + my $medium = URPM::pkg2media($urpm->{media}, $pkg); + if ($prev_medium && $prev_medium ne $medium) { + $flush->(); + } + push @pkgs, $pkg; + $prev_medium = $medium; + } + $flush->(); + + (sprintf($format_line_format, map { " $_" } N("Package"), N("Version"), N("Release"), N("Arch")), + @lines); +} +sub _format_line_selected_packages { + my ($state, $medium, $pkgs) = @_; + + my @l = map { + my @name_and_evr = $_->fullname; + if ($state->{selected}{$_->id}{suggested}) { + push @name_and_evr, N("(suggested)"); + } + \@name_and_evr; + } sort { $a->name cmp $b->name } @$pkgs; + + my $i; + foreach my $max (@format_line_field_sizes) { + foreach (@l) { + if ($max && length($_->[$i]) > $max) { + $_->[$i] = substr($_->[$i], 0, $max-1) . '*'; + } + } + $i++; + } + + ('(' . ($medium ? N("medium \"%s\"", $medium->{name}) : N("command line")) . ')', + map { sprintf($format_line_format, @$_) } @l); +} + # duplicated from svn+ssh://svn.mandriva.com/svn/soft/drakx/trunk/perl-install/common.pm sub formatXiB { my ($newnb, $o_newbase) = @_; |