summaryrefslogtreecommitdiff
path: root/usr.sbin/pkg_add/pod/OpenBSD::RequiredBy.pod
blob: 096168e52fe28bc9e5c002f4f62eac1a2b8fb94e (plain)
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::RequiredBy.pod,v 1.2 2005/08/17 18:53:08 espie Exp $

=head1 NAME

OpenBSD::RequiredBy - manage installed package dependencies

=head1 SYNOPSIS

    use OpenBSD::RequiredBy;

	
    # let's do things for real
    our $not = 0;

    my $o = OpenBSD::RequiredBy->new($pkgname);

    my $o2 = OpenBSD::Requiring->new($pkgname);

    print "Requirements for $pkgname are ", join(' ',$o2->list()), "\n";

    # add some reverse dependencies
    $o->add($reverse_dep1, $reverse_dep2);

    # remove some dependency
    $o2->delete($dep);

    # forget some cache entry
    OpenBSD::RequiredBy->forget(installed_info($pkgname));

    # compute the transitive closure of some dependencies
    my @fulldeps = OpenBSD::Requiring->compute_closure($pkg1, $pkg2);


=head1 DESCRIPTION

=for comment should add a reference to L<PackageInfo/installed_info>
when it's documented.

C<OpenBSD::RequiredBy> handles lists of forward and reverse dependencies
for installed packages.

If C<$main::not> is true, all change operations are done internally and
never written to disk.

C<$o = OpenBSD::RequiredBy-E<gt>new($pkgname)> gives access to the reverse 
dependencies,
C<$o =OpenBSD::Requiring-E<gt>new($pkgname)>  gives access to the forward 
dependencies.

Such an object can be used to list the dependencies C<$o-E<gt>list()>,
add names to them C<$o-E<gt>add(name1, name2, ...)> or remove name from
them C<$o-E<gt>delete(name1, name2, ...)>.

The full list of forward dependencies (transitive closure) from a set of
packages is given by 
C<OpenBSD::RequiredBy-E<gt>compute_closure($name1, name2, ...)>.
Likewise,
C<OpenBSD::Requiring-E<gt>compute_closure($name1, name2, ...)>
yields the list of reverse dependencies.

Those lists of dependencies trim duplicates and, unless C<$main::not> is true,
disk files are automatically synchronized whenever the lists change.

C<OpenBSD::RequiredBy> maintains a cache for efficiency. When an 
installed package is deleted completely, 
C<OpenBSD::RequiredBy-E<gt>forget($dir)> and 
C<OpenBSD::Requiring-E<gt>forget($dir)> will remove the cache entries.