From 2d58cb6cadd79cec3ad79eb153218e0b0b306053 Mon Sep 17 00:00:00 2001 From: Marc Espie Date: Sun, 13 May 2007 09:31:25 +0000 Subject: 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.. --- usr.sbin/pkg_add/OpenBSD/PackageRepository.pm | 13 ++++++++- usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm | 32 ++++++++++++++++++++++- 2 files changed, 43 insertions(+), 2 deletions(-) (limited to 'usr.sbin/pkg_add/OpenBSD') 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 # @@ -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 # @@ -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; -- cgit v1.2.3