| 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 - parse and manipulate dependencies of Debian packages | ||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | The Dpkg::Deps module provides classes implementing various types of | ||||||||||||||||||||||||||||||||||||||||||
| 31 | dependencies. | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | The most important function is deps_parse(), it turns a dependency line in | ||||||||||||||||||||||||||||||||||||||||||
| 34 | a set of Dpkg::Deps::{Simple,AND,OR,Union} objects depending on the case. | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | package Dpkg::Deps 1.07; | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 4 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 4 | our @EXPORT = qw( | |||||||||||||||||||||||||||||||||||||||||
| 43 | deps_concat | ||||||||||||||||||||||||||||||||||||||||||
| 44 | deps_parse | ||||||||||||||||||||||||||||||||||||||||||
| 45 | deps_eval_implication | ||||||||||||||||||||||||||||||||||||||||||
| 46 | deps_iterate | ||||||||||||||||||||||||||||||||||||||||||
| 47 | deps_compare | ||||||||||||||||||||||||||||||||||||||||||
| 48 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 4 | ▶ | use Exporter qw(import); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 4 | ▶ | use Dpkg::Version; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | 4 | ▶ | use Dpkg::Arch qw(get_host_arch get_build_arch debarch_to_debtuple); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 55 | 4 | ▶ | use Dpkg::BuildProfiles qw(get_build_profiles); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 4 | ▶ | use Dpkg::ErrorHandling; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 4 | ▶ | use Dpkg::Gettext; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 58 | 4 | ▶ | use Dpkg::Deps::Simple; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 4 | ▶ | use Dpkg::Deps::Union; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | ▶ | use Dpkg::Deps::AND; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 4 | ▶ | use Dpkg::Deps::OR; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 4 | ▶ | use Dpkg::Deps::KnownFacts; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | =head1 FUNCTIONS | ||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | All the deps_* functions are exported by default. | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | =item $tribool = deps_eval_implication($rel_p, $v_p, $rel_q, $v_q) | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | ($rel_p, $v_p) and ($rel_q, $v_q) express two dependencies as (relation, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | version). The relation variable can have the following values that are | ||||||||||||||||||||||||||||||||||||||||||
| 74 | exported by L<Dpkg::Version>: REL_EQ, REL_LT, REL_LE, REL_GT, REL_GT. | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | This functions returns 1 if the "p" dependency implies the "q" | ||||||||||||||||||||||||||||||||||||||||||
| 77 | dependency. It returns 0 if the "p" dependency implies that "q" is | ||||||||||||||||||||||||||||||||||||||||||
| 78 | not satisfied. It returns undef when there's no implication. | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | The $v_p and $v_q parameter should be L<Dpkg::Version> objects. | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | 25 | ▶ | sub deps_eval_implication { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deps_eval_implication: called CC=49 SCAR=54.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 25 | my ($rel_p, $v_p, $rel_q, $v_q) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | # If versions are not valid, we cannot decide of any implication. | ||||||||||||||||||||||||||||||||||||||||||
| 88 | 25 | ▶ | return unless defined($v_p) and $v_p->is_valid(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $v_p and $v_p->is_valid
MC/DC0%0/2
defined $v_p and $v_p->is_valid
defined $v_p
$v_p->is_valid
Truth table33%1/3
A and B
A= defined $v_pB= $v_p->is_valid
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 25 | ▶ | return unless defined($v_q) and $v_q->is_valid(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $v_q and $v_q->is_valid
MC/DC0%0/2
defined $v_q and $v_q->is_valid
defined $v_q
$v_q->is_valid
Truth table33%1/3
A and B
A= defined $v_qB= $v_q->is_valid
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | # «q» wants an exact version, so «p» must provide that exact version. | ||||||||||||||||||||||||||||||||||||||||||
| 92 | # «p» disproves «q» if «q»'s version is outside the range enforced by «p». | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 25 | ▶ | if ($rel_q eq REL_EQ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 94 | 3 | ▶ | if ($rel_p eq REL_LT) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | ▶ | return ($v_p <= $v_q) ? 0 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | } elsif ($rel_p eq REL_LE) { | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | return ($v_p < $v_q) ? 0 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | } elsif ($rel_p eq REL_GT) { | ||||||||||||||||||||||||||||||||||||||||||
| 99 | 1 | ▶ | return ($v_p >= $v_q) ? 0 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | } elsif ($rel_p eq REL_GE) { | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | return ($v_p > $v_q) ? 0 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 102 | } elsif ($rel_p eq REL_EQ) { | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | return ($v_p == $v_q); | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | # A greater than clause may disprove a less than clause. An equal clause | ||||||||||||||||||||||||||||||||||||||||||
| 108 | # might as well. Otherwise, if «p»'s clause is <<, <=, or =, the version | ||||||||||||||||||||||||||||||||||||||||||
| 109 | # must be <= «q»'s to imply «q». | ||||||||||||||||||||||||||||||||||||||||||
| 110 | 22 | ▶ | if ($rel_q eq REL_LE) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 3 | ▶ | if ($rel_p eq REL_GT) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | return ($v_p >= $v_q) ? 0 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | } elsif ($rel_p eq REL_GE) { | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | ▶ | return ($v_p > $v_q) ? 0 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | } elsif ($rel_p eq REL_EQ) { | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | ▶ | return ($v_p <= $v_q) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 118 | # <<, <= | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | ▶ | return ($v_p <= $v_q) ? 1 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | # Similar, but << is stronger than <= so «p»'s version must be << «q»'s | ||||||||||||||||||||||||||||||||||||||||||
| 124 | # version if the «p» relation is <= or =. | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 19 | ▶ | if ($rel_q eq REL_LT) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | 4 | ▶ | if ($rel_p eq REL_GT or $rel_p eq REL_GE) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition100%3/3
$rel_p eq ">>" or $rel_p eq ">="
MC/DC100%2/2
$rel_p eq ">>" or $rel_p eq ">="
$rel_p eq ">>"
$rel_p eq ">="
Truth table100%3/3
A or B
A= $rel_p eq ">>"B= $rel_p eq ">="
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 2 | ▶ | return ($v_p >= $v_p) ? 0 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | } elsif ($rel_p eq REL_LT) { | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | return ($v_p <= $v_q) ? 1 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 130 | } elsif ($rel_p eq REL_EQ) { | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | ▶ | return ($v_p < $v_q) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 133 | # <<, <= | ||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | return ($v_p < $v_q) ? 1 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | # Same logic as above, only inverted. | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 15 | ▶ | if ($rel_q eq REL_GE) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 10 | ▶ | if ($rel_p eq REL_LT) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | return ($v_p <= $v_q) ? 0 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | } elsif ($rel_p eq REL_LE) { | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 2 | ▶ | return ($v_p < $v_q) ? 0 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 144 | } elsif ($rel_p eq REL_EQ) { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | return ($v_p >= $v_q) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 147 | # >>, >= | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 8 | ▶ | return ($v_p >= $v_q) ? 1 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 5 | ▶ | if ($rel_q eq REL_GT) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 5 | ▶ | if ($rel_p eq REL_LT or $rel_p eq REL_LE) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
$rel_p eq "<<" or $rel_p eq "<="
MC/DC50%1/2
$rel_p eq "<<" or $rel_p eq "<="
$rel_p eq "<<"
$rel_p eq "<="
Truth table66%2/3
A or B
A= $rel_p eq "<<"B= $rel_p eq "<="
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 1 | ▶ | return ($v_p <= $v_q) ? 0 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | } elsif ($rel_p eq REL_GT) { | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | return ($v_p >= $v_q) ? 1 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | } elsif ($rel_p eq REL_EQ) { | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | ▶ | return ($v_p > $v_q) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 159 | 3 | ▶ | return ($v_p > $v_q) ? 1 : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | =item $dep = deps_concat(@dep_list) | ||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | This function concatenates multiple dependency lines into a single line, | ||||||||||||||||||||||||||||||||||||||||||
| 169 | joining them with ", " if appropriate, and always returning a valid string. | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | 12 | ▶ | sub deps_concat { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deps_concat: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 12 | my (@dep_list) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 12 | return join ', ', grep { defined } @dep_list; | |||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||
| 179 | =item $dep = deps_parse($line, %opts) | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | This function parses the dependency line and returns an object, either a | ||||||||||||||||||||||||||||||||||||||||||
| 182 | L<Dpkg::Deps::AND> or a L<Dpkg::Deps::Union>. Various options can alter the | ||||||||||||||||||||||||||||||||||||||||||
| 183 | behavior of that function. | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | =item use_arch (defaults to 1) | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | Take into account the architecture restriction part of the dependencies. | ||||||||||||||||||||||||||||||||||||||||||
| 190 | Set to 0 to completely ignore that information. | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | =item host_arch (defaults to the current architecture) | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | Define the host architecture. By default it uses | ||||||||||||||||||||||||||||||||||||||||||
| 195 | Dpkg::Arch::get_host_arch() to identify the proper architecture. | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | =item build_arch (defaults to the current architecture) | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | Define the build architecture. By default it uses | ||||||||||||||||||||||||||||||||||||||||||
| 200 | Dpkg::Arch::get_build_arch() to identify the proper architecture. | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | =item reduce_arch (defaults to 0) | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | If set to 1, ignore dependencies that do not concern the current host | ||||||||||||||||||||||||||||||||||||||||||
| 205 | architecture. This implicitly strips off the architecture restriction | ||||||||||||||||||||||||||||||||||||||||||
| 206 | list so that the resulting dependencies are directly applicable to the | ||||||||||||||||||||||||||||||||||||||||||
| 207 | current architecture. | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | =item use_profiles (defaults to 1) | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | Take into account the profile restriction part of the dependencies. Set | ||||||||||||||||||||||||||||||||||||||||||
| 212 | to 0 to completely ignore that information. | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | =item build_profiles (defaults to no profile) | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | Define the active build profiles. By default no profile is defined. | ||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | =item reduce_profiles (defaults to 0) | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | If set to 1, ignore dependencies that do not concern the current build | ||||||||||||||||||||||||||||||||||||||||||
| 221 | profile. This implicitly strips off the profile restriction formula so | ||||||||||||||||||||||||||||||||||||||||||
| 222 | that the resulting dependencies are directly applicable to the current | ||||||||||||||||||||||||||||||||||||||||||
| 223 | profiles. | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | =item reduce_restrictions (defaults to 0) | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | If set to 1, ignore dependencies that do not concern the current set of | ||||||||||||||||||||||||||||||||||||||||||
| 228 | restrictions. This implicitly strips off any architecture restriction list | ||||||||||||||||||||||||||||||||||||||||||
| 229 | or restriction formula so that the resulting dependencies are directly | ||||||||||||||||||||||||||||||||||||||||||
| 230 | applicable to the current restriction. | ||||||||||||||||||||||||||||||||||||||||||
| 231 | This currently implies C<reduce_arch> and C<reduce_profiles>, and overrides | ||||||||||||||||||||||||||||||||||||||||||
| 232 | them if set. | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | =item union (defaults to 0) | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | If set to 1, returns a L<Dpkg::Deps::Union> instead of a L<Dpkg::Deps::AND>. | ||||||||||||||||||||||||||||||||||||||||||
| 237 | Use this when parsing non-dependency fields like Conflicts. | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | =item virtual (defaults to 0) | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | If set to 1, allow only virtual package version relations, that is none, | ||||||||||||||||||||||||||||||||||||||||||
| 242 | or "=". | ||||||||||||||||||||||||||||||||||||||||||
| 243 | This should be set whenever working with Provides fields. | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | =item build_dep (defaults to 0) | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | If set to 1, allow build-dep only arch qualifiers, that is ":native". | ||||||||||||||||||||||||||||||||||||||||||
| 248 | This should be set whenever working with build-deps. | ||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | =item tests_dep (defaults to 0) | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | If set to 1, allow tests-specific package names in dependencies, that is | ||||||||||||||||||||||||||||||||||||||||||
| 253 | "@" and "@builddeps@" (since dpkg 1.18.7). This should be set whenever | ||||||||||||||||||||||||||||||||||||||||||
| 254 | working with dependency fields from F<debian/tests/control>. | ||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | This option implicitly (and forcibly) enables C<build_dep> because test | ||||||||||||||||||||||||||||||||||||||||||
| 257 | dependencies are based on build dependencies (since dpkg 1.22.1). | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 76 | ▶ | sub deps_parse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deps_parse: called CC=40 SCAR=38.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 264 | 76 | my ($dep_line, %opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | # Validate arguments. | ||||||||||||||||||||||||||||||||||||||||||
| 267 | croak "invalid host_arch $opts{host_arch}" | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 76 | ▶ | if defined $opts{host_arch} and not defined debarch_to_debtuple($opts{host_arch}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $opts{"host_arch"} and not defined debarch_to_debtuple($opts{"host_arch"})
MC/DC100%2/2
defined $opts{"host_arch"} and not defined debarch_to_debtuple($opts{"host_arch"})
defined $opts{"host_arch"}
not defined debarch_to_debtuple($opts{"host_arch"})
Truth table100%3/3
A and not(B)
A= defined $opts{"host_arch"}B= not defined debarch_to_debtuple($opts{"host_arch"})
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | croak "invalid build_arch $opts{build_arch}" | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 72 | ▶ | if defined $opts{build_arch} and not defined debarch_to_debtuple($opts{build_arch}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $opts{"build_arch"} and not defined debarch_to_debtuple($opts{"build_arch"})
MC/DC50%1/2
defined $opts{"build_arch"} and not defined debarch_to_debtuple($opts{"build_arch"})
defined $opts{"build_arch"}
not defined debarch_to_debtuple($opts{"build_arch"})
Truth table66%2/3
A and not(B)
A= defined $opts{"build_arch"}B= not defined debarch_to_debtuple($opts{"build_arch"})
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | 68 | ▶ | $opts{use_arch} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"use_arch"} //= 1
MC/DC0%0/1
$opts{"use_arch"} //= 1
$opts{"use_arch"}
Truth table50%1/2
A
A= $opts{"use_arch"}
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 68 | ▶ | $opts{reduce_arch} //= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts{"reduce_arch"} //= 0
MC/DC100%1/1
$opts{"reduce_arch"} //= 0
$opts{"reduce_arch"}
Truth table100%2/2
A
A= $opts{"reduce_arch"}
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | 68 | ▶ | $opts{use_profiles} //= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"use_profiles"} //= 1
MC/DC0%0/1
$opts{"use_profiles"} //= 1
$opts{"use_profiles"}
Truth table50%1/2
A
A= $opts{"use_profiles"}
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 68 | ▶ | $opts{reduce_profiles} //= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts{"reduce_profiles"} //= 0
MC/DC100%1/1
$opts{"reduce_profiles"} //= 0
$opts{"reduce_profiles"}
Truth table100%2/2
A
A= $opts{"reduce_profiles"}
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 68 | ▶ | $opts{reduce_restrictions} //= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts{"reduce_restrictions"} //= 0
MC/DC100%1/1
$opts{"reduce_restrictions"} //= 0
$opts{"reduce_restrictions"}
Truth table100%2/2
A
A= $opts{"reduce_restrictions"}
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 68 | ▶ | $opts{union} //= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts{"union"} //= 0
MC/DC100%1/1
$opts{"union"} //= 0
$opts{"union"}
Truth table100%2/2
A
A= $opts{"union"}
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 68 | ▶ | $opts{virtual} //= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$opts{"virtual"} //= 0
MC/DC0%0/1
$opts{"virtual"} //= 0
$opts{"virtual"}
Truth table50%1/2
A
A= $opts{"virtual"}
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 68 | ▶ | $opts{build_dep} //= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts{"build_dep"} //= 0
MC/DC100%1/1
$opts{"build_dep"} //= 0
$opts{"build_dep"}
Truth table100%2/2
A
A= $opts{"build_dep"}
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | 68 | ▶ | $opts{tests_dep} //= 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts{"tests_dep"} //= 0
MC/DC100%1/1
$opts{"tests_dep"} //= 0
$opts{"tests_dep"}
Truth table100%2/2
A
A= $opts{"tests_dep"}
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 68 | ▶ | if ($opts{reduce_restrictions}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 8 | $opts{reduce_arch} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 284 | 8 | $opts{reduce_profiles} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 68 | ▶ | if ($opts{reduce_arch}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | 11 | ▶ | $opts{host_arch} //= get_host_arch(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$opts{"host_arch"} //= get_host_arch()
MC/DC0%0/2
$opts{"host_arch"} //= get_host_arch()
$opts{"host_arch"}
get_host_arch()
Truth table66%2/3
A //= B
A= $opts{"host_arch"}B= get_host_arch()
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 11 | ▶ | $opts{build_arch} //= get_build_arch(); | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$opts{"build_arch"} //= get_build_arch()
MC/DC0%0/2
$opts{"build_arch"} //= get_build_arch()
$opts{"build_arch"}
get_build_arch()
Truth table33%1/3
A //= B
A= $opts{"build_arch"}B= get_build_arch()
| |||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 68 | ▶ | if ($opts{reduce_profiles}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 12 | ▶ | $opts{build_profiles} //= [ get_build_profiles() ]; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$opts{"build_profiles"} //= [get_build_profiles()]
MC/DC100%1/1
$opts{"build_profiles"} //= [get_build_profiles()]
$opts{"build_profiles"}
Truth table100%2/2
A
A= $opts{"build_profiles"}
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | } | ||||||||||||||||||||||||||||||||||||||||||
| 293 | 68 | ▶ | if ($opts{tests_dep}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 2 | $opts{build_dep} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | # Options for Dpkg::Deps::Simple. | ||||||||||||||||||||||||||||||||||||||||||
| 298 | my %deps_options = ( | ||||||||||||||||||||||||||||||||||||||||||
| 299 | host_arch => $opts{host_arch}, | ||||||||||||||||||||||||||||||||||||||||||
| 300 | build_arch => $opts{build_arch}, | ||||||||||||||||||||||||||||||||||||||||||
| 301 | build_dep => $opts{build_dep}, | ||||||||||||||||||||||||||||||||||||||||||
| 302 | tests_dep => $opts{tests_dep}, | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 68 | ); | |||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | # Merge in a single-line. | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 68 | $dep_line =~ s/\s*[\r\n]\s*/ /g; | |||||||||||||||||||||||||||||||||||||||||
| 307 | # Strip trailing/leading spaces. | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 68 | $dep_line =~ s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||
| 309 | 68 | $dep_line =~ s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 68 | my @dep_list; | |||||||||||||||||||||||||||||||||||||||||
| 312 | 68 | foreach my $dep_and (split(/\s*,\s*/m, $dep_line)) { | |||||||||||||||||||||||||||||||||||||||||
| 313 | 235 | my @or_list = (); | |||||||||||||||||||||||||||||||||||||||||
| 314 | 235 | foreach my $dep_or (split(/\s*\|\s*/m, $dep_and)) { | |||||||||||||||||||||||||||||||||||||||||
| 315 | 268 | my $dep_simple = Dpkg::Deps::Simple->new($dep_or, %deps_options); | |||||||||||||||||||||||||||||||||||||||||
| 316 | 268 | ▶ | if (not defined $dep_simple->{package}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 5 | warning(g_('cannot parse dependency %s'), $dep_or); | |||||||||||||||||||||||||||||||||||||||||
| 318 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 263 | ▶ | if ($opts{virtual} && defined $dep_simple->{relation} && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$opts{"virtual"} and defined $dep_simple->{"relation"} and $dep_simple->{"relation"} ne "="
$opts{"virtual"} and defined $dep_simple->{"relation"}
MC/DC0%0/3
$opts{"virtual"} and defined $dep_simple->{"relation"} and $dep_simple->{"relation"} ne "="
$opts{"virtual"}
defined $dep_simple->{"relation"}
$dep_simple->{"relation"} ne "="
Truth table25%1/4
A and B and C
A= $opts{"virtual"}B= defined $dep_simple->{"relation"}C= $dep_simple->{"relation"} ne "="
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | $dep_simple->{relation} ne '=') { | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | warning(g_('virtual dependency contains invalid relation: %s'), | |||||||||||||||||||||||||||||||||||||||||
| 323 | $dep_simple->output); | ||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 263 | ▶ | $dep_simple->{arches} = undef if not $opts{use_arch}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | 263 | ▶ | if ($opts{reduce_arch}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 23 | $dep_simple->reduce_arch($opts{host_arch}); | |||||||||||||||||||||||||||||||||||||||||
| 329 | 23 | ▶ | next if not $dep_simple->arch_is_concerned($opts{host_arch}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | 257 | ▶ | $dep_simple->{restrictions} = undef if not $opts{use_profiles}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | 257 | ▶ | if ($opts{reduce_profiles}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 70 | $dep_simple->reduce_profiles($opts{build_profiles}); | |||||||||||||||||||||||||||||||||||||||||
| 334 | 70 | ▶ | next if not $dep_simple->profile_is_concerned($opts{build_profiles}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 228 | push @or_list, $dep_simple; | |||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 230 | ▶ | next if not @or_list; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 194 | ▶ | if (scalar @or_list == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 172 | push @dep_list, $or_list[0]; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 342 | 22 | my $dep_or = Dpkg::Deps::OR->new(); | |||||||||||||||||||||||||||||||||||||||||
| 343 | 22 | $dep_or->add($_) foreach (@or_list); | |||||||||||||||||||||||||||||||||||||||||
| 344 | 22 | push @dep_list, $dep_or; | |||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | } | ||||||||||||||||||||||||||||||||||||||||||
| 347 | 63 | my $dep_and; | |||||||||||||||||||||||||||||||||||||||||
| 348 | 63 | ▶ | if ($opts{union}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | 3 | $dep_and = Dpkg::Deps::Union->new(); | |||||||||||||||||||||||||||||||||||||||||
| 350 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 351 | 60 | $dep_and = Dpkg::Deps::AND->new(); | |||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 63 | foreach my $dep (@dep_list) { | |||||||||||||||||||||||||||||||||||||||||
| 354 | 191 | ▶ | if ($opts{union} and not $dep->isa('Dpkg::Deps::Simple')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$opts{"union"} and not $dep->isa("Dpkg::Deps::Simple")
MC/DC0%0/2
$opts{"union"} and not $dep->isa("Dpkg::Deps::Simple")
$opts{"union"}
not $dep->isa("Dpkg::Deps::Simple")
Truth table66%2/3
A and not(B)
A= $opts{"union"}B= not $dep->isa("Dpkg::Deps::Simple")
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | warning(g_('an union dependency can only contain simple dependencies')); | |||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 191 | $dep_and->add($dep); | |||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 63 | return $dep_and; | |||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | =item $bool = deps_iterate($deps, $callback_func) | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | This function visits all elements of the dependency object, calling the | ||||||||||||||||||||||||||||||||||||||||||
| 366 | callback function for each element. | ||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | The callback function is expected to return true when everything is fine, | ||||||||||||||||||||||||||||||||||||||||||
| 369 | or false if something went wrong, in which case the iteration will stop. | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | Return the same value as the callback function. | ||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | 72 | ▶ | sub deps_iterate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deps_iterate: called CC=1 SCAR=0.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | 72 | my ($deps, $callback_func) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 88 | ▶ | my $visitor_func = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.5
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 88 | foreach my $dep (@_) { | |||||||||||||||||||||||||||||||||||||||||
| 380 | 99 | ▶ | return unless defined $dep; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | 99 | ▶ | if ($dep->isa('Dpkg::Deps::Simple')) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | 83 | ▶ | return unless $callback_func->($dep); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 385 | 16 | ▶ | return unless __SUB__->($dep->get_deps()); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||
| 388 | 82 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 389 | 72 | }; | |||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | 72 | return $visitor_func->($deps); | |||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | =item $cmp = deps_compare($a, $b) | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | Implements a comparison operator between two dependency objects. | ||||||||||||||||||||||||||||||||||||||||||
| 397 | This function is mainly used to implement the sort() method. | ||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 4 | my %relation_ordering = ( | |||||||||||||||||||||||||||||||||||||||||
| 404 | undef => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 405 | REL_GE() => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 406 | REL_GT() => 2, | ||||||||||||||||||||||||||||||||||||||||||
| 407 | REL_EQ() => 3, | ||||||||||||||||||||||||||||||||||||||||||
| 408 | REL_LT() => 4, | ||||||||||||||||||||||||||||||||||||||||||
| 409 | REL_LE() => 5, | ||||||||||||||||||||||||||||||||||||||||||
| 410 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 32 | ▶ | sub deps_compare :prototype($$) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
deps_compare: called CC=14 SCAR=26.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | { | ||||||||||||||||||||||||||||||||||||||||||
| 414 | 32 | my ($aref, $bref) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | 32 | my (@as, @bs); | |||||||||||||||||||||||||||||||||||||||||
| 417 | 32 | ▶ | deps_iterate($aref, sub { push @as, @_ }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 32 | ▶ | deps_iterate($bref, sub { push @bs, @_ }); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | 32 | while (1) { | |||||||||||||||||||||||||||||||||||||||||
| 421 | 35 | my ($a, $b) = (shift @as, shift @bs); | |||||||||||||||||||||||||||||||||||||||||
| 422 | 35 | ▶ | my $aundef = not defined $a or $a->is_empty(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | 35 | ▶ | my $bundef = not defined $b or $b->is_empty(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | 35 | ▶ | return 0 if $aundef and $bundef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$aundef and $bundef
MC/DC0%0/2
$aundef and $bundef
$aundef
$bundef
Truth table66%2/3
A and B
A= $aundefB= $bundef
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 35 | ▶ | return -1 if $aundef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | 33 | ▶ | return 1 if $bundef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | 33 | ▶ | my $ar = $a->{relation} // 'undef'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$a->{"relation"} // "undef"
MC/DC100%1/1
$a->{"relation"} // "undef"
$a->{"relation"}
Truth table100%2/2
A
A= $a->{"relation"}
| |||||||||||||||||||||||||||||||||||||||||||
| 430 | 33 | ▶ | my $br = $b->{relation} // 'undef'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$b->{"relation"} // "undef"
MC/DC100%1/1
$b->{"relation"} // "undef"
$b->{"relation"}
Truth table100%2/2
A
A= $b->{"relation"}
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | 33 | ▶ | my $av = $a->{version} // ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$a->{"version"} // ""
MC/DC100%1/1
$a->{"version"} // ""
$a->{"version"}
Truth table100%2/2
A
A= $a->{"version"}
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | 33 | ▶ | my $bv = $b->{version} // ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$b->{"version"} // ""
MC/DC100%1/1
$b->{"version"} // ""
$b->{"version"}
Truth table100%2/2
A
A= $b->{"version"}
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | my $res = (($a->{package} cmp $b->{package}) || | ||||||||||||||||||||||||||||||||||||||||||
| 435 | 33 | ▶ | ($relation_ordering{$ar} <=> $relation_ordering{$br}) || | ||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
$a->{'package'} cmp $b->{'package'} || $relation_ordering{$ar} <=> $relation_ordering{$br} || $av cmp $bv
$a->{"package"} cmp $b->{"package"} or $relation_ordering{$ar} <=> $relation_ordering{$br}
MC/DC66%2/3
$a->{'package'} cmp $b->{'package'} || $relation_ordering{$ar} <=> $relation_ordering{$br} || $av cmp $bv
$a->{"package"} cmp $b->{"package"}
$relation_ordering{$ar} <=> $relation_ordering{$br}
$av cmp $bv
Truth table75%3/4
A or B || C
A= $a->{"package"} cmp $b->{"package"}B= $relation_ordering{$ar} <=> $relation_ordering{$br}C= $av cmp $bv
| |||||||||||||||||||||||||||||||||||||||||||
| 436 | ($av cmp $bv)); | ||||||||||||||||||||||||||||||||||||||||||
| 437 | 33 | ▶ | return $res if $res != 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | =head1 CLASSES - Dpkg::Deps::* | ||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||
| 443 | There are several kind of dependencies. A L<Dpkg::Deps::Simple> dependency | ||||||||||||||||||||||||||||||||||||||||||
| 444 | represents a single dependency statement (it relates to one package only). | ||||||||||||||||||||||||||||||||||||||||||
| 445 | L<Dpkg::Deps::Multiple> dependencies are built on top of this class | ||||||||||||||||||||||||||||||||||||||||||
| 446 | and combine several dependencies in different manners. L<Dpkg::Deps::AND> | ||||||||||||||||||||||||||||||||||||||||||
| 447 | represents the logical "AND" between dependencies while L<Dpkg::Deps::OR> | ||||||||||||||||||||||||||||||||||||||||||
| 448 | represents the logical "OR". L<Dpkg::Deps::Multiple> objects can contain | ||||||||||||||||||||||||||||||||||||||||||
| 449 | L<Dpkg::Deps::Simple> object as well as other L<Dpkg::Deps::Multiple> objects. | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | In practice, the code is only meant to handle the realistic cases which, | ||||||||||||||||||||||||||||||||||||||||||
| 452 | given Debian's dependencies structure, imply those restrictions: AND can | ||||||||||||||||||||||||||||||||||||||||||
| 453 | contain Simple or OR objects, OR can only contain Simple objects. | ||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | L<Dpkg::Deps::KnownFacts> is a special class that is used while evaluating | ||||||||||||||||||||||||||||||||||||||||||
| 456 | dependencies and while trying to simplify them. It represents a set of | ||||||||||||||||||||||||||||||||||||||||||
| 457 | installed packages along with the virtual packages that they might | ||||||||||||||||||||||||||||||||||||||||||
| 458 | provide. | ||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | =head1 CHANGES | ||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | =head2 Version 1.07 (dpkg 1.20.0) | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | New option: Add virtual option to deps_parse(). | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | =head2 Version 1.06 (dpkg 1.18.7; module version bumped on dpkg 1.18.24) | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | New option: Add tests_dep option to deps_parse(). | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | =head2 Version 1.05 (dpkg 1.17.14) | ||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | New function: deps_iterate(). | ||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | =head2 Version 1.04 (dpkg 1.17.10) | ||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | New options: Add use_profiles, build_profiles, reduce_profiles and | ||||||||||||||||||||||||||||||||||||||||||
| 477 | reduce_restrictions to deps_parse(). | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | =head2 Version 1.03 (dpkg 1.17.0) | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | New option: Add build_arch option to deps_parse(). | ||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | =head2 Version 1.02 (dpkg 1.17.0) | ||||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | New function: deps_concat() | ||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | =head2 Version 1.01 (dpkg 1.16.1) | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | <Used to document changes to Dpkg::Deps::* modules before they were split.> | ||||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | =head2 Version 1.00 (dpkg 1.15.6) | ||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | Mark the module as public. | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||
| 497 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||