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 |
7
|
|
|
|
|
|
|
# Copyright © 2008-2009, 2012-2014 Guillem Jover |
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 . |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
package Dpkg::Deps::OR; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=encoding utf8 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 NAME |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Dpkg::Deps::OR - list of OR dependencies |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
This class represents a list of dependencies of which only one must be met |
33
|
|
|
|
|
|
|
for the dependency to be true. It inherits from Dpkg::Deps::Multiple. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
38
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
53
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
our $VERSION = '1.00'; |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
1
|
|
11
|
use parent qw(Dpkg::Deps::Multiple); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 METHODS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=over 4 |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item $dep->output([$fh]) |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
The output method uses " | " to join the list of sub-dependencies. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub output { |
55
|
14
|
|
|
14
|
1
|
32
|
my ($self, $fh) = @_; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my $res = join(' | ', map { |
58
|
31
|
|
|
|
|
60
|
$_->output() |
59
|
|
|
|
|
|
|
} grep { |
60
|
14
|
|
|
|
|
32
|
not $_->is_empty() |
|
31
|
|
|
|
|
52
|
|
61
|
|
|
|
|
|
|
} $self->get_deps()); |
62
|
|
|
|
|
|
|
|
63
|
14
|
50
|
|
|
|
35
|
if (defined $fh) { |
64
|
0
|
|
|
|
|
0
|
print { $fh } $res; |
|
0
|
|
|
|
|
0
|
|
65
|
|
|
|
|
|
|
} |
66
|
14
|
|
|
|
|
47
|
return $res; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=item $dep->implies($other_dep) |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Returns 1 when $dep implies $other_dep. Returns 0 when $dep implies |
72
|
|
|
|
|
|
|
NOT($other_dep). Returns undef when there's no implication. $dep and |
73
|
|
|
|
|
|
|
$other_dep do not need to be of the same type. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub implies { |
78
|
4
|
|
|
4
|
1
|
16
|
my ($self, $o) = @_; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# Special case for AND with a single member, replace it by its member |
81
|
4
|
100
|
|
|
|
29
|
if ($o->isa('Dpkg::Deps::AND')) { |
82
|
2
|
|
|
|
|
4
|
my @subdeps = $o->get_deps(); |
83
|
2
|
50
|
|
|
|
6
|
if (scalar(@subdeps) == 1) { |
84
|
2
|
|
|
|
|
5
|
$o = $subdeps[0]; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# In general, an OR dependency can't imply anything except if each |
89
|
|
|
|
|
|
|
# of its member implies a member in the other OR dependency |
90
|
4
|
100
|
|
|
|
18
|
if ($o->isa('Dpkg::Deps::OR')) { |
91
|
3
|
|
|
|
|
7
|
my $subset = 1; |
92
|
3
|
|
|
|
|
4
|
foreach my $dep ($self->get_deps()) { |
93
|
19
|
|
|
|
|
23
|
my $found = 0; |
94
|
19
|
|
|
|
|
38
|
foreach my $odep ($o->get_deps()) { |
95
|
72
|
100
|
|
|
|
129
|
$found = 1 if $dep->implies($odep); |
96
|
|
|
|
|
|
|
} |
97
|
19
|
100
|
|
|
|
43
|
$subset = 0 if not $found; |
98
|
|
|
|
|
|
|
} |
99
|
3
|
100
|
|
|
|
17
|
return 1 if $subset; |
100
|
|
|
|
|
|
|
} |
101
|
3
|
|
|
|
|
13
|
return; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item $dep->get_evaluation($facts) |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Evaluates the dependency given a list of installed packages and a list of |
107
|
|
|
|
|
|
|
virtual packages provided. These lists are part of the Dpkg::Deps::KnownFacts |
108
|
|
|
|
|
|
|
object given as parameters. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Returns 1 when it's true, 0 when it's false, undef when some information |
111
|
|
|
|
|
|
|
is lacking to conclude. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub get_evaluation { |
116
|
12
|
|
|
12
|
1
|
27
|
my ($self, $facts) = @_; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# Returns false if all members evaluates to 0 |
119
|
|
|
|
|
|
|
# Returns true if at least one member evaluates to true |
120
|
|
|
|
|
|
|
# Returns undef otherwise |
121
|
12
|
|
|
|
|
15
|
my $result = 0; |
122
|
12
|
|
|
|
|
30
|
foreach my $dep ($self->get_deps()) { |
123
|
26
|
|
|
|
|
55
|
my $eval = $dep->get_evaluation($facts); |
124
|
26
|
50
|
|
|
|
94
|
if (not defined $eval) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
125
|
0
|
|
|
|
|
0
|
$result = undef; |
126
|
|
|
|
|
|
|
} elsif ($eval == 1) { |
127
|
3
|
|
|
|
|
5
|
$result = 1; |
128
|
3
|
|
|
|
|
6
|
last; |
129
|
|
|
|
|
|
|
} elsif ($eval == 0) { |
130
|
|
|
|
|
|
|
# Still possible to have a false evaluation |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
} |
133
|
12
|
|
|
|
|
26
|
return $result; |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item $dep->simplify_deps($facts, @assumed_deps) |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Simplifies the dependency as much as possible given the list of facts (see |
139
|
|
|
|
|
|
|
object Dpkg::Deps::KnownFacts) and a list of other dependencies that are |
140
|
|
|
|
|
|
|
known to be true. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=cut |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub simplify_deps { |
145
|
0
|
|
|
0
|
1
|
|
my ($self, $facts) = @_; |
146
|
0
|
|
|
|
|
|
my @new; |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
WHILELOOP: |
149
|
0
|
|
|
|
|
|
while (@{$self->{list}}) { |
|
0
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
my $dep = shift @{$self->{list}}; |
|
0
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
my $eval = $dep->get_evaluation($facts); |
152
|
0
|
0
|
0
|
|
|
|
if (defined $eval and $eval == 1) { |
153
|
0
|
|
|
|
|
|
$self->{list} = []; |
154
|
0
|
|
|
|
|
|
return; |
155
|
|
|
|
|
|
|
} |
156
|
0
|
|
|
|
|
|
foreach my $odep (@new, @{$self->{list}}) { |
|
0
|
|
|
|
|
|
|
157
|
0
|
0
|
|
|
|
|
next WHILELOOP if $odep->implies($dep); |
158
|
|
|
|
|
|
|
} |
159
|
0
|
|
|
|
|
|
push @new, $dep; |
160
|
|
|
|
|
|
|
} |
161
|
0
|
|
|
|
|
|
$self->{list} = [ @new ]; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=back |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 CHANGES |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head2 Version 1.00 (dpkg 1.15.6) |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Mark the module as public. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
1; |