summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS3
-rw-r--r--urpm/msg.pm49
-rwxr-xr-xurpmi32
3 files changed, 62 insertions, 22 deletions
diff --git a/NEWS b/NEWS
index 65c4d602..d3472e29 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+- urpmi
+ o enhance "columns" display of packages to install (esp. fit on 80 columns)
+
Version 4.10.7 - 6 September 2007, by Pascal "Pixel" Rigaux
- urpmi
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) = @_;
diff --git a/urpmi b/urpmi
index 03e96541..52a321bd 100755
--- a/urpmi
+++ b/urpmi
@@ -25,7 +25,7 @@ use urpm::args;
use urpm::msg;
use urpm::media;
use urpm::select;
-use urpm::util qw(max untaint difference2 member partition);
+use urpm::util qw(untaint difference2 member partition);
use urpm::main_loop;
#- contains informations to parse installed system.
@@ -569,47 +569,35 @@ have to be removed for others to be upgraded:\n%s\n", $list);
}
}
-#- package to install as a array of strings.
-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 @root_only;
-foreach my $pkg (sort { $a->name cmp $b->name } @{$urpm->{depslist}}[keys %{$state->{selected}}]) {
+my @to_install = @{$urpm->{depslist}}[sort { $a <=> $b } keys %{$state->{selected}}]; # sorted by medium for format_selected_packages
+foreach my $pkg (@to_install) {
#- reflect change in flag usage, now requested is set whatever a package is selected or not,
#- but required is always set (so a required but not requested is a pure dependency).
$ask_user ||= !$pkg->flag_requested || $auto_select || $parallel;
if (!$env && $install_src && $pkg->arch ne 'src') {
push @root_only, $pkg->fullname;
- } elsif ($install_src || $pkg->arch ne 'src') {
- my $medium = URPM::pkg2media($urpm->{media}, $pkg);
- my @name_and_evr = ($pkg->fullname, $medium && $medium->{name});
- $name_and_evr[2] =~ s/mdv(.*)/mdv/ if length($name_and_evr[2]) > 15;
- if ($state->{selected}{$pkg->id}{suggested}) {
- push @name_and_evr, N("(suggested)");
- }
- push @to_install, \@name_and_evr;
}
}
-$urpm->{nb_install} = @to_install;
if (@root_only && !$env) {
- print N("You need to be root to install the following dependencies:\n%s\n", join ' ', @root_only);
+ print N("You need to be root to install the following dependencies:\n%s\n", join(' ', sort @root_only));
exit 1;
-} elsif (!$urpm->{options}{auto} && $ask_user && $urpm->{nb_install} || $env) {
+}
+$urpm->{nb_install} = @to_install;
+if (!$urpm->{options}{auto} && $ask_user && $urpm->{nb_install} || $env) {
my $msg = $urpm->{nb_install} == 1 ? N("To satisfy dependencies, the following package is going to be installed:")
: N("To satisfy dependencies, the following packages are going to be installed:");
if ($test) {
$msg = "$msg\n" . N("(test only, installation will not be actually done)");
}
- my $size = $urpm->selected_size($state);
- my @field_sizes = map { my $i = $_; max(map { length($_->[$i]) } @to_install) } 0 .. 5;
- my @field_nice_sizes = (40, 10, 14, 6, 15, 15);
- { my $i; foreach (@field_sizes) { $_++ if $_ <= $field_nice_sizes[$i++] } }
- my $format = join(' ', map { '%-' . $_ . 's' } @field_sizes);
- my @to_install_formatted = map { sprintf(" $format", @$_) } @to_install;
+ my $size = $urpm->selected_size($state);
+
+ my @to_install_formatted = urpm::msg::format_line_selected_packages($urpm, $state, \@to_install);
my $msg2 = $size >= 0 ?
N("%s of additional disk space will be used.", formatXiB($size)) :
N("%s of disk space will be freed.", formatXiB(-$size));