summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rwxr-xr-xgurpmi270
-rw-r--r--urpm/download.pm15
3 files changed, 64 insertions, 22 deletions
diff --git a/NEWS b/NEWS
index 2b5df22b..071308ba 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
- urpmi:
o fix displaying "bad signature" in non-utf8 (#44587)
- gurpmi:
+ o overall progress-bar, display the download speed, nicer looking
o [bugfix for 6.15] re-allow to continue on bad signature
Version 6.15 - 7 October 2008
diff --git a/gurpmi2 b/gurpmi2
index faf3c559..d9f761f4 100755
--- a/gurpmi2
+++ b/gurpmi2
@@ -16,6 +16,7 @@ use urpm::media;
use urpm::signature;
use urpm::get_pkgs;
use urpm::msg;
+use urpm::util;
use urpm::select;
use urpm::main_loop;
use Gtk2;
@@ -66,12 +67,14 @@ $> and fatal(N("Must be root"));
Gtk2->init;
Gtk2->croak_execeptions;
+my $title = $::auto_select ? N("Distribution Upgrade") : N("Packages installation");
+
#- Create main window
$mainw = Gtk2::Window->new('toplevel');
$::main_window = $mainw;
-$mainw->set_border_width(3);
-$mainw->set_title(N("RPM installation"));
+$mainw->set_border_width(12);
+$mainw->set_title($title);
$mainw->signal_connect(destroy => \&quit);
$mainw->set_position('center');
$mainw->set_default_size($progressbar_size, 60);
@@ -91,6 +94,8 @@ if (@gurpmi::names) {
) || $force or exit 1;
}
+wait_label(N("Preparing packages installation..."));
+
#- return value is true if program should be restarted (in order to take care of important
#- packages being upgraded (problably urpmi and perl-URPM, but maybe rpm too, and glibc also ?).
my $restart_itself = urpm::select::resolve_dependencies($urpm,
@@ -247,31 +252,51 @@ sub do_install_2 () {
}
sub do_install_3 () {
- wait_label(N("Package installation..."));
+ wait_label($title);
my ($local_sources, $blists) = urpm::get_pkgs::selected2local_and_blists($urpm, $state->{selected});
$local_sources || $blists or $urpm->{fatal}(3, N("unable to get source packages, aborting"));
my $vbox = Gtk2::VBox->new(0, 5);
- my $progress_label = Gtk2::Label->new('-');
+
+ my $global_label = gtk_new_Label_Left("<b>$title</b>");
+ $global_label->set_use_markup(1);
+ $vbox->pack_start($global_label, 0, 0, 0);
+
+ my $global_progressbar = Gtk2::ProgressBar->new;
+ $vbox->pack_start($global_progressbar, 0, 0, 0);
+
+ my $progress_label = gtk_new_Label_Left('-');
$vbox->pack_start($progress_label, 1, 1, 0);
+
+
my $progressbar = Gtk2::ProgressBar->new;
$progressbar->set_size_request($progressbar_size, -1);
$vbox->pack_start($progressbar, 0, 0, 0);
+
change_mainw($vbox);
- my $progress_nb;
+ my ($progress_nb, $download_nb);
+ my $set_progressbar = sub {
+ my ($local_ratio) = @_;
+ if ($progress_nb || $download_nb) { # this happens when computing transaction
+ $global_progressbar->set_fraction(($download_nb + $progress_nb - 1 + $local_ratio) / 2 / $urpm->{nb_install});
+ }
+ $progressbar->set_fraction($local_ratio);
+ };
my $callback_inst = sub {
my ($urpm, $type, $id, $subtype, $amount, $total) = @_;
my $pkg = defined $id ? $urpm->{depslist}[$id] : undef;
if ($subtype eq 'start') {
if ($type eq 'trans') {
$progress_label->set_label(N("Preparing..."));
- } else {
- defined $pkg
- and $progress_label->set_label(
- N("Installing package `%s' (%s/%s)...", $pkg->name, ++$progress_nb, $urpm->{nb_install})
- );
+ } elsif ($pkg) {
+ $progress_nb++;
+ $download_nb = max($download_nb, $progress_nb);
+ $set_progressbar->(0);
+ $progress_label->set_label(
+ N("Installing package `%s' (%s/%s)...", $pkg->name, $progress_nb, $urpm->{nb_install})
+ );
}
} elsif ($subtype eq 'progress') {
- $progressbar->set_fraction($amount / $total);
+ $set_progressbar->($amount / $total);
}
sync();
};
@@ -292,15 +317,20 @@ sub do_install_3 () {
1;
},
trans_log => sub {
- my ($mode, $file, $percent) = @_;
+ my ($mode, $file, $percent, $total, $eta, $speed) = @_;
+
+ if (member($mode, 'start', 'progress')) {
+ $file =~ s|/*\s*$||; $file =~ s|.*/||;
+ $progress_label->set_label(N("Downloading package `%s'...", $file) . "\n" . &urpm::download::progress_text);
+ }
if ($mode eq 'start') {
- $file =~ s|/*\s*$||; $file =~ s|.*/||;
- $progress_label->set_label(N("Downloading package `%s'...", $file));
+ $download_nb++;
+ $set_progressbar->(0);
select(undef, undef, undef, 0.1); #- hackish
} elsif ($mode eq 'progress') {
- $progressbar->set_fraction($percent / 100);
+ $set_progressbar->($percent / 100);
} elsif ($mode eq 'end') {
- $progressbar->set_fraction(1);
+ $set_progressbar->(1);
}
sync();
},
@@ -361,3 +391,11 @@ sub do_install_3 () {
}
exit $exit_code;
}
+
+sub gtk_new_Label_Left {
+ my ($text) = @_;
+ my $w = Gtk2::Label->new($text);
+ $w->set_alignment(0, 0);
+ $w->set_padding(6, 0);
+ $w;
+}
diff --git a/urpm/download.pm b/urpm/download.pm
index db844d41..e8c5a950 100644
--- a/urpm/download.pm
+++ b/urpm/download.pm
@@ -750,18 +750,21 @@ eval {
--$wchar;
};
+sub progress_text {
+ my ($mode, $file, $percent, $total, $eta, $speed) = @_;
+ $mode eq 'progress' ?
+ (defined $total && defined $eta ?
+ N(" %s%% of %s completed, ETA = %s, speed = %s", $percent, $total, $eta, $speed) :
+ N(" %s%% completed, speed = %s", $percent, $speed)) : '';
+}
+
#- default logger suitable for sync operation on STDERR only.
sub sync_logger {
my ($mode, $file, $percent, $total, $eta, $speed) = @_;
if ($mode eq 'start') {
print STDERR " $file\n";
} elsif ($mode eq 'progress') {
- my $text;
- if (defined $total && defined $eta) {
- $text = N(" %s%% of %s completed, ETA = %s, speed = %s", $percent, $total, $eta, $speed);
- } else {
- $text = N(" %s%% completed, speed = %s", $percent, $speed);
- }
+ my $text = &progress_text;
if (length($text) > $wchar) { $text = substr($text, 0, $wchar) }
if (bytes::length($text) < $wchar) {
# clearing more than needed in case the terminal is not handling utf8 and we have a utf8 string