diff options
Diffstat (limited to 'usr.sbin/pkg_add/OpenBSD')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageLocator.pm | 7 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm | 13 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/Search.pm | 37 |
3 files changed, 54 insertions, 3 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm index 263e312a037..eb8496167c3 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageLocator.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageLocator.pm,v 1.70 2007/05/19 09:18:55 espie Exp $ +# $OpenBSD: PackageLocator.pm,v 1.71 2007/05/19 09:45:33 espie Exp $ # # Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org> # @@ -115,4 +115,9 @@ sub match return $pkgpath->match(@search); } +sub match_locations +{ + my ($class, @search) = @_; + return $pkgpath->match_locations(@search); +} 1; diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm index 024bf06e4ba..d07e6bdcc00 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository/Installed.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Installed.pm,v 1.9 2007/05/19 09:18:55 espie Exp $ +# $OpenBSD: Installed.pm,v 1.10 2007/05/19 09:45:33 espie Exp $ # # Copyright (c) 2007 Marc Espie <espie@openbsd.org> # @@ -37,6 +37,17 @@ sub match return @l; } +sub match_locations +{ + my ($self, $search, @filters) = @_; + my @l = $search->match_locations($self); + while (my $filter = (shift @filters)) { + last if @l == 0; # don't bother filtering empty list + @l = $filter->filter_locations(@l); + } + return @l; +} + sub url { my ($self, $name) = @_; diff --git a/usr.sbin/pkg_add/OpenBSD/Search.pm b/usr.sbin/pkg_add/OpenBSD/Search.pm index 05121af0eeb..03f69f4e2eb 100644 --- a/usr.sbin/pkg_add/OpenBSD/Search.pm +++ b/usr.sbin/pkg_add/OpenBSD/Search.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: Search.pm,v 1.4 2007/05/18 13:22:06 espie Exp $ +# $OpenBSD: Search.pm,v 1.5 2007/05/19 09:45:33 espie Exp $ # # Copyright (c) 2007 Marc Espie <espie@openbsd.org> # @@ -16,6 +16,26 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. package OpenBSD::Search; +sub match_locations +{ + my ($self, $o) = @_; + require OpenBSD::PackageLocation; + + return map {OpenBSD::PackageLocation->new($o, $_)} $self->match($o); +} + +# XXX this is not efficient +sub filter_locations +{ + my $self = shift; + my @r = (); + while (my $loc = shift @_) { + if ($self->filter($loc->{name})) { + push(@r, $loc); + } + } + return @r; +} package OpenBSD::Search::PkgSpec; our @ISA=(qw(OpenBSD::Search)); @@ -140,4 +160,19 @@ sub keep_most_recent return $class->new(\&OpenBSD::PackageName::keep_most_recent); } +package OpenBSD::Search::FilterLocation; +our @ISA=(qw(OpenBSD::Search)); +sub new +{ + my ($class, $code) = @_; + + return bless {code => $code}, $class; +} + +sub filter_locations +{ + my ($self, @l) = @_; + return &{$self->{code}}(@l); +} + 1; |