diff options
author | Francois Pons <fpons@mandriva.com> | 2003-06-16 18:05:35 +0000 |
---|---|---|
committer | Francois Pons <fpons@mandriva.com> | 2003-06-16 18:05:35 +0000 |
commit | 07f01970048de8314c51781c6a577191b258bbf7 (patch) | |
tree | 4ff13cffffafae22cfb19360933073c5aed8c1de /urpmi | |
parent | 254d9d92ea1755216fa5f7bfdfe0ff5ee44f27a8 (diff) | |
download | urpmi-07f01970048de8314c51781c6a577191b258bbf7.tar urpmi-07f01970048de8314c51781c6a577191b258bbf7.tar.gz urpmi-07f01970048de8314c51781c6a577191b258bbf7.tar.bz2 urpmi-07f01970048de8314c51781c6a577191b258bbf7.tar.xz urpmi-07f01970048de8314c51781c6a577191b258bbf7.zip |
4.4-1mdk
Diffstat (limited to 'urpmi')
-rwxr-xr-x | urpmi | 368 |
1 files changed, 196 insertions, 172 deletions
@@ -386,6 +386,7 @@ $urpm->resolve_dependencies($state, \%requested, callback_choices => \&ask_choice, install_src => $install_src, nodeps => $urpm->{options}{'allow-nodeps'} || $urpm->{options}{'allow-force'}, + split_level => 1, ); my @ask_unselect = $urpm->unselected_packages($state); @@ -475,7 +476,8 @@ if (@root_only) { #- if not root, the list become invisible and no download will be possible. my ($local_sources, $list) = $urpm->get_source_packages($state->{selected}, - clean_all => $clean, clean_other => !$noclean && $urpm->{options}{'pre-clean'}); + clean_all => $clean, + clean_other => !$noclean && $urpm->{options}{'pre-clean'}); unless ($local_sources || $list) { $urpm->{fatal}(3, N("unable to get source packages, aborting")); } @@ -484,207 +486,229 @@ if ($X) { require gurpm; gurpm::init(N("Package installation..."), N("Initializing...")); } -my %sources = $urpm->download_source_packages($local_sources, $list, + +my %sources = %$local_sources; +my %error_sources; + +$urpm->exlock_urpmi_db; +$urpm->copy_packages_of_removable_media($list, \%sources, + verbose => $verbose > 0, + force_local => 1, + ask_for_medium => (!$auto || $allow_medium_change) && sub { + my $msg = N("Please insert the medium named \"%s\" on device [%s]", @_); + my $msg2 = N("Press Enter when ready..."); + if ($X) { + $msg =~ s/"/\\"/g; + gmessage($msg); + !$?; + } else { + defined message_input("$msg\n$msg2 "); + } + }); + +foreach my $set (@{$state->{transaction} || []}) { + my (@transaction_list, %transaction_sources); + + #- prepare transaction... + $urpm->prepare_transaction($set, $list, \%sources, \@transaction_list, \%transaction_sources); + + #- first, filter out what is really needed to download for this small transaction. + $urpm->download_packages_of_distant_media($list, \%transaction_sources, \%error_sources, verbose => $verbose > 0, limit_rate => $urpm->{options}{'limit-rate'}, + force_local => 1, callback => sub { my ($mode, $file, $percent, $total, $eta, $speed) = @_; - if ($X) { - if ($mode eq 'start') { - $file =~ s|/*\s*$||; $file =~ s|.*/||; - gurpm::label(N("Downloading package `%s'...", $file)); - } elsif ($mode eq 'progress') { - gurpm::progress($percent/100); - } elsif ($mode eq 'end') { - gurpm::progress(1); - } - } else { - if ($mode eq 'start') { - print STDERR " $file\n"; #- allow pass-protected url to be logged. - } elsif ($mode eq 'progress') { - if (defined $total && defined $eta) { - print SAVEERR N(" %s%% of %s completed, ETA = %s, speed = %s", - $percent, $total, $eta, $speed) . "\r"; - } else { - print SAVEERR N(" %s%% completed, speed = %s", - $percent, $speed) . "\r"; - } - } elsif ($mode eq 'end') { - print SAVEERR " " x 79, "\r"; - } - } - }, - force_local => 1, - ask_for_medium => (!$auto || $allow_medium_change) && sub { - my $msg = N("Please insert the medium named \"%s\" on device [%s]", @_); - my $msg2 = N("Press Enter when ready..."); if ($X) { - $msg =~ s/"/\\"/g; - gmessage($msg); - !$?; + if ($mode eq 'start') { + $file =~ s|/*\s*$||; $file =~ s|.*/||; + gurpm::label(N("Downloading package `%s'...", $file)); + } elsif ($mode eq 'progress') { + gurpm::progress($percent/100); + } elsif ($mode eq 'end') { + gurpm::progress(1); + } } else { - defined message_input("$msg\n$msg2 "); + if ($mode eq 'start') { + print STDERR " $file\n"; #- allow pass-protected url to be logged. + } elsif ($mode eq 'progress') { + if (defined $total && defined $eta) { + print SAVEERR N(" %s%% of %s completed, ETA = %s, speed = %s", + $percent, $total, $eta, $speed) . "\r"; + } else { + print SAVEERR N(" %s%% completed, speed = %s", + $percent, $speed) . "\r"; + } + } elsif ($mode eq 'end') { + print SAVEERR " " x 79, "\r"; + } } - }); -my %sources_install = %{$urpm->extract_packages_to_install(\%sources) || {}}; - -if ($urpm->{options}{'verify-rpm'}) { - my ($medium, %invalid_sources); + }, + ); + my %transaction_sources_install = %{$urpm->extract_packages_to_install(\%transaction_sources) || {}}; + + if ($urpm->{options}{'verify-rpm'}) { + my ($medium, %invalid_sources); - foreach my $id (sort { $a <=> $b } keys %sources_install, keys %sources) { - my $verif = URPM::verify_rpm($sources_install{$id} || $sources{$id}); + foreach my $id (sort { $a <=> $b } keys %transaction_sources_install, keys %transaction_sources) { + my $verif = URPM::verify_rpm($transaction_sources_install{$id} || $transaction_sources{$id}); - if ($verif =~ /NOT OK/) { - $invalid_sources{$sources_install{$id} || $sources{$id}} = N("Invalid signature (%s)", $verif); - } else { - unless ($medium && $medium->{start} <= $id && $id <= $medium->{end}) { - $medium = undef; - foreach (@{$urpm->{media}}) { - $_->{start} <= $id && $id <= $_->{end} and $medium = $_, last; + if ($verif =~ /NOT OK/) { + $invalid_sources{$transaction_sources_install{$id} || + $transaction_sources{$id}} = N("Invalid signature (%s)", $verif); + } else { + unless ($medium && $medium->{start} <= $id && $id <= $medium->{end}) { + $medium = undef; + foreach (@{$urpm->{media}}) { + $_->{start} <= $id && $id <= $_->{end} and $medium = $_, last; + } } - } - my $key_ids = $medium && $medium->{key_ids} || $urpm->{options}{key_ids}; - #- check the key ids of the medium are matching (all) the given key id of the package. - if ($key_ids) { - my $valid_ids = 0; - my $invalid_ids = 0; - - foreach my $key_id ($verif =~ /#(\S+)/g) { - if (grep { hex($_) == hex($key_id) } split /[,\s]+/, $key_ids) { - ++$valid_ids; - } else { - ++$invalid_ids; + my $key_ids = $medium && $medium->{key_ids} || $urpm->{options}{key_ids}; + #- check the key ids of the medium are matching (all) the given key id of the package. + if ($key_ids) { + my $valid_ids = 0; + my $invalid_ids = 0; + + foreach my $key_id ($verif =~ /#(\S+)/g) { + if (grep { hex($_) == hex($key_id) } split /[,\s]+/, $key_ids) { + ++$valid_ids; + } else { + ++$invalid_ids; + } } - } - if ($invalid_ids) { - $invalid_sources{$sources_install{$id} || $sources{$id}} = N("Invalid Key ID (%s)", $verif); - } elsif (!$valid_ids) { - $invalid_sources{$sources_install{$id} || $sources{$id}} = N("Missing signature (%s)", $verif); + if ($invalid_ids) { + $invalid_sources{$transaction_sources_install{$id} || + $transaction_sources{$id}} = N("Invalid Key ID (%s)", $verif); + } elsif (!$valid_ids) { + $invalid_sources{$transaction_sources_install{$id} || + $transaction_sources{$id}} = N("Missing signature (%s)", $verif); + } } } } - } - if (%invalid_sources) { - my $msg = N("The following packages have bad signatures"); - my $msg2 = N("Do you want to continue installation ?"); - my $p = join "\n", map { "$_: $invalid_sources{$_}"} sort { $a cmp $b} keys %invalid_sources; - if ($auto) { - message("$msg:\n$p\n", 'noX'); - exit 1; - } else { - if ($X) { - gmessage("$msg:\n$p\n\n$msg2"); - $? and exit 1; + if (%invalid_sources) { + my $msg = N("The following packages have bad signatures"); + my $msg2 = N("Do you want to continue installation ?"); + my $p = join "\n", map { "$_: $invalid_sources{$_}"} sort { $a cmp $b} keys %invalid_sources; + if ($auto) { + message("$msg:\n$p\n", 'noX'); + exit 1; } else { - $noexpr = N("Nn"); - $yesexpr = N("Yy"); - message_input("$msg:\n$p\n$msg2" . N(" (y/N) ")) =~ /[$yesexpr]/ or exit 1; + if ($X) { + gmessage("$msg:\n$p\n\n$msg2"); + $? and exit 1; + } else { + $noexpr = N("Nn"); + $yesexpr = N("Yy"); + message_input("$msg:\n$p\n$msg2" . N(" (y/N) ")) =~ /[$yesexpr]/ or exit 1; + } } } } -} -#- check for local files. -if (my @missing = grep { m|^/| && ! -e $_ } values %sources_install, values %sources) { - message(N("Installation failed, some files are missing:\n%s\nYou may want to update your urpmi database", - join "\n", map { " $_" } @missing)); - exit 2; -} + #- check for local files. + if (my @missing = grep { m|^/| && ! -e $_ } values %transaction_sources_install, values %transaction_sources) { + message(N("Installation failed, some files are missing:\n%s\nYou may want to update your urpmi database", + join "\n", map { " $_" } @missing)); + exit 2; + } -#- install source package only (whatever the user is root or not, but use rpm for that). -if ($install_src) { - if (my @l = grep { /\.src\.rpm$/ } values %sources_install, values %sources) { - system("rpm", "-i$rpm_opt", @l, ($root ? ("--root", $root) : @{[]})); - $? and message(N("Installation failed")), exit 1; + #- install source package only (whatever the user is root or not, but use rpm for that). + if ($install_src) { + if (my @l = grep { /\.src\.rpm$/ } values %transaction_sources_install, values %transaction_sources) { + system("rpm", "-i$rpm_opt", @l, ($root ? ("--root", $root) : @{[]})); + $? and message(N("Installation failed")), exit 1; + } + exit 0; } - exit 0; -} -#- clean to remove any src package now. -foreach (\%sources_install, \%sources) { - foreach my $id (keys %$_) { - my $pkg = $urpm->{depslist}[$id] or next; - $pkg->arch eq 'src' and delete $_->{$id}; + #- clean to remove any src package now. + foreach (\%transaction_sources_install, \%transaction_sources) { + foreach my $id (keys %$_) { + my $pkg = $urpm->{depslist}[$id] or next; + $pkg->arch eq 'src' and delete $_->{$id}; + } } -} -if (%sources_install || %sources) { - if ($parallel) { - message(N("distributing %s\n", join(' ', values %sources_install, values %sources)), 'noX'); - #- no remove are handle here, automatically done by each distant node. - $urpm->{log}("starting distributed install"); - $urpm->parallel_install([ keys %{$state->{rejected} || {}} ], \%sources_install, \%sources, - test => $test, - excludepath => $urpm->{options}{excludepath}, excludedocs => $urpm->{options}{excludedocs}); + if (%transaction_sources_install || %transaction_sources) { + if ($parallel) { + message(N("distributing %s\n", join(' ', values %transaction_sources_install, values %transaction_sources)), 'noX'); + #- no remove are handle here, automatically done by each distant node. + $urpm->{log}("starting distributed install"); + $urpm->parallel_install([ keys %{$state->{rejected} || {}} ], \%transaction_sources_install, \%transaction_sources, + test => $test, + excludepath => $urpm->{options}{excludepath}, excludedocs => $urpm->{options}{excludedocs}); + } else { + message(N("installing %s\n", join(' ', values %transaction_sources_install, values %transaction_sources)), 'noX'); + log_it(scalar localtime, " ", join(' ', values %transaction_sources_install, values %transaction_sources), "\n"); + $urpm->{log}("starting installing packages"); + my $progress_nb; + my $total_nb = grep { m|^/| } values %transaction_sources_install, values %transaction_sources; + my $callback_inst = $X && sub { + my ($urpm, $type, $id, $subtype, $amount, $total) = @_; + my $pkg = defined $id && $urpm->{depslist}[$id]; + + if ($subtype eq 'start') { + if ($type eq 'trans') { + gurpm::label(N("Preparing...")); + } else { + gurpm::label(N("Installing package `%s' (%s/%s)...", $pkg->name, ++$progress_nb, $total_nb)); + } + } elsif ($subtype eq 'progress') { + gurpm::progress($amount/$total); + } + }; + my @l = $urpm->install($set->{remove} || [], \%transaction_sources_install, \%transaction_sources, + translate_message => 1, + oldpackage => $state->{oldpackage}, post_clean_cache => $urpm->{options}{'post-clean'}, + test => $test, + excludepath => $urpm->{options}{excludepath}, excludedocs => $urpm->{options}{excludedocs}, + callback_inst => $callback_inst, callback_trans => $callback_inst); + $X and gurpm::end(); + if (@l) { + message(N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); + + m|^/| && !-e $_ and exit 2 foreach values %transaction_sources_install, values %transaction_sources; #- missing local file + $auto || !$urpm->{options}{'allow-nodeps'} && !$urpm->{options}{'allow-force'} and exit 1; + + $noexpr = N("Nn"); + $yesexpr = N("Yy"); + message_input(N("Try installation without checking dependencies? (y/N) "), $force && $yesexpr) =~ /[$yesexpr]/ + or exit 1; + $urpm->{log}("starting installing packages without deps"); + @l = $urpm->install($set->{remove} || [], \%transaction_sources_install, \%transaction_sources, + translate_message => 1, nodeps => 1, + oldpackage => $state->{oldpackage}, post_clean_cache => $urpm->{options}{'post-clean'}, + test => $test, + excludepath => $urpm->{options}{excludepath}, excludedocs => $urpm->{options}{excludedocs}); + if (@l) { + message(N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); + !$urpm->{options}{'allow-force'} and exit 1; + message_input(N("Try installation even more strongly (--force)? (y/N) "), $force && $yesexpr) =~ /[$yesexpr]/ + or exit 1; + $urpm->{log}("starting force installing packages without deps"); + @l = $urpm->install($set->{remove} || [], \%transaction_sources_install, \%transaction_sources, + translate_message => 1, nodeps => 1, force => 1, + oldpackage => $state->{oldpackage}, post_clean_cache => $urpm->{options}{'post-clean'}, + test => $test, + excludepath => $urpm->{options}{excludepath}, + excludedocs => $urpm->{options}{excludedocs}); + @l and $urpm->fatal(2, N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); + } + } else { + $test and message(N("Installation is possible")); + } + } + } elsif ($test) { + message(N("Installation is possible")); } else { - message(N("installing %s\n", join(' ', values %sources_install, values %sources)), 'noX'); - log_it(scalar localtime, " ", join(' ', values %sources_install, values %sources), "\n"); - $urpm->{log}("starting installing packages"); - my $progress_nb; - my $total_nb = grep { m|^/| } values %sources_install, values %sources; - my $callback_inst = $X && sub { - my ($urpm, $type, $id, $subtype, $amount, $total) = @_; - my $pkg = defined $id && $urpm->{depslist}[$id]; - - if ($subtype eq 'start') { - if ($type eq 'trans') { - gurpm::label(N("Preparing...")); - } else { - gurpm::label(N("Installing package `%s' (%s/%s)...", $pkg->name, ++$progress_nb, $total_nb)); - } - } elsif ($subtype eq 'progress') { - gurpm::progress($amount/$total); - } - }; - my @l = $urpm->install(\@ask_remove, \%sources_install, \%sources, - translate_message => 1, - oldpackage => $state->{oldpackage}, post_clean_cache => $urpm->{options}{'post-clean'}, - test => $test, - excludepath => $urpm->{options}{excludepath}, excludedocs => $urpm->{options}{excludedocs}, - callback_inst => $callback_inst, callback_trans => $callback_inst); - $X and gurpm::end(); - if (@l) { - message(N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); - - m|^/| && !-e $_ and exit 2 foreach values %sources_install, values %sources; #- missing local file - $auto || !$urpm->{options}{'allow-nodeps'} && !$urpm->{options}{'allow-force'} and exit 1; - - $noexpr = N("Nn"); - $yesexpr = N("Yy"); - message_input(N("Try installation without checking dependencies? (y/N) "), $force && $yesexpr) =~ /[$yesexpr]/ - or exit 1; - $urpm->{log}("starting installing packages without deps"); - @l = $urpm->install(\@ask_remove, \%sources_install, \%sources, - translate_message => 1, nodeps => 1, - oldpackage => $state->{oldpackage}, post_clean_cache => $urpm->{options}{'post-clean'}, - test => $test, - excludepath => $urpm->{options}{excludepath}, excludedocs => $urpm->{options}{excludedocs}); - if (@l) { - message(N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); - !$urpm->{options}{'allow-force'} and exit 1; - message_input(N("Try installation even more strongly (--force)? (y/N) "), $force && $yesexpr) =~ /[$yesexpr]/ - or exit 1; - $urpm->{log}("starting force installing packages without deps"); - @l = $urpm->install(\@ask_remove, \%sources_install, \%sources, - translate_message => 1, nodeps => 1, force => 1, - oldpackage => $state->{oldpackage}, post_clean_cache => $urpm->{options}{'post-clean'}, - test => $test, - excludepath => $urpm->{options}{excludepath}, - excludedocs => $urpm->{options}{excludedocs}); - @l and $urpm->fatal(2, N("Installation failed") . ":\n" . join("\n", map { "\t$_" } @l)); - } - } else { - $test and message(N("Installation is possible")); - } + $verbose >= 0 and message(N("Everything already installed"), $auto); } -} elsif ($test) { - message(N("Installation is possible")); -} else { - $verbose >= 0 and message(N("Everything already installed"), $auto); } +$urpm->unlock_urpmi_db; #- try to umount removable device which may have been mounted. $urpm->try_umounting_removables; |