diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2007-05-13 09:31:25 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2007-05-13 09:31:25 +0000 |
commit | 2d58cb6cadd79cec3ad79eb153218e0b0b306053 (patch) | |
tree | d25d7545dfe3be1003181041c93a2b04a3945c3c | |
parent | 0481775edd52c193b068c7af14f04aea635b6333 (diff) |
provide match_spec, findstem, find_partialstem at the repository list level,
with ld -L like semantics: we stop at the first repository which has the
corresponding packages..
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageRepository.pm | 13 | ||||
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm | 32 |
2 files changed, 43 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm index 69f260571a6..9a6c47b2219 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageRepository.pm,v 1.24 2007/05/12 15:00:30 espie Exp $ +# $OpenBSD: PackageRepository.pm,v 1.25 2007/05/13 09:31:24 espie Exp $ # # Copyright (c) 2003-2006 Marc Espie <espie@openbsd.org> # @@ -65,6 +65,17 @@ sub findstem return $self->{stemlist}->findstem($stem); } +sub find_partialstem +{ + my ($self, $partial) = @_; + if (!defined $self->{stemlist}) { + require OpenBSD::PackageName; + + $self->{stemlist} = OpenBSD::PackageName::avail2stems($self->available); + } + return $self->{stemlist}->find_partialstem($partial); +} + sub match_spec { my ($self, $spec) = @_; diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm index 264c7f29a66..7ea26baaa3b 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PackageRepositoryList.pm,v 1.5 2007/05/02 15:05:30 espie Exp $ +# $OpenBSD: PackageRepositoryList.pm,v 1.6 2007/05/13 09:31:24 espie Exp $ # # Copyright (c) 2003-2006 Marc Espie <espie@openbsd.org> # @@ -101,6 +101,36 @@ sub available return keys %{$self->{avail}}; } +sub _first_of +{ + my ($self, $method, @args) = @_; + for my $repo (@{$self->{list}}) { + my @l = $repo->$method(@args); + if (@l > 0) { + return @l; + } + } + return (); +} + +sub find_partialstem +{ + my ($self, $partial) = @_; + return $self->_first_of('find_partialstem', $partial); +} + +sub findstem +{ + my ($self, $stem) = @_; + return $self->_first_of('findstem', $stem); +} + +sub match_spec +{ + my ($self, $spec) = @_; + return $self->_first_of('match_spec', $spec); +} + sub cleanup { my $self = shift; |