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 | =encoding utf8 | ||||||
23 | |||||||
24 - 33 | =head1 NAME Dpkg::Deps::Union - list of unrelated dependencies =head1 DESCRIPTION This class represents a list of relationships. It inherits from L<Dpkg::Deps::Multiple>. =cut | ||||||
34 | |||||||
35 | package Dpkg::Deps::Union 1.00; | ||||||
36 | |||||||
37 | 12 12 12 | 51 7 269 | use strict; | ||||
38 | 12 12 12 | 26 13 440 | use warnings; | ||||
39 | |||||||
40 | 12 12 12 | 25 12 38 | use parent qw(Dpkg::Deps::Multiple); | ||||
41 | |||||||
42 - 50 | =head1 METHODS =over 4 =item $dep->output([$fh]) The output() method uses ", " to join the list of relationships. =cut | ||||||
51 | |||||||
52 | sub output { | ||||||
53 | 9 | 1 | 8 | my ($self, $fh) = @_; | |||
54 | |||||||
55 | my $res = join(', ', map { | ||||||
56 | 18 | 19 | $_->output() | ||||
57 | } grep { | ||||||
58 | 9 18 | 28 17 | not $_->is_empty() | ||||
59 | } $self->get_deps()); | ||||||
60 | |||||||
61 | 9 | 15 | if (defined $fh) { | ||||
62 | 0 0 | 0 0 | print { $fh } $res; | ||||
63 | } | ||||||
64 | 9 | 21 | return $res; | ||||
65 | } | ||||||
66 | |||||||
67 - 73 | =item $dep->implies($other_dep) =item $dep->get_evaluation($other_dep) These methods are not meaningful for this object and always return undef. =cut | ||||||
74 | |||||||
75 | sub implies { | ||||||
76 | # Implication test is not useful on Union. | ||||||
77 | 0 | 1 | 0 | return; | |||
78 | } | ||||||
79 | |||||||
80 | sub get_evaluation { | ||||||
81 | # Evaluation is not useful on Union. | ||||||
82 | 0 | 1 | 0 | return; | |||
83 | } | ||||||
84 | |||||||
85 - 90 | =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 | ||||||
91 | |||||||
92 | sub simplify_deps { | ||||||
93 | 6 | 1 | 11 | my ($self, $facts) = @_; | |||
94 | 6 | 7 | my @new; | ||||
95 | |||||||
96 | WHILELOOP: | ||||||
97 | 6 33 | 4 52 | while (@{$self->{list}}) { | ||||
98 | 27 27 | 23 25 | my $odep = shift @{$self->{list}}; | ||||
99 | 27 | 28 | foreach my $dep (@new) { | ||||
100 | 51 | 68 | next WHILELOOP if $dep->merge_union($odep); | ||||
101 | } | ||||||
102 | 18 | 20 | push @new, $odep; | ||||
103 | } | ||||||
104 | 6 | 15 | $self->{list} = [ @new ]; | ||||
105 | } | ||||||
106 | |||||||
107 | =back | ||||||
108 | |||||||
109 - 115 | =head1 CHANGES =head2 Version 1.00 (dpkg 1.15.6) Mark the module as public. =cut | ||||||
116 | |||||||
117 | 1; |