From 9c46df437e09357865998ab42cabd0fcf6befb9d Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 7 Nov 2006 12:00:29 +0000 Subject: ask user before installing a package that matching part of the name --- urpm.pm | 4 ++++ urpmi | 25 +++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/urpm.pm b/urpm.pm index b6de2d4b..43d6d102 100644 --- a/urpm.pm +++ b/urpm.pm @@ -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 (@$_) { diff --git a/urpmi b/urpmi index 84198a0b..1679c74d 100755 --- a/urpmi +++ b/urpmi @@ -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; } -- cgit v1.2.1