diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2006-11-07 12:00:29 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2006-11-07 12:00:29 +0000 |
commit | 9c46df437e09357865998ab42cabd0fcf6befb9d (patch) | |
tree | 55826e2127a0e4d7035c8af6d4a0ac71e2da9b94 | |
parent | 4ab87638c1909e87503de5d929440b136e2e6438 (diff) | |
download | urpmi-9c46df437e09357865998ab42cabd0fcf6befb9d.tar urpmi-9c46df437e09357865998ab42cabd0fcf6befb9d.tar.gz urpmi-9c46df437e09357865998ab42cabd0fcf6befb9d.tar.bz2 urpmi-9c46df437e09357865998ab42cabd0fcf6befb9d.tar.xz urpmi-9c46df437e09357865998ab42cabd0fcf6befb9d.zip |
ask user before installing a package that matching part of the name
-rw-r--r-- | urpm.pm | 4 | ||||
-rwxr-xr-x | urpmi | 25 |
2 files changed, 21 insertions, 8 deletions
@@ -2267,6 +2267,10 @@ sub search_packages { ); $result = 0; } else { + if (!@{$exact_a{$_} || $exact_ra{$_} || []}) { + #- we found a non-exact match + $result = 'substring'; + } foreach (values %l) { my $best; foreach (@$_) { @@ -416,16 +416,21 @@ if ($bug) { } #- search the packages according to the selection given by the user. +my $search_result; if (@names) { - $urpm->search_packages( + $search_result = $urpm->search_packages( \%requested, [ @names ], all => $all, use_provides => $use_provides, fuzzy => $urpm->{options}{fuzzy}, ) || $force or exit 1; + + if (%requested) { + $urpm->{log}("found package(s): " . join(" ", map { scalar $urpm->{depslist}[$_]->fullname } keys %requested)); + } } if (@src_names) { - $urpm->search_packages(\%requested, [ @src_names ], + $search_result = $urpm->search_packages(\%requested, [ @src_names ], all => $all, use_provides => $use_provides, fuzzy => $urpm->{options}{fuzzy}, @@ -548,7 +553,7 @@ 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; +my $ask_user = $env || $search_result eq 'substring'; my $sum = 0; my @root_only; @@ -826,11 +831,15 @@ if ($nok) { print N("Installation is possible"), "\n"; } elsif (@names || @src_names || @files || @src_files || $auto_select) { if (@{$state->{transaction} || []} == 0 && @ask_unselect == 0) { - print N("The package(s) are already installed"), "\n" if $verbose >= 0; - if ($verbose >= 0 && !$auto_select) { - my @packages = map { $urpm->{depslist}[$_]->name } keys %requested; - my @guessed = difference2(\@packages, \(@names, @src_names)); - print N("The following package names were assumed: %s", join ", ", @guessed), "\n" if @guessed; + if ($verbose >= 0) { + if ($auto_select) { + print N("Packages are up to date"), "\n"; + } else { + my @l = map { scalar $urpm->{depslist}[$_]->fullname } keys %requested; + my $msg = @l > 1 ? N("Packages %s are already installed", join(', ', @l)) : + N("Package %s is already installed", @l); + print "$msg\n"; + } } $exit_code = 15 if our $expect_install; } |