summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_add/pod/OpenBSD::Search.pod
blob: 8f4de16c6792937e851c137a53c59aaac9ee69d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
$OpenBSD: OpenBSD::Search.pod,v 1.4 2010/06/30 10:51:04 espie Exp $

=head1 NAME

OpenBSD::Search - package names matching framework

=head1 SYNOPSIS

   use OpenBSD::Search;

   # pkgspec objects
   my $search_object = OpenBSD::Search::PkgSpec->new($pattern);
   my $filter_object = OpenBSD::Search::Filter->keep_most_recent;

   # need repository to apply to

   use OpenBSD::PackageRepository::Installed;

   my $inst = OpenBSD::PackageRepository::Installed->new;

   my $list_ref = $inst->match_locations($search_object, $filter_object);


=head1 DESCRIPTION

C<OpenBSD::Search> provides a search infrastructure
for C<OpenBSD::PackageRepository> objects.

A given repository can be searched for existing packages using
C<$repo-E<gt>match_locations($search1, $filter1, ...);>

It returns a reference to a list of matching C<OpenBSD::PackageLocation>
objects.

A repository list can be searched in a similar way: the search
proceeds through each repository in the list, and stops as soon
as it finds a non-empty match (similar to C<ld -L> rules).

The first search object C<$search> is used to find the basic set
of matching packages, and further objects are used to weed out
unwanted elements from the list.

Complex searches must be built as lists of filter objects, in
order to preserve RepositoryList semantics, and ensure the correct
non-empty first match is returned.

The infrastructure provides the following objects:

=over 4

=item OpenBSD::Search::PkgSpec

C<OpenBSD::PkgSpec> filters.

=item OpenBSD::Search::Stem

finds all packages with a given stem.

=item OpenBSD::Search::PartialStem

finds all packages including a partial stem.

=item OpenBSD::Search::Filter

filters package list through further tests.

=back