xref: /openbsd-src/usr.sbin/pkg_add/OpenBSD/Search.pod (revision 6e49571c59fe1f1e78405e5a57a1e8dc40029e00)
1$OpenBSD: Search.pod,v 1.1 2020/12/20 15:30:58 daniel Exp $
2
3=head1 NAME
4
5OpenBSD::Search - package names matching framework
6
7=head1 SYNOPSIS
8
9   use OpenBSD::Search;
10
11   # pkgspec objects
12   my $search_object = OpenBSD::Search::PkgSpec->new($pattern);
13   my $filter_object = OpenBSD::Search::Filter->keep_most_recent;
14
15   # need repository to apply to
16
17   use OpenBSD::PackageRepository::Installed;
18
19   my $inst = OpenBSD::PackageRepository::Installed->new;
20
21   my $list_ref = $inst->match_locations($search_object, $filter_object);
22
23
24=head1 DESCRIPTION
25
26C<OpenBSD::Search> provides a search infrastructure
27for C<OpenBSD::PackageRepository> objects.
28
29A given repository can be searched for existing packages using
30C<$repo-E<gt>match_locations($search1, $filter1, ...);>
31
32It returns a reference to a list of matching C<OpenBSD::PackageLocation>
33objects.
34
35A repository list can be searched in a similar way: the search
36proceeds through each repository in the list, and stops as soon
37as it finds a non-empty match (similar to C<ld -L> rules).
38
39The first search object C<$search> is used to find the basic set
40of matching packages, and further objects are used to weed out
41unwanted elements from the list.
42
43Complex searches must be built as lists of filter objects, in
44order to preserve RepositoryList semantics, and ensure the correct
45non-empty first match is returned.
46
47The infrastructure provides the following objects:
48
49=over 4
50
51=item OpenBSD::Search::PkgSpec
52
53C<OpenBSD::PkgSpec> filters.
54
55=item OpenBSD::Search::Stem
56
57finds all packages with a given stem.
58
59=item OpenBSD::Search::PartialStem
60
61finds all packages including a partial stem.
62
63=item OpenBSD::Search::Filter
64
65filters package list through further tests.
66
67=back
68