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