| 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::Simple - represents a single dependency statement | ||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||
| 28 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||
| 30 | This class represents a single dependency statement. | ||||||||||||||||||||||||||||||
| 31 | It has several interesting properties: | ||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||
| 33 | =over 4 | ||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||
| 35 | =item package | ||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||
| 37 | The package name (can be undef if the dependency has not been initialized | ||||||||||||||||||||||||||||||
| 38 | or if the simplification of the dependency lead to its removal). | ||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||
| 40 | =item relation | ||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||
| 42 | The relational operator: "=", "<<", "<=", ">=" or ">>". It can be | ||||||||||||||||||||||||||||||
| 43 | undefined if the dependency had no version restriction. In that case the | ||||||||||||||||||||||||||||||
| 44 | following field is also undefined. | ||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||
| 46 | =item version | ||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||
| 48 | The version. | ||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||
| 50 | =item arches | ||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||
| 52 | The list of architectures where this dependency is applicable. It is | ||||||||||||||||||||||||||||||
| 53 | undefined when there's no restriction, otherwise it is an | ||||||||||||||||||||||||||||||
| 54 | array ref. It can contain an exclusion list, in that case each | ||||||||||||||||||||||||||||||
| 55 | architecture is prefixed with an exclamation mark. | ||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||
| 57 | =item archqual | ||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||
| 59 | The arch qualifier of the dependency (can be undef if there is none). | ||||||||||||||||||||||||||||||
| 60 | In the dependency "python:any (>= 2.6)", the arch qualifier is "any". | ||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||
| 62 | =item restrictions | ||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||
| 64 | The restrictions formula for this dependency. It is undefined when there | ||||||||||||||||||||||||||||||
| 65 | is no restriction formula. Otherwise it is an array ref. | ||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||
| 67 | =back | ||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||
| 69 | =cut | ||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||
| 71 | package Dpkg::Deps::Simple 1.02; | ||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||
| 73 | 4 | ▶ | use v5.36; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||
| 75 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||
| 77 | 4 | ▶ | use Dpkg::Arch qw(debarch_is_concerned debarch_list_parse); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 78 | 4 | ▶ | use Dpkg::BuildProfiles qw(parse_build_profiles evaluate_restriction_formula); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 79 | 4 | ▶ | use Dpkg::Version; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 80 | 4 | ▶ | use Dpkg::ErrorHandling; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 81 | 4 | ▶ | use Dpkg::Gettext; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||
| 83 | 4 | ▶ | use parent qw(Dpkg::Interface::Storable); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||
| 85 | =head1 METHODS | ||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||
| 87 | =over 4 | ||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||
| 89 | =item $dep = Dpkg::Deps::Simple->new([$dep[, %opts]]); | ||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||
| 91 | Creates a new object. | ||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||
| 93 | Options: | ||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||
| 95 | =over | ||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||
| 97 | =item B<host_arch> | ||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||
| 99 | Sets the host architecture. | ||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||
| 101 | =item B<build_arch> | ||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||
| 103 | Sets the build architecture. | ||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||
| 105 | =item B<build_dep> | ||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||
| 107 | Specifies whether the parser should consider it a build dependency. | ||||||||||||||||||||||||||||||
| 108 | Defaults to 0. | ||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||
| 110 | =item B<tests_dep> | ||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||
| 112 | Specifies whether the parser should consider it a tests dependency. | ||||||||||||||||||||||||||||||
| 113 | Defaults to 0. | ||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||
| 115 | This option implicitly (and forcibly) enables C<build_dep> because test | ||||||||||||||||||||||||||||||
| 116 | dependencies are based on build dependencies (since dpkg 1.22.1). | ||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||
| 118 | =back | ||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||
| 120 | =cut | ||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||
| 122 | 268 | ▶ | sub new { | ||||||||||||||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=18.4
Pod
documented
| |||||||||||||||||||||||||||||||
| 123 | 268 | my ($this, $arg, %opts) = @_; | |||||||||||||||||||||||||||||
| 124 | 268 | ▶ | 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
| |||||||||||||||||||||||||||||||
| 125 | 268 | my $self = {}; | |||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||
| 127 | 268 | bless $self, $class; | |||||||||||||||||||||||||||||
| 128 | 268 | $self->reset(); | |||||||||||||||||||||||||||||
| 129 | 268 | $self->{host_arch} = $opts{host_arch}; | |||||||||||||||||||||||||||||
| 130 | 268 | $self->{build_arch} = $opts{build_arch}; | |||||||||||||||||||||||||||||
| 131 | 268 | ▶ | $self->{build_dep} = $opts{build_dep} // 0; | ||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"build_dep"} // 0
MC/DC0%0/1
$opts{"build_dep"} // 0
$opts{"build_dep"}
Truth table50%1/2
A
A= $opts{"build_dep"}
| |||||||||||||||||||||||||||||||
| 132 | 268 | ▶ | $self->{tests_dep} = $opts{tests_dep} // 0; | ||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"tests_dep"} // 0
MC/DC0%0/1
$opts{"tests_dep"} // 0
$opts{"tests_dep"}
Truth table50%1/2
A
A= $opts{"tests_dep"}
| |||||||||||||||||||||||||||||||
| 133 | 268 | ▶ | if ($self->{tests_dep}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 134 | 7 | $self->{build_dep} = 1; | |||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||
| 137 | 268 | ▶ | $self->parse_string($arg) if defined $arg; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 138 | 268 | return $self; | |||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||
| 141 | =item $dep->reset() | ||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||
| 143 | Clears any dependency information stored in $dep so that $dep->is_empty() | ||||||||||||||||||||||||||||||
| 144 | returns true. | ||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||
| 146 | =cut | ||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||
| 148 | 332 | ▶ | sub reset { | ||||||||||||||||||||||||||||
|
Subroutine
reset: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 149 | 332 | my $self = shift; | |||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||
| 151 | 332 | $self->{package} = undef; | |||||||||||||||||||||||||||||
| 152 | 332 | $self->{relation} = undef; | |||||||||||||||||||||||||||||
| 153 | 332 | $self->{version} = undef; | |||||||||||||||||||||||||||||
| 154 | 332 | $self->{arches} = undef; | |||||||||||||||||||||||||||||
| 155 | 332 | $self->{archqual} = undef; | |||||||||||||||||||||||||||||
| 156 | 332 | $self->{restrictions} = undef; | |||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||
| 159 | =item $dep->parse_string($dep_string) | ||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||
| 161 | Parses the dependency string and modifies internal properties to match the | ||||||||||||||||||||||||||||||
| 162 | parsed dependency. | ||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||
| 164 | =cut | ||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||
| 166 | 268 | ▶ | sub parse_string { | ||||||||||||||||||||||||||||
|
Subroutine
parse_string: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 167 | 268 | my ($self, $dep) = @_; | |||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||
| 169 | 268 | my $pkgname_regex; | |||||||||||||||||||||||||||||
| 170 | 268 | ▶ | if ($self->{tests_dep}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 171 | 7 | $pkgname_regex = qr/[\@a-zA-Z0-9][\@a-zA-Z0-9+.-]*/; | |||||||||||||||||||||||||||||
| 172 | } else { | ||||||||||||||||||||||||||||||
| 173 | 261 | $pkgname_regex = qr/[a-zA-Z0-9][a-zA-Z0-9+.-]*/; | |||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||
| 176 | 268 | my $dep_regex = qr{ | |||||||||||||||||||||||||||||
| 177 | ^\s* # Skip leading whitespace. | ||||||||||||||||||||||||||||||
| 178 | ($pkgname_regex) # Package name. | ||||||||||||||||||||||||||||||
| 179 | (?: # Start of optional part. | ||||||||||||||||||||||||||||||
| 180 | : # Colon for architecture. | ||||||||||||||||||||||||||||||
| 181 | ([a-zA-Z0-9][a-zA-Z0-9-]*) # Architecture name. | ||||||||||||||||||||||||||||||
| 182 | )? # End of optional part. | ||||||||||||||||||||||||||||||
| 183 | (?: # Start of optional part. | ||||||||||||||||||||||||||||||
| 184 | \s* \( # Open parenthesis for version part. | ||||||||||||||||||||||||||||||
| 185 | \s* (<<|<=|=|>=|>>|[<>]) # Relation part. | ||||||||||||||||||||||||||||||
| 186 | \s* ([^\)\s]+) # Do not attempt to parse version. | ||||||||||||||||||||||||||||||
| 187 | \s* \) # Closing parenthesis. | ||||||||||||||||||||||||||||||
| 188 | )? # End of optional part. | ||||||||||||||||||||||||||||||
| 189 | (?: # Start of optional architecture. | ||||||||||||||||||||||||||||||
| 190 | \s* \[ # Open bracket for architecture. | ||||||||||||||||||||||||||||||
| 191 | \s* ([^\]]+) # Do not parse architectures now. | ||||||||||||||||||||||||||||||
| 192 | \s* \] # Closing bracket. | ||||||||||||||||||||||||||||||
| 193 | )? # End of optional architecture. | ||||||||||||||||||||||||||||||
| 194 | ( | ||||||||||||||||||||||||||||||
| 195 | (?: # Start of optional restriction. | ||||||||||||||||||||||||||||||
| 196 | \s* < # Open bracket for restriction. | ||||||||||||||||||||||||||||||
| 197 | \s* [^>]+ # Do not parse restrictions now. | ||||||||||||||||||||||||||||||
| 198 | \s* > # Closing bracket. | ||||||||||||||||||||||||||||||
| 199 | )+ | ||||||||||||||||||||||||||||||
| 200 | )? # End of optional restriction. | ||||||||||||||||||||||||||||||
| 201 | \s*$ # Trailing spaces at end. | ||||||||||||||||||||||||||||||
| 202 | }x; | ||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||
| 204 | ## no critic (RegularExpressions::ProhibitCaptureWithoutTest) | ||||||||||||||||||||||||||||||
| 205 | 268 | ▶ | return if not $dep =~ $dep_regex; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 206 | 263 | ▶ | if (defined $2) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 207 | 19 | ▶ | return if $2 eq 'native' and not $self->{build_dep}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$2 eq "native" and not $self->{"build_dep"}
MC/DC0%0/2
$2 eq "native" and not $self->{"build_dep"}
$2 eq "native"
not $self->{"build_dep"}
Truth table66%2/3
A and not(B)
A= $2 eq "native"B= not $self->{"build_dep"}
| |||||||||||||||||||||||||||||||
| 208 | 19 | $self->{archqual} = $2; | |||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||
| 210 | 263 | $self->{package} = $1; | |||||||||||||||||||||||||||||
| 211 | 263 | ▶ | $self->{relation} = version_normalize_relation($3) if defined $3; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 212 | 263 | ▶ | if (defined $4) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 213 | 53 | $self->{version} = Dpkg::Version->new($4); | |||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||
| 215 | 263 | ▶ | if (defined $5) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 216 | 10 | $self->{arches} = [ debarch_list_parse($5) ]; | |||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||
| 218 | 263 | ▶ | if (defined $6) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 219 | 134 | $self->{restrictions} = [ parse_build_profiles($6) ]; | |||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||
| 223 | =item $dep->parse($fh, $desc) | ||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||
| 225 | Parse a dependency line from a filehandle. | ||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||
| 227 | =cut | ||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | sub parse { | ||||||||||||||||||||||||||||
|
Subroutine
parse: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 230 | 0 | my ($self, $fh, $desc) = @_; | |||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||
| 232 | 0 | my $line = <$fh>; | |||||||||||||||||||||||||||||
| 233 | 0 | chomp $line; | |||||||||||||||||||||||||||||
| 234 | 0 | return $self->parse_string($line); | |||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||
| 237 | =item $dep->load($filename) | ||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||
| 239 | Parse a dependency line from $filename. | ||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||
| 241 | =item $string = "$dep" | ||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||
| 243 | =item $string = $dep->output([$fh]) | ||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||
| 245 | Returns a string representing the dependency. If $fh is set, it prints | ||||||||||||||||||||||||||||||
| 246 | the string to the filehandle. | ||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||
| 248 | =cut | ||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||
| 250 | 145 | ▶ | sub output { | ||||||||||||||||||||||||||||
|
Subroutine
output: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||
| 251 | 145 | my ($self, $fh) = @_; | |||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||
| 253 | 145 | my $res = $self->{package}; | |||||||||||||||||||||||||||||
| 254 | 145 | ▶ | if (defined $self->{archqual}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 255 | 11 | $res .= ':' . $self->{archqual}; | |||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||
| 257 | 145 | ▶ | if (defined $self->{relation}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 258 | 30 | $res .= ' (' . $self->{relation} . ' ' . $self->{version} . ')'; | |||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||
| 260 | 145 | ▶ | if (defined $self->{arches}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 261 | 1 | $res .= ' [' . join(' ', @{$self->{arches}}) . ']'; | |||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||
| 263 | 145 | ▶ | if (defined $self->{restrictions}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 264 | 7 | for my $restrlist (@{$self->{restrictions}}) { | |||||||||||||||||||||||||||||
| 265 | 10 | $res .= ' <' . join(' ', @{$restrlist}) . '>'; | |||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||
| 268 | 145 | ▶ | if (defined $fh) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 269 | 0 | print { $fh } $res; | |||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||
| 271 | 145 | return $res; | |||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||
| 274 | =item $dep->save($filename) | ||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||
| 276 | Save the dependency into the given $filename. | ||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||
| 278 | =cut | ||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||
| 280 | # _arch_is_superset(\@p, \@q) | ||||||||||||||||||||||||||||||
| 281 | # | ||||||||||||||||||||||||||||||
| 282 | # Returns true if the arch list @p is a superset of arch list @q. | ||||||||||||||||||||||||||||||
| 283 | # The arguments can also be undef in case there is no explicit architecture | ||||||||||||||||||||||||||||||
| 284 | # restriction. | ||||||||||||||||||||||||||||||
| 285 | 70 | ▶ | sub _arch_is_superset { | ||||||||||||||||||||||||||||
|
Subroutine
_arch_is_superset: called CC=22 SCAR=58.9
| |||||||||||||||||||||||||||||||
| 286 | 70 | my ($p, $q) = @_; | |||||||||||||||||||||||||||||
| 287 | 70 | ▶ | my $p_arch_neg = defined $p and $p->[0] =~ /^!/; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 288 | 70 | ▶ | my $q_arch_neg = defined $q and $q->[0] =~ /^!/; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||
| 290 | 70 | ▶ | if (not defined $p) { | ||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||
| 291 | # If $p has no arches, it is a superset of $q and we should fall | ||||||||||||||||||||||||||||||
| 292 | # through to the version check. | ||||||||||||||||||||||||||||||
| 293 | 70 | return 1; | |||||||||||||||||||||||||||||
| 294 | } elsif (not defined $q) { | ||||||||||||||||||||||||||||||
| 295 | # If $q has no arches, it is a superset of $p and there are no useful | ||||||||||||||||||||||||||||||
| 296 | # implications. | ||||||||||||||||||||||||||||||
| 297 | 0 | return 0; | |||||||||||||||||||||||||||||
| 298 | ▶ | } elsif (not $p_arch_neg and not $q_arch_neg) { | |||||||||||||||||||||||||||||
|
Condition0%0/3
$p_arch_neg || $q_arch_neg
MC/DC0%0/2
$p_arch_neg || $q_arch_neg
$p_arch_neg
$q_arch_neg
Truth table0%0/3
A || B
A= $p_arch_negB= $q_arch_neg
| |||||||||||||||||||||||||||||||
| 299 | # Both have arches. If neither are negated, we know nothing useful | ||||||||||||||||||||||||||||||
| 300 | # unless $q is a subset of $p. | ||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||
| 302 | 0 | my %p_arches = map { $_ => 1 } @{$p}; | |||||||||||||||||||||||||||||
| 303 | 0 | my $subset = 1; | |||||||||||||||||||||||||||||
| 304 | 0 | for my $arch (@{$q}) { | |||||||||||||||||||||||||||||
| 305 | 0 | ▶ | $subset = 0 unless $p_arches{$arch}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | return 0 unless $subset; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 308 | ▶ | } elsif ($p_arch_neg and $q_arch_neg) { | |||||||||||||||||||||||||||||
|
Condition0%0/3
$p_arch_neg and $q_arch_neg
MC/DC0%0/2
$p_arch_neg and $q_arch_neg
$p_arch_neg
$q_arch_neg
Truth table0%0/3
A and B
A= $p_arch_negB= $q_arch_neg
| |||||||||||||||||||||||||||||||
| 309 | # If both are negated, we know nothing useful unless $p is a subset of | ||||||||||||||||||||||||||||||
| 310 | # $q (and therefore has fewer things excluded, and therefore is more | ||||||||||||||||||||||||||||||
| 311 | # general). | ||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||
| 313 | 0 | my %q_arches = map { $_ => 1 } @{$q}; | |||||||||||||||||||||||||||||
| 314 | 0 | my $subset = 1; | |||||||||||||||||||||||||||||
| 315 | 0 | for my $arch (@{$p}) { | |||||||||||||||||||||||||||||
| 316 | 0 | ▶ | $subset = 0 unless $q_arches{$arch}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | return 0 unless $subset; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 319 | ▶ | } elsif (not $p_arch_neg and $q_arch_neg) { | |||||||||||||||||||||||||||||
|
Condition0%0/3
not $p_arch_neg and $q_arch_neg
MC/DC0%0/2
not $p_arch_neg and $q_arch_neg
not $p_arch_neg
$q_arch_neg
Truth table0%0/3
not(A) and B
A= not $p_arch_negB= $q_arch_neg
| |||||||||||||||||||||||||||||||
| 320 | # If $q is negated and $p is not, we would need to know the full list | ||||||||||||||||||||||||||||||
| 321 | # of arches to know if there is any relationship, so bail. | ||||||||||||||||||||||||||||||
| 322 | 0 | return 0; | |||||||||||||||||||||||||||||
| 323 | ▶ | } elsif ($p_arch_neg and not $q_arch_neg) { | |||||||||||||||||||||||||||||
|
Condition0%0/3
$p_arch_neg and not $q_arch_neg
MC/DC0%0/2
$p_arch_neg and not $q_arch_neg
$p_arch_neg
not $q_arch_neg
Truth table0%0/3
A and not(B)
A= $p_arch_negB= not $q_arch_neg
| |||||||||||||||||||||||||||||||
| 324 | # If $p is negated and $q is not, $q is a subset of $p if none of the | ||||||||||||||||||||||||||||||
| 325 | # negated arches in $p are present in $q. | ||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||
| 327 | 0 | my %q_arches = map { $_ => 1 } @{$q}; | |||||||||||||||||||||||||||||
| 328 | 0 | my $subset = 1; | |||||||||||||||||||||||||||||
| 329 | 0 | for my $arch (@{$p}) { | |||||||||||||||||||||||||||||
| 330 | 0 | ▶ | $subset = 0 if $q_arches{substr($arch, 1)}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | return 0 unless $subset; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||
| 334 | 0 | return 1; | |||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||
| 337 | # _arch_qualifier_implies($p, $q) | ||||||||||||||||||||||||||||||
| 338 | # | ||||||||||||||||||||||||||||||
| 339 | # Returns true if the arch qualifier $p and $q are compatible with the | ||||||||||||||||||||||||||||||
| 340 | # implication $p -> $q, false otherwise. $p/$q can be undef/"any"/"native" | ||||||||||||||||||||||||||||||
| 341 | # or an architecture string. | ||||||||||||||||||||||||||||||
| 342 | # | ||||||||||||||||||||||||||||||
| 343 | # Because we are handling dependencies in isolation, and the full context | ||||||||||||||||||||||||||||||
| 344 | # of the implications are only known when doing dependency resolution at | ||||||||||||||||||||||||||||||
| 345 | # run-time, we can only assert that they are implied if they are equal. | ||||||||||||||||||||||||||||||
| 346 | # | ||||||||||||||||||||||||||||||
| 347 | # For example dependencies with different arch-qualifiers cannot be simplified | ||||||||||||||||||||||||||||||
| 348 | # as these depend on the state of Multi-Arch field in the package depended on. | ||||||||||||||||||||||||||||||
| 349 | 70 | ▶ | sub _arch_qualifier_implies { | ||||||||||||||||||||||||||||
|
Subroutine
_arch_qualifier_implies: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||
| 350 | 70 | my ($p, $q) = @_; | |||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||
| 352 | 70 | ▶ | return $p eq $q if defined $p and defined $q; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $p and defined $q
MC/DC100%2/2
defined $p and defined $q
defined $p
defined $q
Truth table100%3/3
A and B
A= defined $pB= defined $q
| |||||||||||||||||||||||||||||||
| 353 | 53 | ▶ | return 1 if not defined $p and not defined $q; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $p or defined $q
MC/DC100%2/2
defined $p or defined $q
defined $p
defined $q
Truth table100%3/3
A or B
A= defined $pB= defined $q
| |||||||||||||||||||||||||||||||
| 354 | 8 | return 0; | |||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||
| 357 | # _restrictions_imply($p, $q) | ||||||||||||||||||||||||||||||
| 358 | # | ||||||||||||||||||||||||||||||
| 359 | # Returns true if the restrictions $p and $q are compatible with the | ||||||||||||||||||||||||||||||
| 360 | # implication $p -> $q, false otherwise. | ||||||||||||||||||||||||||||||
| 361 | # Note: We do not try to be very clever here, so we may conservatively | ||||||||||||||||||||||||||||||
| 362 | # return false when there is an implication. | ||||||||||||||||||||||||||||||
| 363 | 48 | ▶ | sub _restrictions_imply { | ||||||||||||||||||||||||||||
|
Subroutine
_restrictions_imply: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||
| 364 | 48 | my ($p, $q) = @_; | |||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||
| 366 | 48 | ▶ | if (not defined $p) { | ||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||
| 367 | 45 | return 1; | |||||||||||||||||||||||||||||
| 368 | } elsif (not defined $q) { | ||||||||||||||||||||||||||||||
| 369 | 0 | return 0; | |||||||||||||||||||||||||||||
| 370 | } else { | ||||||||||||||||||||||||||||||
| 371 | # Check whether set difference is empty. | ||||||||||||||||||||||||||||||
| 372 | 3 | my %restr; | |||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||
| 374 | 3 | for my $restrlist (@{$q}) { | |||||||||||||||||||||||||||||
| 375 | 3 | my $reststr = join ' ', sort @{$restrlist}; | |||||||||||||||||||||||||||||
| 376 | 3 | $restr{$reststr} = 1; | |||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||
| 378 | 3 | for my $restrlist (@{$p}) { | |||||||||||||||||||||||||||||
| 379 | 3 | my $reststr = join ' ', sort @{$restrlist}; | |||||||||||||||||||||||||||||
| 380 | 3 | delete $restr{$reststr}; | |||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||
| 383 | 3 | return keys %restr == 0; | |||||||||||||||||||||||||||||
| 384 | } | ||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||
| 387 | =item $tribool = $dep->implies($other_dep) | ||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||
| 389 | Returns 1 when $dep implies $other_dep. Returns 0 when $dep implies | ||||||||||||||||||||||||||||||
| 390 | NOT($other_dep). Returns undef when there is no implication. $dep and | ||||||||||||||||||||||||||||||
| 391 | $other_dep do not need to be of the same type. | ||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||
| 393 | =cut | ||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||
| 395 | 303 | ▶ | sub implies { | ||||||||||||||||||||||||||||
|
Subroutine
implies: called CC=20 SCAR=31.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 396 | 303 | my ($self, $o) = @_; | |||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||
| 398 | 303 | ▶ | if ($o->isa('Dpkg::Deps::Simple')) { | ||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||
| 399 | # An implication is only possible on the same package. | ||||||||||||||||||||||||||||||
| 400 | 276 | ▶ | return if $self->{package} ne $o->{package}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||
| 402 | # Our architecture set must be a superset of the architectures for | ||||||||||||||||||||||||||||||
| 403 | # $o, otherwise we cannot conclude anything. | ||||||||||||||||||||||||||||||
| 404 | 70 | ▶ | return unless _arch_is_superset($self->{arches}, $o->{arches}); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||
| 406 | # The arch qualifier must not forbid an implication. | ||||||||||||||||||||||||||||||
| 407 | return unless _arch_qualifier_implies($self->{archqual}, | ||||||||||||||||||||||||||||||
| 408 | 70 | ▶ | $o->{archqual}); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||
| 410 | # Our restrictions must imply the restrictions for $o. | ||||||||||||||||||||||||||||||
| 411 | return unless _restrictions_imply($self->{restrictions}, | ||||||||||||||||||||||||||||||
| 412 | 48 | ▶ | $o->{restrictions}); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||
| 414 | # If $o has no version clause, then our dependency is stronger. | ||||||||||||||||||||||||||||||
| 415 | 46 | ▶ | return 1 if not defined $o->{relation}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 416 | # If $o has a version clause, we must also have one, otherwise there | ||||||||||||||||||||||||||||||
| 417 | # cannot be an implication. | ||||||||||||||||||||||||||||||
| 418 | 31 | ▶ | return if not defined $self->{relation}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||
| 420 | return Dpkg::Deps::deps_eval_implication($self->{relation}, | ||||||||||||||||||||||||||||||
| 421 | 25 | $self->{version}, $o->{relation}, $o->{version}); | |||||||||||||||||||||||||||||
| 422 | } elsif ($o->isa('Dpkg::Deps::AND')) { | ||||||||||||||||||||||||||||||
| 423 | # true: Need to imply all individual elements. | ||||||||||||||||||||||||||||||
| 424 | # false: Need to not imply at least one individual element. | ||||||||||||||||||||||||||||||
| 425 | 24 | my $res = 1; | |||||||||||||||||||||||||||||
| 426 | 24 | foreach my $dep ($o->get_deps()) { | |||||||||||||||||||||||||||||
| 427 | 80 | my $implication = $self->implies($dep); | |||||||||||||||||||||||||||||
| 428 | 80 | ▶ | unless (defined $implication and $implication == 1) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $implication and $implication == 1
MC/DC100%2/2
defined $implication and $implication == 1
defined $implication
$implication == 1
Truth table100%3/3
A and B
A= defined $implicationB= $implication == 1
| |||||||||||||||||||||||||||||||
| 429 | 73 | $res = $implication; | |||||||||||||||||||||||||||||
| 430 | 73 | ▶ | last if defined $res; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||
| 433 | 24 | return $res; | |||||||||||||||||||||||||||||
| 434 | } elsif ($o->isa('Dpkg::Deps::OR')) { | ||||||||||||||||||||||||||||||
| 435 | # true: Need to imply at least one individual element. | ||||||||||||||||||||||||||||||
| 436 | # false: Need to not apply all individual elements. | ||||||||||||||||||||||||||||||
| 437 | # undef: The rest. | ||||||||||||||||||||||||||||||
| 438 | 3 | my $res = undef; | |||||||||||||||||||||||||||||
| 439 | 3 | foreach my $dep ($o->get_deps()) { | |||||||||||||||||||||||||||||
| 440 | 5 | my $implication = $self->implies($dep); | |||||||||||||||||||||||||||||
| 441 | 5 | ▶ | if (defined $implication) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 442 | 1 | ▶ | if (not defined $res) { | ||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||
| 443 | 1 | $res = $implication; | |||||||||||||||||||||||||||||
| 444 | } elsif ($implication) { | ||||||||||||||||||||||||||||||
| 445 | 0 | $res = 1; | |||||||||||||||||||||||||||||
| 446 | } else { | ||||||||||||||||||||||||||||||
| 447 | 0 | $res = 0; | |||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||
| 449 | 1 | ▶ | last if defined $res and $res == 1; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $res and $res == 1
MC/DC0%0/2
defined $res and $res == 1
defined $res
$res == 1
Truth table33%1/3
A and B
A= defined $resB= $res == 1
| |||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||
| 452 | 3 | return $res; | |||||||||||||||||||||||||||||
| 453 | } else { | ||||||||||||||||||||||||||||||
| 454 | 0 | croak 'Dpkg::Deps::Simple cannot evaluate implication with a ' . | |||||||||||||||||||||||||||||
| 455 | ref($o); | ||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||
| 459 | =item @dep_list = $dep->get_deps() | ||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||
| 461 | Returns a list of sub-dependencies, which for this object it means it | ||||||||||||||||||||||||||||||
| 462 | returns itself. | ||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||
| 464 | =cut | ||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | sub get_deps { | ||||||||||||||||||||||||||||
|
Subroutine
get_deps: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 467 | 0 | my $self = shift; | |||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||
| 469 | 0 | return $self; | |||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||
| 472 | =item $dep->sort() | ||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||
| 474 | This method is a no-op for this object. | ||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||
| 476 | =cut | ||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | sub sort { | ||||||||||||||||||||||||||||
|
Subroutine
sort: not called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 479 | # Nothing to sort. | ||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||
| 482 | =item $bool = $dep->arch_is_concerned($arch) | ||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||
| 484 | Returns true if the dependency applies to the indicated architecture. | ||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||
| 486 | =cut | ||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||
| 488 | 46 | ▶ | sub arch_is_concerned { | ||||||||||||||||||||||||||||
|
Subroutine
arch_is_concerned: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 489 | 46 | my ($self, $host_arch) = @_; | |||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||
| 491 | # Empty dep. | ||||||||||||||||||||||||||||||
| 492 | 46 | ▶ | return 0 if not defined $self->{package}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 493 | # Dep without arch spec. | ||||||||||||||||||||||||||||||
| 494 | 40 | ▶ | return 1 if not defined $self->{arches}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||
| 496 | 9 | return debarch_is_concerned($host_arch, @{$self->{arches}}); | |||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||
| 499 | =item $dep->reduce_arch($arch) | ||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||
| 501 | Simplifies the dependency to contain only information relevant to the given | ||||||||||||||||||||||||||||||
| 502 | architecture. This object can be left empty after this operation. This trims | ||||||||||||||||||||||||||||||
| 503 | off the architecture restriction list of these objects. | ||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||
| 505 | =cut | ||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||
| 507 | 23 | ▶ | sub reduce_arch { | ||||||||||||||||||||||||||||
|
Subroutine
reduce_arch: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 508 | 23 | my ($self, $host_arch) = @_; | |||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||
| 510 | 23 | ▶ | if (not $self->arch_is_concerned($host_arch)) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 511 | 6 | $self->reset(); | |||||||||||||||||||||||||||||
| 512 | } else { | ||||||||||||||||||||||||||||||
| 513 | 17 | $self->{arches} = undef; | |||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||
| 515 | } | ||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||
| 517 | =item $pkgname = $dep->has_arch_restriction() | ||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||
| 519 | Returns the package name if the dependency applies only to a subset of | ||||||||||||||||||||||||||||||
| 520 | architectures. | ||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||
| 522 | =cut | ||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | sub has_arch_restriction { | ||||||||||||||||||||||||||||
|
Subroutine
has_arch_restriction: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 525 | 0 | my $self = shift; | |||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | if (defined $self->{arches}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 528 | 0 | return $self->{package}; | |||||||||||||||||||||||||||||
| 529 | } else { | ||||||||||||||||||||||||||||||
| 530 | 0 | return (); | |||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||
| 534 | =item $bool = $dep->profile_is_concerned() | ||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||
| 536 | Returns true if the dependency applies to the indicated profile. | ||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||
| 538 | =cut | ||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||
| 540 | 268 | ▶ | sub profile_is_concerned { | ||||||||||||||||||||||||||||
|
Subroutine
profile_is_concerned: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 541 | 268 | my ($self, $build_profiles) = @_; | |||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||
| 543 | # Empty dep. | ||||||||||||||||||||||||||||||
| 544 | 268 | ▶ | return 0 if not defined $self->{package}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 545 | # Dep without restrictions. | ||||||||||||||||||||||||||||||
| 546 | 210 | ▶ | return 1 if not defined $self->{restrictions}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 547 | 124 | return evaluate_restriction_formula($self->{restrictions}, $build_profiles); | |||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||
| 550 | =item $dep->reduce_profiles() | ||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||
| 552 | Simplifies the dependency to contain only information relevant to the given | ||||||||||||||||||||||||||||||
| 553 | profile. This object can be left empty after this operation. This trims off | ||||||||||||||||||||||||||||||
| 554 | the profile restriction list of this object. | ||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||
| 556 | =cut | ||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||
| 558 | 132 | ▶ | sub reduce_profiles { | ||||||||||||||||||||||||||||
|
Subroutine
reduce_profiles: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||
| 559 | 132 | my ($self, $build_profiles) = @_; | |||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||
| 561 | 132 | ▶ | if (not $self->profile_is_concerned($build_profiles)) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 562 | 58 | $self->reset(); | |||||||||||||||||||||||||||||
| 563 | } else { | ||||||||||||||||||||||||||||||
| 564 | 74 | $self->{restrictions} = undef; | |||||||||||||||||||||||||||||
| 565 | } | ||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||
| 568 | =item $tribool = $dep->get_evaluation($facts) | ||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||
| 570 | Evaluates the dependency given a list of installed packages and a list of | ||||||||||||||||||||||||||||||
| 571 | virtual packages provided. These lists are part of the | ||||||||||||||||||||||||||||||
| 572 | L<Dpkg::Deps::KnownFacts> object given as parameters. | ||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||
| 574 | Returns 1 when it's true, 0 when it's false, undef when some information | ||||||||||||||||||||||||||||||
| 575 | is lacking to conclude. | ||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||
| 577 | =cut | ||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||
| 579 | 56 | ▶ | sub get_evaluation { | ||||||||||||||||||||||||||||
|
Subroutine
get_evaluation: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||||
| 580 | 56 | my ($self, $facts) = @_; | |||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||
| 582 | 56 | ▶ | return if not defined $self->{package}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 583 | 56 | return $facts->evaluate_simple_dep($self); | |||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||
| 586 | =item $dep->simplify_deps($facts, @assumed_deps) | ||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||
| 588 | Simplifies the dependency as much as possible given the list of facts (see | ||||||||||||||||||||||||||||||
| 589 | class L<Dpkg::Deps::KnownFacts>) and a list of other dependencies that are | ||||||||||||||||||||||||||||||
| 590 | known to be true. | ||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||
| 592 | =cut | ||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||
| 594 | 0 | ▶ | sub simplify_deps { | ||||||||||||||||||||||||||||
|
Subroutine
simplify_deps: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||
| 595 | 0 | my ($self, $facts) = @_; | |||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||
| 597 | 0 | my $eval = $self->get_evaluation($facts); | |||||||||||||||||||||||||||||
| 598 | 0 | ▶ | $self->reset() if defined $eval and $eval == 1; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $eval and $eval == 1
MC/DC0%0/2
defined $eval and $eval == 1
defined $eval
$eval == 1
Truth table0%0/3
A and B
A= defined $evalB= $eval == 1
| |||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||
| 601 | =item $bool = $dep->is_empty() | ||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||
| 603 | Returns true if the dependency is empty and doesn't contain any useful | ||||||||||||||||||||||||||||||
| 604 | information. This is true when the object has not yet been initialized. | ||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||
| 606 | =cut | ||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||
| 608 | 742 | ▶ | sub is_empty { | ||||||||||||||||||||||||||||
|
Subroutine
is_empty: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 609 | 742 | my $self = shift; | |||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||
| 611 | 742 | return not defined $self->{package}; | |||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||
| 614 | =item $bool = $dep->merge_union($other_dep) | ||||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||||
| 616 | Returns true if $dep could be modified to represent the union of both | ||||||||||||||||||||||||||||||
| 617 | dependencies. Otherwise returns false. | ||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||
| 619 | =cut | ||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||
| 621 | 17 | ▶ | sub merge_union { | ||||||||||||||||||||||||||||
|
Subroutine
merge_union: called CC=13 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||
| 622 | 17 | my ($self, $o) = @_; | |||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||
| 624 | 17 | ▶ | return 0 if not $o->isa('Dpkg::Deps::Simple'); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 625 | 17 | ▶ | return 0 if $self->is_empty() or $o->is_empty(); | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->is_empty or $o->is_empty
MC/DC0%0/2
$self->is_empty or $o->is_empty
$self->is_empty
$o->is_empty
Truth table33%1/3
A or B
A= $self->is_emptyB= $o->is_empty
| |||||||||||||||||||||||||||||||
| 626 | 17 | ▶ | return 0 if $self->{package} ne $o->{package}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 627 | 6 | ▶ | return 0 if defined $self->{arches} or defined $o->{arches}; | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $self->{"arches"} or defined $o->{"arches"}
MC/DC0%0/2
defined $self->{"arches"} or defined $o->{"arches"}
defined $self->{"arches"}
defined $o->{"arches"}
Truth table33%1/3
A or B
A= defined $self->{"arches"}B= defined $o->{"arches"}
| |||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||
| 629 | 6 | ▶ | if (not defined $o->{relation} and defined $self->{relation}) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $o->{"relation"} and defined $self->{"relation"}
MC/DC0%0/2
not defined $o->{"relation"} and defined $self->{"relation"}
not defined $o->{"relation"}
defined $self->{"relation"}
Truth table33%1/3
not(A) and B
A= not defined $o->{"relation"}B= defined $self->{"relation"}
| |||||||||||||||||||||||||||||||
| 630 | # Union is the non-versioned dependency. | ||||||||||||||||||||||||||||||
| 631 | 0 | $self->{relation} = undef; | |||||||||||||||||||||||||||||
| 632 | 0 | $self->{version} = undef; | |||||||||||||||||||||||||||||
| 633 | 0 | return 1; | |||||||||||||||||||||||||||||
| 634 | } | ||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||
| 636 | 6 | my $implication = $self->implies($o); | |||||||||||||||||||||||||||||
| 637 | 6 | my $rev_implication = $o->implies($self); | |||||||||||||||||||||||||||||
| 638 | 6 | ▶ | if (defined $implication) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 639 | 4 | ▶ | if ($implication) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 640 | 1 | $self->{relation} = $o->{relation}; | |||||||||||||||||||||||||||||
| 641 | 1 | $self->{version} = $o->{version}; | |||||||||||||||||||||||||||||
| 642 | 1 | return 1; | |||||||||||||||||||||||||||||
| 643 | } else { | ||||||||||||||||||||||||||||||
| 644 | 3 | return 0; | |||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||
| 647 | 2 | ▶ | if (defined $rev_implication) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 648 | 2 | ▶ | if ($rev_implication) { | ||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||
| 649 | # Already merged... | ||||||||||||||||||||||||||||||
| 650 | 2 | return 1; | |||||||||||||||||||||||||||||
| 651 | } else { | ||||||||||||||||||||||||||||||
| 652 | 0 | return 0; | |||||||||||||||||||||||||||||
| 653 | } | ||||||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||||
| 655 | 0 | return 0; | |||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||
| 658 | =back | ||||||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||||
| 660 | =head1 CHANGES | ||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||
| 662 | =head2 Version 1.02 (dpkg 1.17.10) | ||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||
| 664 | New methods: Add $dep->profile_is_concerned() and $dep->reduce_profiles(). | ||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||
| 666 | =head2 Version 1.01 (dpkg 1.16.1) | ||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||
| 668 | New method: Add $dep->reset(). | ||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||
| 670 | New property: recognizes the arch qualifier "any" and stores it in the | ||||||||||||||||||||||||||||||
| 671 | "archqual" property when present. | ||||||||||||||||||||||||||||||
| 672 | |||||||||||||||||||||||||||||||
| 673 | =head2 Version 1.00 (dpkg 1.15.6) | ||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||
| 675 | Mark the module as public. | ||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||
| 677 | =cut | ||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||
| 679 | 4 | 1; | |||||||||||||||||||||||||||||