summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-07-26 05:55:04 +0000
committerRafael Garcia-Suarez <rgarciasuarez@mandriva.org>2004-07-26 05:55:04 +0000
commit3012a07ac593661d173c9239f52a20a19e598657 (patch)
tree7833afc0bdc816494216b8ab864f921e7d422a31
parentb6502109dfa5e54234c3e8a794c961c69441952b (diff)
downloadurpmi-3012a07ac593661d173c9239f52a20a19e598657.tar
urpmi-3012a07ac593661d173c9239f52a20a19e598657.tar.gz
urpmi-3012a07ac593661d173c9239f52a20a19e598657.tar.bz2
urpmi-3012a07ac593661d173c9239f52a20a19e598657.tar.xz
urpmi-3012a07ac593661d173c9239f52a20a19e598657.zip
Add an option -Y to urpmq (fuzzy and case insensitive)
-rw-r--r--urpm.pm53
-rw-r--r--urpm/args.pm1
-rwxr-xr-xurpmq3
3 files changed, 28 insertions, 29 deletions
diff --git a/urpm.pm b/urpm.pm
index dc5a161f..6d212a02 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -2011,13 +2011,25 @@ sub register_rpms {
%requested;
}
-#- search packages registered by their name by storing their id into packages hash.
+sub _findindeps {
+ my ($urpm, $found, $v, %options) = @_;
+ my @list = grep { defined $_ } map {
+ my $pkg = $urpm->{depslist}[$_];
+ $pkg
+ && ($options{src} ? $pkg->arch eq 'src' : $pkg->arch ne 'src')
+ ? $pkg->id : undef;
+ } keys %{$urpm->{provides}{$_} || {}};
+ @list > 0 and push @{$found->{$v}}, join '|', @list;
+}
+
+#- search packages registered by their names by storing their ids into the $packages hash.
sub search_packages {
my ($urpm, $packages, $names, %options) = @_;
my (%exact, %exact_a, %exact_ra, %found, %foundi);
foreach my $v (@$names) {
my $qv = quotemeta $v;
+ $qv = '(?i)'.$qv if $options{caseinsensitive};
unless ($options{fuzzy}) {
#- try to search through provides.
@@ -2031,10 +2043,10 @@ sub search_packages {
$urpm->{depslist}[$_]
} keys %{$urpm->{provides}{$v} || {}})
{
- #- we assume that if the there is at least one package providing the resource exactly,
- #- this should be the best ones that is described.
- #- but we first check if one of the packages has the same name as searched.
- if (my @l2 = grep { $_->name eq $v } @l) {
+ #- we assume that if there is at least one package providing
+ #- the resource exactly, this should be the best one; but we
+ #- first check if one of the packages has the same name as searched.
+ if ((my @l2) = grep { $_->name eq $v } @l) {
$exact{$v} = join '|', map { $_->id } @l2;
} else {
$exact{$v} = join '|', map { $_->id } @l;
@@ -2045,28 +2057,11 @@ sub search_packages {
if ($options{use_provides} && $options{fuzzy}) {
foreach (keys %{$urpm->{provides}}) {
- #- search through provides to find if a provide match this one.
- #- but manages choices correctly (as a provides may be virtual or
- #- multiply defined.
- if (/$qv/) {
- my @list = grep { defined $_ } map {
- my $pkg = $urpm->{depslist}[$_];
- $pkg
- && ($options{src} ? $pkg->arch eq 'src' : $pkg->arch ne 'src')
- ? $pkg->id : undef;
- }
- keys %{$urpm->{provides}{$_} || {}};
- @list > 0 and push @{$found{$v}}, join '|', @list;
- }
- if (/$qv/i) {
- my @list = grep { defined $_ } map {
- my $pkg = $urpm->{depslist}[$_];
- $pkg
- && ($options{src} ? $pkg->arch eq 'src' : $pkg->arch ne 'src')
- ? $pkg->id : undef;
- }
- keys %{$urpm->{provides}{$_} || {}};
- @list > 0 and push @{$found{$v}}, join '|', @list;
+ #- search through provides to find if a provide matches this one;
+ #- but manage choices correctly (as a provides may be virtual or
+ #- defined several times).
+ if (/$qv/ || (!$options{caseinsensitive} && /$qv/i)) {
+ $urpm->_findindeps(\%found, $v, %options);
}
}
}
@@ -2094,7 +2089,7 @@ sub search_packages {
}
$pack =~ /$qv/ and push @{$found{$v}}, $id;
- $pack =~ /$qv/i and push @{$foundi{$v}}, $id;
+ $pack =~ /$qv/i and push @{$foundi{$v}}, $id unless $options{caseinsensitive};
}
}
@@ -2138,7 +2133,7 @@ sub search_packages {
}
}
- #- return true if no error have been encoutered, else false.
+ #- return true if no error has been encoutered, else false.
$result;
}
diff --git a/urpm/args.pm b/urpm/args.pm
index 3b3a94de..76a60460 100644
--- a/urpm/args.pm
+++ b/urpm/args.pm
@@ -208,6 +208,7 @@ my %options_spec = (
P => sub { $options{use_provides} = 0 },
R => \$options{what_requires},
y => sub { $options{fuzzy} = $options{all} = 1 },
+ Y => sub { $options{fuzzy} = $options{all} = $options{caseinsensitive} = 1 },
v => \$options{verbose},
i => \$options{info},
l => \$options{list_files},
diff --git a/urpmq b/urpmq
index 3ec20647..77d27984 100755
--- a/urpmq
+++ b/urpmq
@@ -82,6 +82,7 @@ usage:
") . N(" -P - do not search in provides to find package (default).
") . N(" -R - reverse search to what requires package.
") . N(" -y - impose fuzzy search (same as --fuzzy).
+") . N(" -Y - like -y, but forces to match case-insensitively.
") . N(" -s - next package is a source package (same as --src).
") . N(" -i - print useful information in human readable form.
") . N(" -g - print groups with name also.
@@ -182,6 +183,7 @@ if ($urpm::args::options{list_aliases}) {
[ @names ],
use_provides => $urpm::args::options{use_provides},
fuzzy => $urpm::args::options{fuzzy},
+ caseinsensitive => $urpm::args::options{caseinsensitive},
all => $urpm::args::options{all},
) or $urpm::args::options{force}
or exit 1;
@@ -192,6 +194,7 @@ if ($urpm::args::options{list_aliases}) {
[ @src_names ],
use_provides => $urpm::args::options{use_provides},
fuzzy => $urpm::args::options{fuzzy},
+ caseinsensitive => $urpm::args::options{caseinsensitive},
src => 1,
) or $urpm::args::options{force}
or exit 1;