summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Espie <espie@cvs.openbsd.org>2007-05-13 13:32:37 +0000
committerMarc Espie <espie@cvs.openbsd.org>2007-05-13 13:32:37 +0000
commit092cf68861c9352f7c3176532b86be07b88be16d (patch)
tree8bc701463f6ab9e30328636cc7eada6e3adc3e01
parent1ce313db22a6e29e1eabd2521b919d96a10825af (diff)
unify object lookup as locator->match($o) or $repo->match($o)
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Dependencies.pm4
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageInfo.pm4
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageName.pm8
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageRepository.pm8
-rw-r--r--usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm6
-rw-r--r--usr.sbin/pkg_add/OpenBSD/Update.pm6
-rw-r--r--usr.sbin/pkg_add/pkg_add4
-rw-r--r--usr.sbin/pkg_add/pkg_info7
8 files changed, 27 insertions, 20 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
index 02433f8d5f2..a86ac3a8a93 100644
--- a/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Dependencies.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Dependencies.pm,v 1.21 2007/05/12 15:19:00 espie Exp $
+# $OpenBSD: Dependencies.pm,v 1.22 2007/05/13 13:32:36 espie Exp $
#
# Copyright (c) 2005-2007 Marc Espie <espie@openbsd.org>
#
@@ -84,7 +84,7 @@ sub solve
require OpenBSD::PackageLocator;
# try with list of available packages
- my @candidates = OpenBSD::PackageLocator->match_spec($spec);
+ my @candidates = OpenBSD::PackageLocator->match($spec);
if (!$state->{forced}->{allversions}) {
@candidates = OpenBSD::PackageName::keep_most_recent(@candidates);
}
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm
index 7b915f5abc6..5321479fd02 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackageInfo.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackageInfo.pm,v 1.23 2007/05/07 14:33:30 espie Exp $
+# $OpenBSD: PackageInfo.pm,v 1.24 2007/05/13 13:32:36 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -201,7 +201,7 @@ sub solve_installed_names
if (OpenBSD::PackageName::is_stem($pkgname)) {
require OpenBSD::PackageRepository;
- my @l = OpenBSD::PackageRepository::Installed->new->findstem($pkgname);
+ my @l = OpenBSD::PackageRepository::Installed->new->match(OpenBSD::PackageName::Stem->new($pkgname));
if (@l == 0) {
print "Can't resolve $pkgname to an installed package name\n";
$bad = 1;
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageName.pm b/usr.sbin/pkg_add/OpenBSD/PackageName.pm
index 09de0d3d009..04dfb81d3a6 100644
--- a/usr.sbin/pkg_add/OpenBSD/PackageName.pm
+++ b/usr.sbin/pkg_add/OpenBSD/PackageName.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: PackageName.pm,v 1.20 2007/05/13 13:12:21 espie Exp $
+# $OpenBSD: PackageName.pm,v 1.21 2007/05/13 13:32:36 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -320,11 +320,11 @@ sub split
sub match_repo
{
my ($self, $o) = @_;
- return $o->stemlist->findstem($o->{stem});
+ return $o->stemlist->findstem($self->{stem});
}
package OpenBSD::PackageName::PartialStem;
-our @ISA=(qw(OpenBSD::PackageName::PartialStem));
+our @ISA=(qw(OpenBSD::PackageName::Stem));
sub to_pattern
{
@@ -335,7 +335,7 @@ sub to_pattern
sub match_repo
{
my ($self, $o) = @_;
- return $o->stemlist->find_partialstem($o->{stem});
+ return $o->stemlist->find_partialstem($self->{stem});
}
package OpenBSD::PackageName::Name;
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepository.pm
index 2dabba15f84..c264e2eaf18 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.26 2007/05/13 12:58:54 espie Exp $
+# $OpenBSD: PackageRepository.pm,v 1.27 2007/05/13 13:32:36 espie Exp $
#
# Copyright (c) 2003-2006 Marc Espie <espie@openbsd.org>
#
@@ -83,6 +83,12 @@ sub match_spec
return $spec->match_repo($self);
}
+sub match
+{
+ my ($self, $search) = @_;
+ return $search->match_repo($self);
+}
+
sub wipe_info
{
my ($self, $pkg) = @_;
diff --git a/usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm b/usr.sbin/pkg_add/OpenBSD/PackageRepositoryList.pm
index 315d3167adf..acef08fa53d 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.8 2007/05/13 13:12:21 espie Exp $
+# $OpenBSD: PackageRepositoryList.pm,v 1.9 2007/05/13 13:32:36 espie Exp $
#
# Copyright (c) 2003-2006 Marc Espie <espie@openbsd.org>
#
@@ -134,10 +134,10 @@ sub match_spec
return $self->_first_of('match_spec', $filter, $spec);
}
-sub match_repo
+sub match
{
my ($self, $spec, $filter) = @_;
- return $self->_first_of('match_repo', $filter, $spec);
+ return $self->_first_of('match', $filter, $spec);
}
sub cleanup
diff --git a/usr.sbin/pkg_add/OpenBSD/Update.pm b/usr.sbin/pkg_add/OpenBSD/Update.pm
index 2467ad585ba..af8041f3338 100644
--- a/usr.sbin/pkg_add/OpenBSD/Update.pm
+++ b/usr.sbin/pkg_add/OpenBSD/Update.pm
@@ -1,5 +1,5 @@
# ex:ts=8 sw=4:
-# $OpenBSD: Update.pm,v 1.72 2007/05/13 12:19:28 espie Exp $
+# $OpenBSD: Update.pm,v 1.73 2007/05/13 13:32:36 espie Exp $
#
# Copyright (c) 2004-2006 Marc Espie <espie@openbsd.org>
#
@@ -63,7 +63,7 @@ sub process_package
print "Not updating $pkgname, remember to clean it\n";
next;
}
- my $stem = OpenBSD::PackageName::splitstem($pkgname);
+ my $stem = OpenBSD::PackageName::Stem->split($pkgname);
my $found;
my $plist;
@@ -119,7 +119,7 @@ sub process_package
};
- my @l = OpenBSD::PackageLocator->findstem($stem, $filter);
+ my @l = OpenBSD::PackageLocator->match($stem, $filter);
if (@l == 0) {
$self->add2cant($pkgname);
return;
diff --git a/usr.sbin/pkg_add/pkg_add b/usr.sbin/pkg_add/pkg_add
index 7af716b2ce1..60810b1e002 100644
--- a/usr.sbin/pkg_add/pkg_add
+++ b/usr.sbin/pkg_add/pkg_add
@@ -1,7 +1,7 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg_add,v 1.239 2007/05/13 10:43:33 espie Exp $
+# $OpenBSD: pkg_add,v 1.240 2007/05/13 13:32:36 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -591,7 +591,7 @@ sub find_truenames
$h = 'OpenBSD::PackageLocator';
$path = "";
}
- my @l = $h->findstem($pkgname);
+ my @l = $h->match(OpenBSD::PackageName::Stem->new($pkgname));
if (@l > 1 && !$state->{forced}->{allversions}) {
@l = OpenBSD::PackageName::keep_most_recent(@l);
}
diff --git a/usr.sbin/pkg_add/pkg_info b/usr.sbin/pkg_add/pkg_info
index ec5047878f5..fa7f2994d6e 100644
--- a/usr.sbin/pkg_add/pkg_info
+++ b/usr.sbin/pkg_add/pkg_info
@@ -1,6 +1,6 @@
#! /usr/bin/perl
# ex:ts=8 sw=4:
-# $OpenBSD: pkg_info,v 1.49 2007/05/12 14:48:45 espie Exp $
+# $OpenBSD: pkg_info,v 1.50 2007/05/13 13:32:36 espie Exp $
#
# Copyright (c) 2003-2007 Marc Espie <espie@openbsd.org>
#
@@ -78,7 +78,7 @@ sub find_pkg
return;
}
if (OpenBSD::PackageName::is_stem($pkgname)) {
- my @l = sort ($repo->findstem($pkgname));
+ my @l = sort ($repo->match(OpenBSD::PackageName::Stem->new($pkgname)));
if (@l != 0) {
for my $p (@l) {
&$code($p, $repo->find($p));
@@ -369,8 +369,9 @@ if ($opt_Q) {
require OpenBSD::PackageLocator;
print "PKG_PATH=$ENV{PKG_PATH}\n" if $opt_v;
+ my $partial = OpenBSD::PackageName::PartialStem->new($opt_Q);
- for my $p (sort OpenBSD::PackageLocator->find_partialstem($opt_Q)) {
+ for my $p (sort OpenBSD::PackageLocator->match($partial)) {
print $p, is_installed($p) ? " (installed)" : "" , "\n";
}