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::Multiple; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=encoding utf8 |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 NAME |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Dpkg::Deps::Multiple - base module to represent multiple dependencies |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
The Dpkg::Deps::Multiple module provides objects implementing various types |
33
|
|
|
|
|
|
|
of dependencies. It is the base class for Dpkg::Deps::{AND,OR,Union}. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
|
630
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
38
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
our $VERSION = '1.02'; |
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
49
|
|
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
1
|
|
6
|
use Dpkg::ErrorHandling; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
83
|
|
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
1
|
|
7
|
use parent qw(Dpkg::Interface::Storable); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 METHODS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=over 4 |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=item $dep = Dpkg::Deps::Multiple->new(%opts); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Creates a new object. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub new { |
59
|
77
|
|
|
77
|
1
|
116
|
my $this = shift; |
60
|
77
|
|
33
|
|
|
226
|
my $class = ref($this) || $this; |
61
|
77
|
|
|
|
|
254
|
my $self = { list => [ @_ ] }; |
62
|
|
|
|
|
|
|
|
63
|
77
|
|
|
|
|
140
|
bless $self, $class; |
64
|
77
|
|
|
|
|
153
|
return $self; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=item $dep->reset() |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Clears any dependency information stored in $dep so that $dep->is_empty() |
70
|
|
|
|
|
|
|
returns true. |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub reset { |
75
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
0
|
$self->{list} = []; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=item $dep->add(@deps) |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Adds new dependency objects at the end of the list. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub add { |
87
|
235
|
|
|
235
|
1
|
307
|
my $self = shift; |
88
|
|
|
|
|
|
|
|
89
|
235
|
|
|
|
|
282
|
push @{$self->{list}}, @_; |
|
235
|
|
|
|
|
709
|
|
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item $dep->get_deps() |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Returns a list of sub-dependencies. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub get_deps { |
99
|
186
|
|
|
186
|
1
|
274
|
my $self = shift; |
100
|
|
|
|
|
|
|
|
101
|
186
|
|
|
|
|
237
|
return grep { not $_->is_empty() } @{$self->{list}}; |
|
504
|
|
|
|
|
913
|
|
|
186
|
|
|
|
|
335
|
|
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item $dep->sort() |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Sorts alphabetically the internal list of dependencies. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub sort { |
111
|
2
|
|
|
2
|
1
|
10
|
my $self = shift; |
112
|
|
|
|
|
|
|
|
113
|
2
|
|
|
|
|
4
|
my @res = (); |
114
|
2
|
|
|
|
|
3
|
@res = sort { Dpkg::Deps::deps_compare($a, $b) } @{$self->{list}}; |
|
32
|
|
|
|
|
64
|
|
|
2
|
|
|
|
|
9
|
|
115
|
2
|
|
|
|
|
13
|
$self->{list} = [ @res ]; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item $dep->arch_is_concerned($arch) |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Returns true if at least one of the sub-dependencies apply to this |
121
|
|
|
|
|
|
|
architecture. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=cut |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub arch_is_concerned { |
126
|
0
|
|
|
0
|
1
|
0
|
my ($self, $host_arch) = @_; |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
0
|
my $res = 0; |
129
|
0
|
|
|
|
|
0
|
foreach my $dep (@{$self->{list}}) { |
|
0
|
|
|
|
|
0
|
|
130
|
0
|
0
|
|
|
|
0
|
$res = 1 if $dep->arch_is_concerned($host_arch); |
131
|
|
|
|
|
|
|
} |
132
|
0
|
|
|
|
|
0
|
return $res; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=item $dep->reduce_arch($arch) |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Simplifies the dependencies to contain only information relevant to the |
138
|
|
|
|
|
|
|
given architecture. The non-relevant sub-dependencies are simply removed. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This trims off the architecture restriction list of Dpkg::Deps::Simple |
141
|
|
|
|
|
|
|
objects. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=cut |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub reduce_arch { |
146
|
0
|
|
|
0
|
1
|
0
|
my ($self, $host_arch) = @_; |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
0
|
my @new; |
149
|
0
|
|
|
|
|
0
|
foreach my $dep (@{$self->{list}}) { |
|
0
|
|
|
|
|
0
|
|
150
|
0
|
|
|
|
|
0
|
$dep->reduce_arch($host_arch); |
151
|
0
|
0
|
|
|
|
0
|
push @new, $dep if $dep->arch_is_concerned($host_arch); |
152
|
|
|
|
|
|
|
} |
153
|
0
|
|
|
|
|
0
|
$self->{list} = [ @new ]; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item $dep->has_arch_restriction() |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
Returns the list of package names that have such a restriction. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=cut |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub has_arch_restriction { |
163
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
164
|
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
0
|
my @res; |
166
|
0
|
|
|
|
|
0
|
foreach my $dep (@{$self->{list}}) { |
|
0
|
|
|
|
|
0
|
|
167
|
0
|
|
|
|
|
0
|
push @res, $dep->has_arch_restriction(); |
168
|
|
|
|
|
|
|
} |
169
|
0
|
|
|
|
|
0
|
return @res; |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item $dep->profile_is_concerned() |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Returns true if at least one of the sub-dependencies apply to this profile. |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub profile_is_concerned { |
179
|
4
|
|
|
4
|
1
|
8
|
my ($self, $build_profiles) = @_; |
180
|
|
|
|
|
|
|
|
181
|
4
|
|
|
|
|
7
|
my $res = 0; |
182
|
4
|
|
|
|
|
6
|
foreach my $dep (@{$self->{list}}) { |
|
4
|
|
|
|
|
9
|
|
183
|
4
|
50
|
|
|
|
9
|
$res = 1 if $dep->profile_is_concerned($build_profiles); |
184
|
|
|
|
|
|
|
} |
185
|
4
|
|
|
|
|
10
|
return $res; |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item $dep->reduce_profiles() |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
Simplifies the dependencies to contain only information relevant to the |
191
|
|
|
|
|
|
|
given profile. The non-relevant sub-dependencies are simply removed. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
This trims off the profile restriction list of Dpkg::Deps::Simple objects. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=cut |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
sub reduce_profiles { |
198
|
9
|
|
|
9
|
1
|
40
|
my ($self, $build_profiles) = @_; |
199
|
|
|
|
|
|
|
|
200
|
9
|
|
|
|
|
13
|
my @new; |
201
|
9
|
|
|
|
|
10
|
foreach my $dep (@{$self->{list}}) { |
|
9
|
|
|
|
|
26
|
|
202
|
66
|
|
|
|
|
154
|
$dep->reduce_profiles($build_profiles); |
203
|
66
|
100
|
|
|
|
133
|
push @new, $dep if $dep->profile_is_concerned($build_profiles); |
204
|
|
|
|
|
|
|
} |
205
|
9
|
|
|
|
|
60
|
$self->{list} = [ @new ]; |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=item $dep->is_empty() |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Returns true if the dependency is empty and doesn't contain any useful |
211
|
|
|
|
|
|
|
information. This is true when a (descendant of) Dpkg::Deps::Multiple |
212
|
|
|
|
|
|
|
contains an empty list of dependencies. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=cut |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
sub is_empty { |
217
|
35
|
|
|
35
|
1
|
70
|
my $self = shift; |
218
|
|
|
|
|
|
|
|
219
|
35
|
|
|
|
|
42
|
return scalar @{$self->{list}} == 0; |
|
35
|
|
|
|
|
102
|
|
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=item $dep->merge_union($other_dep) |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
This method is not meaningful for this object, and will always croak. |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=cut |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub merge_union { |
229
|
0
|
|
|
0
|
1
|
|
croak 'method merge_union() is only valid for Dpkg::Deps::Simple'; |
230
|
|
|
|
|
|
|
} |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=back |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=head1 CHANGES |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head2 Version 1.02 (dpkg 1.17.10) |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
New methods: Add $dep->profile_is_concerned() and $dep->reduce_profiles(). |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head2 Version 1.01 (dpkg 1.16.1) |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
New method: Add $dep->reset(). |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=head2 Version 1.00 (dpkg 1.15.6) |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
Mark the module as public. |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
=cut |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
1; |