diff options
author | Thierry Vignaud <tv@mageia.org> | 2013-02-05 14:31:09 +0000 |
---|---|---|
committer | Thierry Vignaud <tv@mageia.org> | 2013-02-05 14:31:09 +0000 |
commit | 42ac5040258da9cbd0da9bb4f9de6b82ec75a6ec (patch) | |
tree | 2dac54b4101779be0e28ec22de768f8137f03f9a /urpm | |
parent | 424d49c945f5adea3425de2a1a8f173eb0ff82b5 (diff) | |
download | urpmi-42ac5040258da9cbd0da9bb4f9de6b82ec75a6ec.tar urpmi-42ac5040258da9cbd0da9bb4f9de6b82ec75a6ec.tar.gz urpmi-42ac5040258da9cbd0da9bb4f9de6b82ec75a6ec.tar.bz2 urpmi-42ac5040258da9cbd0da9bb4f9de6b82ec75a6ec.tar.xz urpmi-42ac5040258da9cbd0da9bb4f9de6b82ec75a6ec.zip |
(_compute_pkg_total) introduce it in order to count total elements
(run) compute exact total of installed/removed packages
Diffstat (limited to 'urpm')
-rw-r--r-- | urpm/main_loop.pm | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/urpm/main_loop.pm b/urpm/main_loop.pm index d760f412..4d6aba62 100644 --- a/urpm/main_loop.pm +++ b/urpm/main_loop.pm @@ -29,7 +29,7 @@ use urpm::select; use urpm::orphans; use urpm::get_pkgs; use urpm::signature; -use urpm::util qw(difference2 find intersection member partition untaint); +use urpm::util qw(any difference2 find intersection member partition untaint); #- global boolean options my ($auto_select, $no_install, $install_src, $clean, $noclean, $force, $parallel, $test); @@ -309,6 +309,32 @@ sub _run_transaction { !$fatal; } +# computes the number of packages to install or to erase - +# side-effects: urpm->{nb_install} +my $fullname2name_re = qr/^(.*)-[^\-]*-[^\-]*\.[^\.\-]*$/; +sub _compute_pkg_total { + my ($urpm, $state, $options) = @_; + $urpm->{nb_install} = 0; + + # first account for install/erasures we will schedule (upgrades count twice as they involve erasure of the older package): + foreach my $set (@{$state->{transaction} || []}) { + my ($install, $upgrade) = partition { + my $pkg = $urpm->{depslist}[$_]; + $pkg && !$pkg->flag_installed; + } @{$set->{upgrade}}; + my $remove = $options->{'allow-force'} ? [] : $set->{remove} || []; + my ($rm_count, $inst_count, $up_count) = (scalar(@$remove), scalar(values @$install), scalar(keys @$upgrade)); + $urpm->{nb_install} += $rm_count + $inst_count + 2 * $up_count; + } + + # account for erases added by rpm (removal through obsoletes): + foreach my $fn (keys %{$state->{transaction_state}{rejected} || {}}) { + my ($n) = $fn =~ $fullname2name_re; + next if !keys %{$state->{transaction_state}{rejected}{$fn}{obsoleted}}; + $urpm->{nb_install}++ if any { !/^\Q$n/ } keys %{$state->{transaction_state}{rejected}{$fn}{obsoleted}}; + } +} + =item run($urpm, $state, $something_was_to_be_done, $ask_unselect, $_requested, $callbacks) Run the main urpm loop: @@ -399,6 +425,9 @@ sub run { my $migrate_back_rpmdb_db_version = $urpm->{root} && urpm::select::should_we_migrate_back_rpmdb_db_version($urpm, $state); + #- compute package total: + _compute_pkg_total($urpm, $state, $options); + #- now process each remove/install transaction foreach my $set (@{$state->{transaction} || []}) { |