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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
|
# Copyright © 1998 Richard Braakman
# Copyright © 1999 Darren Benham
# Copyright © 2000 Sean 'Shaleh' Perry
# Copyright © 2004 Frank Lichtenheld
# Copyright © 2006 Russ Allbery
# Copyright © 2007-2009 Raphaël Hertzog <hertzog@debian.org>
# Copyright © 2008-2009, 2012-2014 Guillem Jover <guillem@debian.org>
#
# This program is free software; you may redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
=encoding utf8
=head1 NAME
Dpkg::Deps::Multiple - base module to represent multiple dependencies
=head1 DESCRIPTION
The Dpkg::Deps::Multiple module provides objects implementing various types
of dependencies. It is the base class for Dpkg::Deps::{AND,OR,Union}.
=cut
package Dpkg::Deps::Multiple 1.02;
use strict;
use warnings;
use Carp;
use Dpkg::ErrorHandling;
use parent qw(Dpkg::Interface::Storable);
=head1 METHODS
=over 4
=item $dep = Dpkg::Deps::Multiple->new(%opts);
Creates a new object.
=cut
sub new {
my ($this, @deps) = @_;
my $class = ref($this) || $this;
my $self = { list => [ @deps ] };
bless $self, $class;
return $self;
}
=item $dep->reset()
Clears any dependency information stored in $dep so that $dep->is_empty()
returns true.
=cut
sub reset {
my $self = shift;
$self->{list} = [];
}
=item $dep->add(@deps)
Adds new dependency objects at the end of the list.
=cut
sub add {
my ($self, @deps) = @_;
push @{$self->{list}}, @deps;
}
=item $dep->get_deps()
Returns a list of sub-dependencies.
=cut
sub get_deps {
my $self = shift;
return grep { not $_->is_empty() } @{$self->{list}};
}
=item $dep->sort()
Sorts alphabetically the internal list of dependencies.
=cut
sub sort {
my $self = shift;
my @res = ();
@res = sort { Dpkg::Deps::deps_compare($a, $b) } @{$self->{list}};
$self->{list} = [ @res ];
}
=item $dep->arch_is_concerned($arch)
Returns true if at least one of the sub-dependencies apply to this
architecture.
=cut
sub arch_is_concerned {
my ($self, $host_arch) = @_;
my $res = 0;
foreach my $dep (@{$self->{list}}) {
$res = 1 if $dep->arch_is_concerned($host_arch);
}
return $res;
}
=item $dep->reduce_arch($arch)
Simplifies the dependencies to contain only information relevant to the
given architecture. The non-relevant sub-dependencies are simply removed.
This trims off the architecture restriction list of L<Dpkg::Deps::Simple>
objects.
=cut
sub reduce_arch {
my ($self, $host_arch) = @_;
my @new;
foreach my $dep (@{$self->{list}}) {
$dep->reduce_arch($host_arch);
push @new, $dep if $dep->arch_is_concerned($host_arch);
}
$self->{list} = [ @new ];
}
=item $dep->has_arch_restriction()
Returns the list of package names that have such a restriction.
=cut
sub has_arch_restriction {
my $self = shift;
my @res;
foreach my $dep (@{$self->{list}}) {
push @res, $dep->has_arch_restriction();
}
return @res;
}
=item $dep->profile_is_concerned()
Returns true if at least one of the sub-dependencies apply to this profile.
=cut
sub profile_is_concerned {
my ($self, $build_profiles) = @_;
my $res = 0;
foreach my $dep (@{$self->{list}}) {
$res = 1 if $dep->profile_is_concerned($build_profiles);
}
return $res;
}
=item $dep->reduce_profiles()
Simplifies the dependencies to contain only information relevant to the
given profile. The non-relevant sub-dependencies are simply removed.
This trims off the profile restriction list of L<Dpkg::Deps::Simple> objects.
=cut
sub reduce_profiles {
my ($self, $build_profiles) = @_;
my @new;
foreach my $dep (@{$self->{list}}) {
$dep->reduce_profiles($build_profiles);
push @new, $dep if $dep->profile_is_concerned($build_profiles);
}
$self->{list} = [ @new ];
}
=item $dep->is_empty()
Returns true if the dependency is empty and doesn't contain any useful
information. This is true when a (descendant of) L<Dpkg::Deps::Multiple>
contains an empty list of dependencies.
=cut
sub is_empty {
my $self = shift;
return scalar @{$self->{list}} == 0;
}
=item $dep->merge_union($other_dep)
This method is not meaningful for this object, and will always croak.
=cut
sub merge_union {
croak 'method merge_union() is only valid for Dpkg::Deps::Simple';
}
=back
=head1 CHANGES
=head2 Version 1.02 (dpkg 1.17.10)
New methods: Add $dep->profile_is_concerned() and $dep->reduce_profiles().
=head2 Version 1.01 (dpkg 1.16.1)
New method: Add $dep->reset().
=head2 Version 1.00 (dpkg 1.15.6)
Mark the module as public.
=cut
1;
|