diff options
Diffstat (limited to 'gurpmi2')
-rwxr-xr-x | gurpmi2 | 70 |
1 files changed, 54 insertions, 16 deletions
@@ -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; +} |