File: | Dpkg/Deps/Union.pm |
Coverage: | 84.1% |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | # Copyright © 1998 Richard Braakman | ||||||
2 | # Copyright © 1999 Darren Benham | ||||||
3 | # Copyright © 2000 Sean 'Shaleh' Perry | ||||||
4 | # Copyright © 2004 Frank Lichtenheld | ||||||
5 | # Copyright © 2006 Russ Allbery | ||||||
6 | # Copyright © 2007-2009 Raphaël Hertzog <hertzog@debian.org> | ||||||
7 | # Copyright © 2008-2009, 2012-2014 Guillem Jover <guillem@debian.org> | ||||||
8 | # | ||||||
9 | # This program is free software; you may redistribute it and/or modify | ||||||
10 | # it under the terms of the GNU General Public License as published by | ||||||
11 | # the Free Software Foundation; either version 2 of the License, or | ||||||
12 | # (at your option) any later version. | ||||||
13 | # | ||||||
14 | # This is distributed in the hope that it will be useful, | ||||||
15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||
17 | # GNU General Public License for more details. | ||||||
18 | # | ||||||
19 | # You should have received a copy of the GNU General Public License | ||||||
20 | # along with this program. If not, see <https://www.gnu.org/licenses/>. | ||||||
21 | |||||||
22 | package Dpkg::Deps::Union; | ||||||
23 | |||||||
24 | =encoding utf8 | ||||||
25 | |||||||
26 - 35 | =head1 NAME Dpkg::Deps::Union - list of unrelated dependencies =head1 DESCRIPTION This class represents a list of relationships. It inherits from Dpkg::Deps::Multiple. =cut | ||||||
36 | |||||||
37 | 1 1 1 | 2 1 12 | use strict; | ||||
38 | 1 1 1 | 1 1 27 | use warnings; | ||||
39 | |||||||
40 | our $VERSION = '1.00'; | ||||||
41 | |||||||
42 | 1 1 1 | 1 1 1 | use parent qw(Dpkg::Deps::Multiple); | ||||
43 | |||||||
44 - 52 | =head1 METHODS =over 4 =item $dep->output([$fh]) The output method uses ", " to join the list of relationships. =cut | ||||||
53 | |||||||
54 | sub output { | ||||||
55 | 3 | 1 | 2 | my ($self, $fh) = @_; | |||
56 | |||||||
57 | my $res = join(', ', map { | ||||||
58 | 6 | 3 | $_->output() | ||||
59 | } grep { | ||||||
60 | 3 6 | 6 2 | not $_->is_empty() | ||||
61 | } $self->get_deps()); | ||||||
62 | |||||||
63 | 3 | 4 | if (defined $fh) { | ||||
64 | 0 0 | 0 0 | print { $fh } $res; | ||||
65 | } | ||||||
66 | 3 | 4 | return $res; | ||||
67 | } | ||||||
68 | |||||||
69 - 75 | =item $dep->implies($other_dep) =item $dep->get_evaluation($other_dep) These methods are not meaningful for this object and always return undef. =cut | ||||||
76 | |||||||
77 | sub implies { | ||||||
78 | # Implication test is not useful on Union. | ||||||
79 | 0 | 1 | 0 | return; | |||
80 | } | ||||||
81 | |||||||
82 | sub get_evaluation { | ||||||
83 | # Evaluation is not useful on Union. | ||||||
84 | 0 | 1 | 0 | return; | |||
85 | } | ||||||
86 | |||||||
87 - 92 | =item $dep->simplify_deps($facts) The simplification is done to generate an union of all the relationships. It uses $simple_dep->merge_union($other_dep) to get its job done. =cut | ||||||
93 | |||||||
94 | sub simplify_deps { | ||||||
95 | 2 | 1 | 1 | my ($self, $facts) = @_; | |||
96 | 2 | 2 | my @new; | ||||
97 | |||||||
98 | WHILELOOP: | ||||||
99 | 2 11 | 0 10 | while (@{$self->{list}}) { | ||||
100 | 9 9 | 7 5 | my $odep = shift @{$self->{list}}; | ||||
101 | 9 | 5 | foreach my $dep (@new) { | ||||
102 | 17 | 14 | next WHILELOOP if $dep->merge_union($odep); | ||||
103 | } | ||||||
104 | 6 | 6 | push @new, $odep; | ||||
105 | } | ||||||
106 | 2 | 3 | $self->{list} = [ @new ]; | ||||
107 | } | ||||||
108 | |||||||
109 | =back | ||||||
110 | |||||||
111 - 117 | =head1 CHANGES =head2 Version 1.00 (dpkg 1.15.6) Mark the module as public. =cut | ||||||
118 | |||||||
119 | 1; |