aboutsummaryrefslogtreecommitdiffstats
path: root/URPM.pm
diff options
context:
space:
mode:
Diffstat (limited to 'URPM.pm')
-rw-r--r--URPM.pm18
1 files changed, 17 insertions, 1 deletions
diff --git a/URPM.pm b/URPM.pm
index e9a0eb2..27187fa 100644
--- a/URPM.pm
+++ b/URPM.pm
@@ -6,7 +6,7 @@ use vars qw($VERSION @ISA);
require DynaLoader;
@ISA = qw(DynaLoader);
-$VERSION = '0.09';
+$VERSION = '0.10';
bootstrap URPM $VERSION;
@@ -18,6 +18,22 @@ sub new {
}, $class;
}
+sub search {
+ my ($urpm, $name, %options) = @_;
+ my $best = undef;
+
+ foreach (keys %{$urpm->{provides}{$name} || {}}) {
+ my $pkg = $urpm->{depslist}[$_];
+ my ($n, $v, $r, $a) = $pkg->fullname;
+
+ $options{src} && $a eq 'src' || $pkg->is_arch_compat or next;
+ $n eq $name || !$options{strict} && ("$n-$v" eq $name || "$n-$v-$r" eq $name || "$n-$v-$r.$a" eq $name) or next;
+ !$best || $pkg->compare_pkg($best) > 0 and $best = $pkg;
+ }
+
+ $best;
+}
+
sub traverse {
my ($urpm, $callback) = @_;