blib/lib/CPAN/Plugin/Sysdeps.pm

filter: Statementstmt 90.4% 1472 / 1628 Branchbran 56.9% 198 / 348 Conditioncond 65.4% 53 / 81 MC/DCmcdc 32.6% 17 / 52 Subroutinesub 98.1% 421 / 429 Podpod 66.6% 2 / 3 totaltotal 85.1% 2163 / 2541 CC 215 SCAR 27.5
CC
215
Cov
84%
new
89.0
_detect_linux_distribution_fallback
72.0
_detect_linux_distribution_lsb_release
56.0
CRAP 15.6
↑ Summary blib/lib/CPAN/Plugin/Sysdeps/Mapping.pm »
1 package CPAN::Plugin::Sysdeps;
2  
3 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 9 our $VERSION = '0.83';
7  
8 9 ▶use List::Util 'first';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 9 our $TRAVERSE_ONLY; # only for testing
11  
12 9 ▶use constant SUPPORTED_NUMERICAL_OPS => ['<','<=','==','>','>='];
Subroutine BEGIN: called CC=1 SCAR=0.0
13 9 use constant SUPPORTED_NUMERICAL_OPS_RX => do {
14 9 my $rx = '^(' . join('|', map { quotemeta } @{SUPPORTED_NUMERICAL_OPS()}) . ')$';
15 9 qr{$rx};
16 9 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 9 our @OS_RELEASE_PATH_CANDIDATES = ('/etc/os-release', '/usr/lib/os-release');
19  
20 sub new {
21 44 ▶ my($class, @args) = @_;
Subroutine new: called CC=42 SCAR=44.9
Pod documented
22  
23 44 my $installer;
24 44 my $batch = 0;
25 44 my $dryrun = 0;
26 44 my $debug = 0;
27 44 my @additional_mappings;
28 my @args_errors;
29 44 my $options;
30 44 for my $arg (@args) {
31 121 ▶ if (ref $arg eq 'HASH') {
Branch: 7 branches
BranchTrueFalseTotal
if (ref $arg eq 'HASH') { } 15 106 121
elsif ($arg =~ /^(apt-get|aptitude|pkg|pkg_add|yum|dnf|chocolatey|homebrew|apk)$/) { } 24 82 106
elsif ($arg eq 'batch') { } 33 49 82
elsif ($arg eq 'interactive') { } 1 48 49
elsif ($arg eq 'dryrun') { } 32 16 48
elsif ($arg =~ /^mapping=(.*)$/) { } 16 0 16
elsif ($arg =~ /^debug(?:=(\d+))?$/) { } 0 0 0
32 15 ▶ if ($options) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options) { } 0 15 15
33 0 die "Cannot handle multiple option hashes";
34 } else {
35 15 $options = $arg;
36 }
37 } elsif ($arg =~ m{^(apt-get|aptitude|pkg|pkg_add|yum|dnf|chocolatey|homebrew|apk)$}) { # XXX are there more package installers?
38 24 $installer = $1;
39 } elsif ($arg eq 'batch') {
40 33 $batch = 1;
41 } elsif ($arg eq 'interactive') {
42 1 $batch = 0;
43 } elsif ($arg eq 'dryrun') {
44 32 $dryrun = 1;
45 } elsif ($arg =~ m{^mapping=(.*)$}) {
46 16 push @additional_mappings, $1;
47 } elsif ($arg =~ m{^debug(?:=(\d+))?$}) {
48 0 ▶ $debug = defined $1 ? $1 : 1;
Branch: 1 branch
BranchTrueFalseTotal
defined $1 ? : 0 0 0
49 } else {
50 0 push @args_errors, $arg;
51 }
52 }
53 44 ▶ if (@args_errors) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args_errors) 0 44 44
54 0 ▶ die 'Unrecognized ' . __PACKAGE__ . ' argument' . (@args_errors != 1 ? 's' : '') . ": @args_errors\n";
Branch: 1 branch
BranchTrueFalseTotal
@args_errors != 1 ? : 0 0 0
55 }
56  
57 44 ▶ if (exists $ENV{CPAN_PLUGIN_SYSDEPS_DEBUG}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ENV{"CPAN_PLUGIN_SYSDEPS_DEBUG"}) 0 44 44
58 0 $debug = $ENV{CPAN_PLUGIN_SYSDEPS_DEBUG};
59 }
60 44 ▶ if ($debug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug) 0 44 44
61 0 require Data::Dumper; # we'll need it
62 }
63  
64 44 ▶ my $os = $options->{os} || $^O;
Condition66%2/3
$options->{'os'} || $^O
l!l&&r!l&&!r
15290
MC/DC0%0/2
$options->{'os'} || $^O
$options->{'os'} $^O
Truth table66%2/3
A || B
A= $options->{'os'}B= $^O
ABresult
1X1
011
000
65 44 my $osvers = '';
66 44 my $linuxdistro = '';
67 44 my $linuxdistroversion = 0;
68 44 my $linuxdistrocodename = '';
69 44 ▶ if ($os eq 'linux') {
Branch: 2 branches
BranchTrueFalseTotal
if ($os eq 'linux') { } 35 9 44
elsif ($os eq 'freebsd' or $os eq 'openbsd' or $os eq 'dragonfly') { } 9 0 9
70 35 my $linux_info;
71 my $get_linux_info = sub {
72 87 ▶ return $linux_info if $linux_info;
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $linux_info 58 29 87
73 29 return $linux_info = _detect_linux_distribution();
74 35 };
75 35 ▶ if (defined $options->{linuxdistro}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $options->{'linuxdistro'}) { } 6 29 35
76 6 $linuxdistro = $options->{linuxdistro};
77 } else {
78 29 $linuxdistro = $get_linux_info->()->{linuxdistro};
79 }
80  
81 35 ▶ if (defined $options->{linuxdistroversion}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $options->{'linuxdistroversion'}) { } 6 29 35
82 6 $linuxdistroversion = $options->{linuxdistroversion};
83 } else {
84 29 $linuxdistroversion = $get_linux_info->()->{linuxdistroversion}; # XXX make it a version object? or make sure it's just X.Y?
85 }
86  
87 35 ▶ if (defined $options->{linuxdistrocodename}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $options->{'linuxdistrocodename'}) { } 6 29 35
88 6 $linuxdistrocodename = $options->{linuxdistrocodename};
89 } else {
90 29 $linuxdistrocodename = $get_linux_info->()->{linuxdistrocodename};
91 }
92 ▶ } elsif (($os eq 'freebsd') || ($os eq 'openbsd') || ($os eq 'dragonfly')) {
Condition33%2/6
$os eq "freebsd" or $os eq "openbsd" or $os eq "dragonfly"
l!l&&r!l&&!r
900
$os eq "freebsd" or $os eq "openbsd"
l!l&&r!l&&!r
900
MC/DC0%0/3
$os eq "freebsd" or $os eq "openbsd" or $os eq "dragonfly"
$os eq "freebsd" $os eq "openbsd" $os eq "dragonfly"
Truth table25%1/4
A or B or C
A= $os eq "freebsd"B= $os eq "openbsd"C= $os eq "dragonfly"
ABCresult
1XX1
01X1
0011
0000
93 # Note: don't use $Config{osvers}, as this is just the OS
94 # version of the system which built the current perl, not the
95 # actually running OS version.
96 9 ▶ if (defined $options->{osvers}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $options->{'osvers'}) { } 9 0 9
97 9 $osvers = $options->{osvers};
98 } else {
99 0 chomp($osvers = `/sbin/sysctl -n kern.osrelease`);
100 }
101 }
102  
103 44 ▶ if (!$installer) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($installer) 20 24 44
104 20 ▶ if ($os eq 'freebsd' || $os eq 'dragonfly') {
Branch: 6 branches
BranchTrueFalseTotal
if ($os eq 'freebsd' or $os eq 'dragonfly') { } 9 11 20
elsif ($os eq 'gnukfreebsd') { } 0 11 11
elsif ($os eq 'openbsd') { } 0 11 11
elsif ($os eq 'linux') { } 11 0 11
elsif ($os eq 'MSWin32') { } 0 0 0
elsif ($os eq 'darwin') { } 0 0 0
Condition66%2/3
$os eq "freebsd" or $os eq "dragonfly"
l!l&&r!l&&!r
9011
MC/DC50%1/2
$os eq "freebsd" or $os eq "dragonfly"
$os eq "freebsd" $os eq "dragonfly"
Truth table66%2/3
A or B
A= $os eq "freebsd"B= $os eq "dragonfly"
ABresult
1X1
011
000
105 9 $installer = 'pkg';
106 } elsif ($os eq 'gnukfreebsd') {
107 0 $installer = 'apt-get';
108 } elsif ($os eq 'openbsd') {
109 0 $installer = 'pkg_add';
110 } elsif ($os eq 'linux') {
111 11 ▶ if (__PACKAGE__->_is_linux_debian_like($linuxdistro)) {
Branch: 3 branches
BranchTrueFalseTotal
if (__PACKAGE__->_is_linux_debian_like($linuxdistro)) { } 10 1 11
elsif (__PACKAGE__->_is_linux_fedora_like($linuxdistro)) { } 1 0 1
elsif (__PACKAGE__->_is_linux_alpine_like($linuxdistro)) { } 0 0 0
112 10 $installer = 'apt-get';
113 } elsif (__PACKAGE__->_is_linux_fedora_like($linuxdistro)) {
114 1 ▶ if (_detect_dnf()) {
Branch: 1 branch
BranchTrueFalseTotal
if (_detect_dnf()) { } 0 1 1
115 0 $installer = 'dnf';
116 } else {
117 1 $installer = 'yum';
118 }
119 } elsif (__PACKAGE__->_is_linux_alpine_like($linuxdistro)) {
120 0 $installer = 'apk';
121 } else {
122 0 die __PACKAGE__ . " has no support for linux distribution $linuxdistro $linuxdistroversion\n";
123 }
124 } elsif( $os eq 'MSWin32' ) {
125 0 $installer = 'chocolatey';
126 } elsif ($os eq 'darwin') {
127 0 $installer = 'homebrew';
128 } else {
129 0 die __PACKAGE__ . " has no support for operating system $os\n";
130 }
131 }
132  
133 44 my @mapping;
134 44 for my $mapping (@additional_mappings, 'CPAN::Plugin::Sysdeps::Mapping') {
135 60 ▶ if (-r $mapping) {
Branch: 1 branch
BranchTrueFalseTotal
if (-r $mapping) { } 16 44 60
136 16 ▶ open my $fh, '<', $mapping
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $mapping or die "Can't load ${mapping}: $!" 0 16 16
137 or die "Can't load $mapping: $!";
138 16 local $/;
139 16 my $buf = <$fh>;
140 16 push @mapping, eval $buf;
141 16 ▶ die "Error while loading $mapping: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 16 16
142 } else {
143 44 ▶ eval "require $mapping"; die "Can't load $mapping: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 44 44
144 44 push @mapping, $mapping->mapping;
145 }
146 }
147  
148 44 my %config =
149 (
150 installer => $installer,
151 batch => $batch,
152 dryrun => $dryrun,
153 debug => $debug,
154 os => $os,
155 osvers => $osvers,
156 linuxdistro => $linuxdistro,
157 linuxdistroversion => $linuxdistroversion,
158 linuxdistrocodename => $linuxdistrocodename,
159 mapping => \@mapping,
160 _mapper_ran => {},
161 _containsmods_warned => 0,
162 );
163 44 my $self = bless \%config, $class;
164 44 ▶ if (eval { require Hash::Util; 1 }) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require Hash::Util; 1 } }) 44 0 44
165 44 Hash::Util::lock_keys($self);
166 }
167 44 $self;
168 }
169  
170 # CPAN.pm plugin hook method (primary)
171 sub post_get {
172 16 ▶ my($self, $dist) = @_;
Subroutine post_get: called CC=1 SCAR=0.0
Pod documented
173 16 $self->_maybe_run_mapper($dist);
174 }
175  
176 # CPAN.pm plugin hook method (secondary, needed only for the "cpan ." workaround)
177 sub pre_make {
178 2 ▶ my($self, $dist) = @_;
Subroutine pre_make: called CC=1 SCAR=0.0
Pod undocumented
179 2 $self->_maybe_run_mapper($dist);
180 }
181  
182 # Helpers/Internal functions/methods
183 sub _maybe_run_mapper {
184 18 ▶ my($self, $dist) = @_;
Subroutine _maybe_run_mapper: called CC=2 SCAR=7.1
185 18 ▶ if (!$self->{_mapper_ran}{$dist->id}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"_mapper_ran"}{$dist->id}) 18 0 18
186 18 $self->_run_mapper($dist);
187 }
188 }
189  
190 sub _run_mapper {
191 18 ▶ my($self, $dist) = @_;
Subroutine _run_mapper: called CC=6 SCAR=20.5
192  
193 18 $self->{_mapper_ran}{$dist->id} = 1;
194  
195 18 my @packages = $self->_map_cpandist($dist);
196 17 ▶ if (@packages) {
Branch: 1 branch
BranchTrueFalseTotal
if (@packages) 4 13 17
197 4 my @uninstalled_packages = $self->_filter_uninstalled_packages(@packages);
198 4 ▶ if (@uninstalled_packages) {
Branch: 1 branch
BranchTrueFalseTotal
if (@uninstalled_packages) 4 0 4
199 4 my @cmds = $self->_install_packages_commands(@uninstalled_packages);
200 4 for my $cmd (@cmds) {
201 4 ▶ if ($self->{dryrun}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'dryrun'}) { } 4 0 4
202 4 warn "DRYRUN: @$cmd\n";
203 } else {
204 0 warn "INFO: run @$cmd...\n";
205  
206 0 system @$cmd;
207 0 ▶ if ($? != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
208 0 die "@$cmd failed, stop installation";
209 }
210 }
211 }
212 }
213 }
214 }
215  
216 sub _detect_linux_distribution {
217 30 ▶ my $info = _detect_linux_distribution_os_release();
Subroutine _detect_linux_distribution: called CC=3 SCAR=17.3
218 30 ▶ return $info if $info;
Branch: 1 branch
BranchTrueFalseTotal
if $info 30 0 30
219 0 ▶ if (-x '/usr/bin/lsb_release') {
Branch: 1 branch
BranchTrueFalseTotal
if (-x '/usr/bin/lsb_release') { } 0 0 0
220 0 _detect_linux_distribution_lsb_release();
221 } else {
222 0 _detect_linux_distribution_fallback();
223 }
224 }
225  
226 sub _get_os_release {
227 44 ▶ for my $candidate_file (@OS_RELEASE_PATH_CANDIDATES) {
Subroutine _get_os_release: called CC=5 SCAR=16.1
228 44 ▶ if (open my $fh, '<', $candidate_file) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, "<", $candidate_file) 43 1 44
229 43 my %c;
230 43 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 517 43 560
231 517 ▶ if (my($k,$v) = $_ =~ m{^(.*?)=["']?(.*?)["']?$}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $_ =~ /^(.*?)=["']?(.*?)["']?$/) 509 8 517
232 509 $c{$k} = $v;
233 }
234 }
235 43 return \%c;
236 }
237 }
238 }
239  
240 sub _detect_linux_distribution_os_release {
241 43 ▶ my $c = _get_os_release();
Subroutine _detect_linux_distribution_os_release: called CC=5 SCAR=16.1
242 43 ▶ if ($c) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c) 42 1 43
243 42 my %info;
244 42 $info{linuxdistro} = $c->{ID};
245 42 $info{linuxdistroversion} = $c->{VERSION_ID};
246 42 $info{linuxdistrocodename} = $c->{VERSION_CODENAME};
247 # heuristics
248 42 ▶ if (!defined $info{linuxdistrocodename} && $info{linuxdistro} eq 'debian' && $c->{VERSION} =~ m{^\d+\s+\((.+)\)$}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $info{"linuxdistrocodename"} and $info{"linuxdistro"} eq "debian" and $c->{"VERSION"} =~ /^\d+\s+\((.+)\)$/) 2 40 42
Condition83%5/6
not defined $info{"linuxdistrocodename"} and $info{"linuxdistro"} eq "debian" and $c->{"VERSION"} =~ /^\d+\s+\((.+)\)$/
!ll&&!rl&&r
4002
not defined $info{"linuxdistrocodename"} and $info{"linuxdistro"} eq "debian"
!ll&&!rl&&r
3282
MC/DC66%2/3
not defined $info{"linuxdistrocodename"} and $info{"linuxdistro"} eq "debian" and $c->{"VERSION"} =~ /^\d+\s+\((.+)\)$/
not defined $info{"linuxdistrocodename"} $info{"linuxdistro"} eq "debian" $c->{"VERSION"} =~ /^\d+\s+\((.+)\)$/
Truth table75%3/4
not(A) and B and C
A= not defined $info{"linuxdistrocodename"}B= $info{"linuxdistro"} eq "debian"C= $c->{"VERSION"} =~ /^\d+\s+\((.+)\)$/
ABCresult
0XX0
10X0
1100
1111
249 2 $info{linuxdistrocodename} = $1;
250 }
251 42 return \%info;
252 }
253 1 undef;
254 }
255  
256 sub _detect_linux_distribution_lsb_release {
257 0 ▶ my %info;
Subroutine _detect_linux_distribution_lsb_release: not called CC=7 SCAR=40.3
258 0 my @cmd = ('lsb_release', '-irc');
259 0 ▶ open my $fh, '-|', @cmd
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "-|", @cmd or die "Error while running '@{cmd}': $!" 0 0 0
260 or die "Error while running '@cmd': $!";
261 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
262 0 chomp;
263 0 ▶ if (m{^Distributor ID:\s+(.*)}) {
Branch: 3 branches
BranchTrueFalseTotal
if (/^Distributor ID:\s+(.*)/) { } 0 0 0
elsif (/^Release:\s+(.*)/) { } 0 0 0
elsif (/^Codename:\s+(.*)/) { } 0 0 0
264 0 $info{linuxdistro} = lc $1;
265 } elsif (m{^Release:\s+(.*)}) {
266 0 $info{linuxdistroversion} = $1;
267 } elsif (m{^Codename:\s+(.*)}) {
268 0 $info{linuxdistrocodename} = $1;
269 } else {
270 0 warn "WARNING: unexpected '@cmd' output '$_'";
271 }
272 }
273 0 ▶ close $fh
Branch: 1 branch
BranchTrueFalseTotal
close $fh or die "Error while running '@{cmd}': $!" 0 0 0
274 or die "Error while running '@cmd': $!";
275 0 \%info;
276 }
277  
278 sub _detect_linux_distribution_fallback {
279 0 ▶ if (open my $fh, '<', '/etc/redhat-release') {
Subroutine _detect_linux_distribution_fallback: not called CC=8 SCAR=42.8
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, "<", "/etc/redhat-release") 0 0 0
280 0 my $contents = <$fh>;
281 0 ▶ if ($contents =~ m{^(CentOS|Rocky|RedHat|Fedora) (?:Linux )?release (\d+)\S*( \((.*?)\))?}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($contents =~ /^(CentOS|Rocky|RedHat|Fedora) (?:Linux )?release (\d+)\S*( \((.*?)\))?/) 0 0 0
282 0 ▶ return {linuxdistro => lc $1, linuxdistroversion => $2, linuxdistrocodename => defined $3 ? $3 : ''};
Branch: 1 branch
BranchTrueFalseTotal
defined $3 ? : 0 0 0
283 }
284 }
285 0 ▶ if (open my $fh, '<', '/etc/issue') {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, '<', '/etc/issue') { } 0 0 0
286 0 chomp(my $line = <$fh>);
287 0 ▶ if ($line =~ m{^Linux Mint (\d+) (\S+)}) {
Branch: 3 branches
BranchTrueFalseTotal
if ($line =~ /^Linux Mint (\d+) (\S+)/) { } 0 0 0
elsif ($line =~ m[^(Debian) GNU/Linux (\d+)]) { } 0 0 0
elsif ($line =~ /^(Ubuntu) (\d+\.\d+)/) { } 0 0 0
288 0 return {linuxdistro => lc('LinuxMint'), linuxdistroversion => $1, linuxdistrocodename => $2};
289 } elsif ($line =~ m{^(Debian) GNU/Linux (\d+)}) {
290 0 my %info = (linuxdistro => lc $1, linuxdistroversion => $2);
291 $info{linuxdistrocodename} =
292 {
293 6 => 'squeeze',
294 7 => 'wheezy',
295 8 => 'jessie',
296 9 => 'stretch',
297 10 => 'buster',
298 11 => 'bullseye',
299 12 => 'bookworm',
300 13 => 'trixie',
301 14 => 'forky',
302 15 => 'duke',
303 0 }->{$info{linuxdistroversion}};
304 0 return \%info;
305 } elsif ($line =~ m{^(Ubuntu) (\d+\.\d+)}) {
306 0 my %info = (linuxdistro => lc $1, linuxdistroversion => $2);
307 $info{linuxdistrocodename} =
308 {
309 '12.04' => 'precise',
310 '14.04' => 'trusty',
311 '16.04' => 'xenial',
312 '18.04' => 'bionic',
313 '20.04' => 'focal',
314 '22.04' => 'jammy',
315 '24.04' => 'noble',
316 '26.04' => 'resolute',
317 0 }->{$info{linuxdistroversion}};
318 0 return \%info;
319 } else {
320 0 warn "WARNING: don't know how to handle '$line'";
321 }
322 } else {
323 0 warn "WARNING: no /etc/issue available";
324 }
325 0 return {};
326 }
327  
328 sub _is_linux_debian_like {
329 4322 ▶ my(undef, $linuxdistro) = @_;
Subroutine _is_linux_debian_like: called CC=1 SCAR=0.0
330 4322 $linuxdistro =~ m{^(debian|ubuntu|linuxmint)$};
331 }
332  
333 sub _is_linux_fedora_like {
334 2713 ▶ my(undef, $linuxdistro) = @_;
Subroutine _is_linux_fedora_like: called CC=1 SCAR=0.0
335 2713 $linuxdistro =~ m{^(fedora|redhat|centos|rocky)$};
336 }
337  
338 sub _is_linux_alpine_like {
339 12 ▶ my(undef, $linuxdistro) = @_;
Subroutine _is_linux_alpine_like: called CC=1 SCAR=0.0
340 12 $linuxdistro =~ m{^(alpine)$};
341 }
342  
343 21 ▶sub _is_apt_installer { shift->{installer} =~m{^(apt-get|aptitude)$} }
Subroutine _is_apt_installer: called CC=1 SCAR=0.0
344  
345 # Run a process in an elevated window, wait for its exit
346 sub _win32_run_elevated {
347 0 ▶ my($exe, @args) = @_;
Subroutine _win32_run_elevated: not called CC=2 SCAR=17.9
348
349 0 ▶ my $args = join " ", map { if(/[ "]/) { s!"!\\"!g; qq{"$_"} } else { $_ }} @args;
Branch: 1 branch
BranchTrueFalseTotal
if (/[ "]/) { } 0 0 0
350  
351 0 my $ps1 = sprintf q{powershell -NonInteractive -NoProfile -Command "$process = Start-Process '%s' -PassThru -ErrorAction Stop -ArgumentList '%s' -Verb RunAs -Wait; Exit $process.ExitCode"},
352 $exe, $args;
353  
354 0 $ps1;
355 }
356  
357 sub _debug {
358 96478 ▶ my $self = shift;
Subroutine _debug: called CC=3 SCAR=19.2
359 96478 ▶ if ($self->{debug}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"}) 0 96478 96478
360 0 print STDERR 'DEBUG: ';
361 print STDERR join('', map {
362 0 ▶ if (ref $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_) { } 0 0 0
363 0 Data::Dumper->new([$_])->Terse(1)->Indent(0)->Dump;
364 } else {
365 0 $_;
366 }
367 } @_);
368 0 print STDERR "\n";
369 }
370 }
371  
372 sub _dist_get_base_id {
373 834 ▶ my($self, $dist) = @_;
Subroutine _dist_get_base_id: called CC=2 SCAR=9.9
374  
375 # compat for older CPAN.pm (1.76)
376 834 ▶ if (!$dist->can('base_id')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dist->can("base_id")) 0 834 834
377 0 my $id = $dist->id();
378 0 my $base_id = File::Basename::basename($id);
379 0 $base_id =~ s{\.(?:tar\.(bz2|gz|Z)|t(?:gz|bz)|zip)$}{}i;
380 0 return $base_id;
381 }
382  
383 834 $dist->base_id();
384 }
385  
386 sub _dist_containsmods {
387 8608 ▶ my($self, $dist) = @_;
Subroutine _dist_containsmods: called CC=5 SCAR=16.1
388 8608 my @containsmods = $dist->containsmods;
389 8608 ▶ if (!@containsmods && $self->_dist_get_base_id($dist) eq '.') {
Branch: 1 branch
BranchTrueFalseTotal
if (not @containsmods and $self->_dist_get_base_id($dist) eq ".") 808 7800 8608
Condition66%2/3
not @containsmods and $self->_dist_get_base_id($dist) eq "."
!ll&&!rl&&r
78000808
MC/DC50%1/2
not @containsmods and $self->_dist_get_base_id($dist) eq "."
not @containsmods $self->_dist_get_base_id($dist) eq "."
Truth table66%2/3
not(A) and B
A= not @containsmodsB= $self->_dist_get_base_id($dist) eq "."
ABresult
0X0
100
111
390 808 ▶ if (defined $ENV{CPAN_PLUGIN_SYSDEPS_MODULE}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{"CPAN_PLUGIN_SYSDEPS_MODULE"}) 397 411 808
391 397 return $ENV{CPAN_PLUGIN_SYSDEPS_MODULE};
392 }
393 411 my $id = $dist->id();
394 411 ▶ if (!$self->{_containsmods_warned}++) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_containsmods_warned"}++) 1 410 411
395 1 warn <<EOF;
396 WARNING: running in local directory '$id'. Please define the environment
397 variable CPAN_PLUGIN_SYSDEPS_MODULE to the primary module of
398 the tested distribution.
399 EOF
400 }
401 }
402 8211 @containsmods;
403 }
404  
405 sub _map_cpandist {
406 32 ▶ my($self, $dist) = @_;
Subroutine _map_cpandist: called CC=6 SCAR=17.9
407  
408 32 my $get_base_id = do {
409 32 my $cached_base_id;
410 sub {
411 22 ▶ return $cached_base_id if defined $cached_base_id;
Subroutine __ANON__: called CC=2 SCAR=7.2
Branch: 1 branch
BranchTrueFalseTotal
if defined $cached_base_id 0 22 22
412 22 $cached_base_id = $self->_dist_get_base_id($dist);
413 32 };
414 };
415  
416 # smartmatch for regexp/string/array without ~~, 5.8.x compat!
417 # also add support for numerical comparisons
418 my $smartmatch = sub ($$) {
419 16169 ▶ my($left, $right) = @_;
Subroutine __ANON__: called CC=13 SCAR=25.6
420 9 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
421 16169 ▶ if (ref $right eq 'Regexp') {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $right eq 'Regexp') { } 183 15986 16169
elsif (ref $right eq 'ARRAY') { } 2029 13957 15986
elsif (ref $right eq 'HASH') { } 425 13532 13957
422 183 ▶ return 1 if $left =~ $right;
Branch: 1 branch
BranchTrueFalseTotal
if $left =~ /$right/ 3 180 183
423 } elsif (ref $right eq 'ARRAY') {
424 2029 ▶ return 1 if first { (!defined $left && !defined $_) || ($_ eq $left) } @$right;
Subroutine __ANON__: called CC=3 SCAR=11.3
Branch: 2 branches
BranchTrueFalseTotal
if &first(sub { not defined $left || defined $_ or $_ eq $left; } , @$right) 121 1908 2029
not defined $left || defined $_ or $_ eq $left 6427 0 6427
Condition66%2/3
defined $left || defined $_
l!l&&r!l&&!r
487515520
MC/DC0%0/2
defined $left || defined $_
defined $left defined $_
Truth table66%2/3
A || B
A= defined $leftB= defined $_
ABresult
1X1
011
000
425 } elsif (ref $right eq 'HASH') {
426 425 for my $op (keys %$right) {
427 431 ▶ if ($op !~ SUPPORTED_NUMERICAL_OPS_RX) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($op =~ /^(\<|\<\=|\=\=|\>|\>\=)$/) 0 431 431
428 0 die "Unsupported operator '$op', only supported: @{SUPPORTED_NUMERICAL_OPS()}";
429 }
430 431 my $val = $right->{$op};
431 431 my $code = 'no warnings q(numeric); $left '.$op.' $val';
432 431 ▶ my $res = eval $code;
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
433 431 ▶ die "Evaluation of '$code' failed: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 431 431
434 431 ▶ return 0 if !$res;
Branch: 1 branch
BranchTrueFalseTotal
unless $res 259 172 431
435 }
436 166 return 1;
437 } else {
438 13532 ▶ return 1 if !defined $left && !defined $right;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $left or defined $right 0 13532 13532
Condition66%2/3
defined $left or defined $right
l!l&&r!l&&!r
13475570
MC/DC0%0/2
defined $left or defined $right
defined $left defined $right
Truth table66%2/3
A or B
A= defined $leftB= defined $right
ABresult
1X1
011
000
439 13532 ▶ return 1 if $left eq $right;
Branch: 1 branch
BranchTrueFalseTotal
if $left eq $right 81 13451 13532
440 }
441 32 };
442  
443 32 my $handle_mapping_entry; $handle_mapping_entry = sub {
444 37366 ▶ my($entry, $level) = @_;
Subroutine __ANON__: called CC=36 SCAR=36.4
445 37366 ▶ for(my $map_i=0; $map_i <= $#$entry; $map_i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($map_i <= $entry->$#*) 66801 19196 85997
446 66801 my $key_or_subentry = $entry->[$map_i];
447 66801 ▶ if (ref $key_or_subentry eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $key_or_subentry eq 'ARRAY') { } 28738 38063 66801
elsif (ref $key_or_subentry eq 'CODE') { } 1 38062 38063
448 28738 $self->_debug(' ' x $level . ' traverse another tree level');
449 28738 my $res = $handle_mapping_entry->($key_or_subentry, $level+1);
450 28737 ▶ return $res if $res && !$TRAVERSE_ONLY;
Branch: 1 branch
BranchTrueFalseTotal
if $res and not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY 24 28713 28737
Condition100%3/3
$res and not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
!ll&&!rl&&r
142771443624
MC/DC100%2/2
$res and not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
$res not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
Truth table100%3/3
A and not(B)
A= $resB= not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
ABresult
0X0
100
111
451 } elsif (ref $key_or_subentry eq 'CODE') {
452 1 my $res = $key_or_subentry->($self, $dist);
453 1 ▶ return $res if $res && !$TRAVERSE_ONLY;
Branch: 1 branch
BranchTrueFalseTotal
if $res and not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY 1 0 1
Condition33%1/3
$res and not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
!ll&&!rl&&r
001
MC/DC0%0/2
$res and not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
$res not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
Truth table33%1/3
A and not(B)
A= $resB= not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
ABresult
0X0
100
111
454 } else {
455 38062 my $key = $key_or_subentry;
456 38062 my $match = $entry->[++$map_i];
457 38062 $self->_debug(' ' x $level . " match '$key' against '", $match, "'");
458 38062 ▶ if ($key eq 'cpandist') {
Branch: 8 branches
BranchTrueFalseTotal
if ($key eq 'cpandist') { } 22 38040 38062
elsif ($key eq 'cpanmod') { } 8606 29434 38040
elsif ($key eq 'os') { } 5313 24121 29434
elsif ($key eq 'osvers') { } 178 23943 24121
elsif ($key eq 'linuxdistro') { } 7768 16175 23943
elsif ($key eq 'linuxdistroversion') { } 420 15755 16175
elsif ($key eq 'linuxdistrocodename') { } 1308 14447 15755
elsif ($key eq 'package') { } 14447 0 14447
459 22 ▶ return 0 if !$smartmatch->($get_base_id->(), $match) && !$TRAVERSE_ONLY;
Branch: 1 branch
BranchTrueFalseTotal
unless &$smartmatch(&$get_base_id(), $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY 9 13 22
Condition100%3/3
&$smartmatch(&$get_base_id(), $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
l!l&&r!l&&!r
1129
MC/DC100%2/2
&$smartmatch(&$get_base_id(), $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
&$smartmatch(&$get_base_id(), $match) $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
Truth table100%3/3
A or B
A= &$smartmatch(&$get_base_id(), $match)B= $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
ABresult
1X1
011
000
460 } elsif ($key eq 'cpanmod') {
461 8606 my $found = 0;
462 8606 for my $mod ($self->_dist_containsmods($dist)) {
463 8196 $self->_debug(' ' x $level . " found module '$mod' in dist, check now against '", $match, "'");
464 8196 ▶ if ($smartmatch->($mod, $match)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$smartmatch($mod, $match)) 17 8179 8196
465 17 $found = 1;
466 17 last;
467 }
468 }
469 8606 ▶ return 0 if !$found && !$TRAVERSE_ONLY;
Branch: 1 branch
BranchTrueFalseTotal
unless $found or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY 3668 4938 8606
Condition100%3/3
$found or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
l!l&&r!l&&!r
1749213668
MC/DC100%2/2
$found or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
$found $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
Truth table100%3/3
A or B
A= $foundB= $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
ABresult
1X1
011
000
470 } elsif ($key eq 'os') {
471 5313 ▶ return 0 if !$smartmatch->($self->{os}, $match) && !$TRAVERSE_ONLY;
Branch: 1 branch
BranchTrueFalseTotal
unless &$smartmatch($self->{"os"}, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY 13 5300 5313
Condition100%3/3
&$smartmatch($self->{"os"}, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
l!l&&r!l&&!r
20528013
MC/DC100%2/2
&$smartmatch($self->{"os"}, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
&$smartmatch($self->{"os"}, $match) $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
Truth table100%3/3
A or B
A= &$smartmatch($self->{"os"}, $match)B= $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
ABresult
1X1
011
000
472 } elsif ($key eq 'osvers') {
473 178 ▶ return 0 if !$smartmatch->($self->{osvers}, $match) && !$TRAVERSE_ONLY;
Branch: 1 branch
BranchTrueFalseTotal
unless &$smartmatch($self->{"osvers"}, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY 6 172 178
Condition100%3/3
&$smartmatch($self->{"osvers"}, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
l!l&&r!l&&!r
88846
MC/DC100%2/2
&$smartmatch($self->{"osvers"}, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
&$smartmatch($self->{"osvers"}, $match) $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
Truth table100%3/3
A or B
A= &$smartmatch($self->{"osvers"}, $match)B= $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
ABresult
1X1
011
000
474 } elsif ($key eq 'linuxdistro') {
475 7768 ▶ if ($match =~ m{^~(debian|fedora|alpine)$}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($match =~ /^~(debian|fedora|alpine)$/) { } 7035 733 7768
elsif ($match =~ /^~/) { } 1 732 733
476 7035 my $method = "_is_linux_$1_like";
477 7035 $self->_debug(' ' x $level . " translate $match to $method");
478 7035 ▶ return 0 if !$self->$method($self->{linuxdistro}) && !$TRAVERSE_ONLY;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->$method($self->{"linuxdistro"}) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY 0 7035 7035
Condition66%2/3
$self->$method($self->{"linuxdistro"}) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
l!l&&r!l&&!r
261044250
MC/DC0%0/2
$self->$method($self->{"linuxdistro"}) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
$self->$method($self->{"linuxdistro"}) $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
Truth table66%2/3
A or B
A= $self->$method($self->{"linuxdistro"})B= $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
ABresult
1X1
011
000
479 } elsif ($match =~ m{^~}) {
480 1 die "'like' matches only for debian, fedora, and alpine";
481 } else {
482 732 ▶ return 0 if !$smartmatch->($self->{linuxdistro}, $match) && !$TRAVERSE_ONLY;
Branch: 1 branch
BranchTrueFalseTotal
unless &$smartmatch($self->{"linuxdistro"}, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY 0 732 732
Condition66%2/3
&$smartmatch($self->{"linuxdistro"}, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
l!l&&r!l&&!r
566760
MC/DC0%0/2
&$smartmatch($self->{"linuxdistro"}, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
&$smartmatch($self->{"linuxdistro"}, $match) $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
Truth table66%2/3
A or B
A= &$smartmatch($self->{"linuxdistro"}, $match)B= $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
ABresult
1X1
011
000
483 }
484 } elsif ($key eq 'linuxdistroversion') {
485 420 ▶ return 0 if !$smartmatch->($self->{linuxdistroversion}, $match) && !$TRAVERSE_ONLY;
Branch: 1 branch
BranchTrueFalseTotal
unless &$smartmatch($self->{"linuxdistroversion"}, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY 0 420 420
Condition66%2/3
&$smartmatch($self->{"linuxdistroversion"}, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
l!l&&r!l&&!r
803400
MC/DC0%0/2
&$smartmatch($self->{"linuxdistroversion"}, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
&$smartmatch($self->{"linuxdistroversion"}, $match) $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
Truth table66%2/3
A or B
A= &$smartmatch($self->{"linuxdistroversion"}, $match)B= $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
ABresult
1X1
011
000
486 } elsif ($key eq 'linuxdistrocodename') {
487 1308 ▶ return 0 if !$smartmatch->($self->{linuxdistrocodename}, $match) && !$TRAVERSE_ONLY; # XXX should also do a smart codename comparison additionally!
Branch: 1 branch
BranchTrueFalseTotal
unless &$smartmatch($self->{"linuxdistrocodename"}, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY 0 1308 1308
Condition66%2/3
&$smartmatch($self->{"linuxdistrocodename"}, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
l!l&&r!l&&!r
10911990
MC/DC0%0/2
&$smartmatch($self->{"linuxdistrocodename"}, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
&$smartmatch($self->{"linuxdistrocodename"}, $match) $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
Truth table66%2/3
A or B
A= &$smartmatch($self->{"linuxdistrocodename"}, $match)B= $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
ABresult
1X1
011
000
488 } elsif ($key eq 'package') {
489 14447 $self->_debug(' ' x $level . " found $match"); # XXX array?
490 14447 return { package => $match };
491 } else {
492 0 die "Invalid key '$key'"; # XXX context/position?
493 }
494 }
495 }
496 32 };
497  
498 32 ▶ for my $entry (@{ $self->{mapping} || [] }) {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"mapping"} or [] 0 32 32
499 8628 my $res = $handle_mapping_entry->($entry, 0);
500 8627 ▶ if ($res && !$TRAVERSE_ONLY) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res and not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY) 12 8615 8627
Condition66%2/3
$res and not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
!ll&&!rl&&r
8615012
MC/DC50%1/2
$res and not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
$res not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
Truth table66%2/3
A and not(B)
A= $resB= not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
ABresult
0X0
100
111
501 12 ▶ return ref $res->{package} eq 'ARRAY' ? @{ $res->{package} } : $res->{package};
Branch: 1 branch
BranchTrueFalseTotal
ref $res->{'package'} eq 'ARRAY' ? : 2 10 12
502 }
503 }
504  
505 19 ();
506 }
507  
508 sub _detect_dnf {
509 1 ▶ my @cmd = ('dnf', '--help');
Subroutine _detect_dnf: called CC=2 SCAR=7.8
510 1 require IPC::Open3;
511 1 require Symbol;
512 1 my $err = Symbol::gensym();
513 1 my $fh;
514 1 return eval {
515 1 ▶ if (my $pid = IPC::Open3::open3(undef, $fh, $err, @cmd)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pid = IPC::Open3::open3(undef, $fh, $err, @cmd)) 0 0 0
516 0 waitpid $pid, 0;
517 0 return $? == 0;
518 }
519 };
520 }
521  
522 sub _find_missing_deb_packages {
523 7 ▶ my($self, @packages) = @_;
Subroutine _find_missing_deb_packages: called CC=8 SCAR=24.8
524 7 ▶ return () if !@packages;
Branch: 1 branch
BranchTrueFalseTotal
unless @packages 1 6 7
525  
526 # taken from ~/devel/deb-install.pl
527 6 my %seen_packages;
528 my @missing_packages;
529  
530 6 my @cmd = ('dpkg-query', '-W', '-f=${Package} ${Status}\n', @packages);
531 6 require IPC::Open3;
532 6 require Symbol;
533 6 my $err = Symbol::gensym();
534 6 my $fh;
535 6 ▶ my $pid = IPC::Open3::open3(undef, $fh, $err, @cmd)
Branch: 1 branch
BranchTrueFalseTotal
my $pid = IPC::Open3::open3(undef, $fh, $err, @cmd) or die "Error running '@{cmd}': $!" 0 6 6
536 or die "Error running '@cmd': $!";
537 6 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 6 6
538 0 chomp;
539 0 ▶ if (m{^(\S+) (.*)}) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^(\S+) (.*)/) { } 0 0 0
540 0 ▶ if ($2 ne 'install ok installed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($2 ne "install ok installed") 0 0 0
541 0 push @missing_packages, $1;
542 }
543 0 $seen_packages{$1} = 1;
544 } else {
545 0 warn "ERROR: cannot parse $_, ignore line...\n";
546 }
547 }
548 6 waitpid $pid, 0;
549 6 for my $package (@packages) {
550 8 ▶ if (!$seen_packages{$package}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($seen_packages{$package}) 8 0 8
551 8 push @missing_packages, $package;
552 }
553 }
554 6 @missing_packages;
555 }
556  
557 sub _find_missing_rpm_packages {
558 6 ▶ my($self, @packages) = @_;
Subroutine _find_missing_rpm_packages: called CC=11 SCAR=24.2
559 6 ▶ return () if !@packages;
Branch: 1 branch
BranchTrueFalseTotal
unless @packages 1 5 6
560  
561 5 my @missing_packages;
562 {
563 5 my %packages = map{($_,1)} @packages;
564  
565 5 local $ENV{LC_ALL} = 'C';
566 5 my @cmd = ('rpm', '-q', @packages);
567 5 ▶ open my $fh, '-|', @cmd
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "-|", @cmd or die "Error running '@{cmd}': $!" 0 5 5
568 or die "Error running '@cmd': $!";
569 5 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 8 5 13
570 8 ▶ if (m{^package (\S+) is not installed}) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^package (\S+) is not installed/) 4 4 8
571 4 my $package = $1;
572 4 ▶ if (!exists $packages{$package}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $packages{$package}) 0 4 4
573 0 die "Unexpected: package $package listed as non-installed, but not queried in '@cmd'?!";
574 }
575 4 push @missing_packages, $package;
576 }
577 }
578 }
579 5 ▶ return () if !@missing_packages;
Branch: 1 branch
BranchTrueFalseTotal
unless @missing_packages 1 4 5
580  
581 # maybe the packages are just provided by another package?
582 4 my @definitively_missing_packages;
583 {
584 4 my %packages = map{($_,1)} @missing_packages;
585  
586 4 local $ENV{LC_ALL} = 'C';
587 4 my @cmd = ('rpm', '-q', '--whatprovides', @missing_packages);
588 4 ▶ open my $fh, '-|', @cmd
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "-|", @cmd or die "Error running '@{cmd}': $!" 0 4 4
589 or die "Error running '@cmd': $!";
590 4 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 5 4 9
591 5 ▶ if (m{^no package provides (\S+)}) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^no package provides (\S+)/) 3 2 5
592 3 my $package = $1;
593 3 ▶ if (!exists $packages{$package}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $packages{$package}) 0 3 3
594 0 die "Unexpected: package $package listed as non-installed, but not queried in '@cmd'?!";
595 }
596 3 push @definitively_missing_packages, $package;
597 }
598 }
599 }
600  
601 4 @definitively_missing_packages;
602 }
603  
604 sub _find_missing_freebsd_pkg_packages {
605 0 ▶ my($self, @packages) = @_;
Subroutine _find_missing_freebsd_pkg_packages: not called CC=4 SCAR=30.0
606 0 ▶ return () if !@packages;
Branch: 1 branch
BranchTrueFalseTotal
unless @packages 0 0 0
607  
608 0 my @missing_packages;
609 0 for my $package (@packages) {
610 0 my @cmd = ('pkg', 'info', '--exists', $package);
611 0 system @cmd;
612 0 ▶ if ($? != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
613 0 push @missing_packages, $package;
614 }
615 }
616  
617 0 @missing_packages;
618 }
619  
620 sub _find_missing_openbsd_pkg_packages {
621 0 ▶ my($self, @packages) = @_;
Subroutine _find_missing_openbsd_pkg_packages: not called CC=7 SCAR=40.3
622 0 ▶ return () if !@packages;
Branch: 1 branch
BranchTrueFalseTotal
unless @packages 0 0 0
623  
624 0 require IPC::Open3;
625 0 require Symbol;
626  
627 0 my @missing_packages;
628 0 for my $package (@packages) {
629 0 my $err = Symbol::gensym();
630 0 my $fh;
631 my $package_in_repository;
632 0 eval {
633 0 ▶ if (my $pid = IPC::Open3::open3(undef, $fh, $err, 'pkg_info', $package)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $pid = IPC::Open3::open3(undef, $fh, $err, "pkg_info", $package)) 0 0 0
634 0 waitpid $pid, 0;
635 0 ▶ if ($? == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? == 0) 0 0 0
636 0 $package_in_repository = 1;
637 }
638 }
639 };
640 0 ▶ if ($package_in_repository) {
Branch: 1 branch
BranchTrueFalseTotal
if ($package_in_repository) 0 0 0
641 0 my @cmd = ('pkg_info', '-q', '-e', "${package}->=0");
642 0 system @cmd;
643 0 ▶ if ($? != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
644 0 push @missing_packages, $package;
645 }
646 }
647 }
648  
649 0 @missing_packages;
650 }
651  
652 sub _find_missing_homebrew_packages {
653 0 ▶ my($self, @packages) = @_;
Subroutine _find_missing_homebrew_packages: not called CC=6 SCAR=37.4
654 0 ▶ return () if !@packages;
Branch: 1 branch
BranchTrueFalseTotal
unless @packages 0 0 0
655  
656 0 my @missing_packages;
657 0 for my $package (@packages) {
658 0 my @cmd = ('brew', 'ls', '--versions', $package);
659 0 ▶ open my $fh, '-|', @cmd
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "-|", @cmd or die "Error running @{cmd}: $!" 0 0 0
660 or die "Error running @cmd: $!";
661 0 my $has_package;
662 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
663 0 $has_package = 1;
664 0 last;
665 }
666 0 close $fh; # earlier homebrew versions returned always 0,
667 # newer (since Oct 2016) return 1 if the package is
668 # missing
669 0 ▶ if (!$has_package) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($has_package) 0 0 0
670 0 push @missing_packages, $package;
671 }
672 }
673 0 @missing_packages;
674 }
675  
676 sub _find_missing_chocolatey_packages {
677 0 ▶ my($self, @packages) = @_;
Subroutine _find_missing_chocolatey_packages: not called CC=3 SCAR=24.8
678 0 ▶ return () if !@packages;
Branch: 1 branch
BranchTrueFalseTotal
unless @packages 0 0 0
679  
680 my %installed_packages = map {
681 0 ▶ /^(.*)\|(.*)$/
Branch: 1 branch
BranchTrueFalseTotal
/^(.*)\|(.*)$/ or next 0 0 0
682 or next;
683 0 $1 => $2
684 } grep {
685 0 /^(.*)\|(.*)$/
686 } `choco list --localonly --limit-output`;
687 0 my @missing_packages = grep { ! $installed_packages{ $_ }} @packages;
688 0 @missing_packages;
689 }
690  
691 sub _find_missing_apk_packages {
692 0 ▶ my($self, @packages) = @_;
Subroutine _find_missing_apk_packages: not called CC=4 SCAR=30.0
693 0 ▶ return () if !@packages;
Branch: 1 branch
BranchTrueFalseTotal
unless @packages 0 0 0
694  
695 0 my @missing_packages;
696 0 for my $package (@packages) {
697 0 my @cmd = ('apk', 'info', '-e', $package);
698 0 system @cmd;
699 0 ▶ if ($? != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
700 0 push @missing_packages, $package;
701 }
702 }
703  
704 0 @missing_packages;
705 }
706  
707 sub _filter_uninstalled_packages {
708 6 ▶ my($self, @packages) = @_;
Subroutine _filter_uninstalled_packages: called CC=14 SCAR=39.2
709 6 my $find_missing_packages;
710 6 ▶ if ($self->_is_apt_installer) {
Branch: 7 branches
BranchTrueFalseTotal
if ($self->_is_apt_installer) { } 6 0 6
elsif ($self->{'installer'} eq 'yum' or $self->{'installer'} eq 'dnf') { } 0 0 0
elsif ($self->{'os'} eq 'freebsd' or $self->{'os'} eq 'dragonfly') { } 0 0 0
elsif ($self->{'os'} eq 'openbsd') { } 0 0 0
elsif ($self->{'os'} eq 'MSWin32') { } 0 0 0
elsif ($self->{'installer'} eq 'homebrew') { } 0 0 0
elsif ($self->{'installer'} eq 'apk') { } 0 0 0
711 6 $find_missing_packages = '_find_missing_deb_packages';
712 ▶ } elsif (($self->{installer} eq 'yum') || ($self->{installer} eq 'dnf')) {
Condition0%0/3
$self->{"installer"} eq "yum" or $self->{"installer"} eq "dnf"
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"installer"} eq "yum" or $self->{"installer"} eq "dnf"
$self->{"installer"} eq "yum" $self->{"installer"} eq "dnf"
Truth table0%0/3
A or B
A= $self->{"installer"} eq "yum"B= $self->{"installer"} eq "dnf"
ABresult
1X1
011
000
713 0 $find_missing_packages = '_find_missing_rpm_packages';
714 ▶ } elsif ($self->{os} eq 'freebsd' || $self->{os} eq 'dragonfly') {
Condition0%0/3
$self->{"os"} eq "freebsd" or $self->{"os"} eq "dragonfly"
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"os"} eq "freebsd" or $self->{"os"} eq "dragonfly"
$self->{"os"} eq "freebsd" $self->{"os"} eq "dragonfly"
Truth table0%0/3
A or B
A= $self->{"os"} eq "freebsd"B= $self->{"os"} eq "dragonfly"
ABresult
1X1
011
000
715 0 $find_missing_packages = '_find_missing_freebsd_pkg_packages';
716 } elsif ($self->{os} eq 'openbsd') {
717 0 $find_missing_packages = '_find_missing_openbsd_pkg_packages';
718 } elsif ($self->{os} eq 'MSWin32') {
719 0 $find_missing_packages = '_find_missing_chocolatey_packages';
720 } elsif ($self->{installer} eq 'homebrew') {
721 0 $find_missing_packages = '_find_missing_homebrew_packages';
722 } elsif ($self->{installer} eq 'apk') {
723 0 $find_missing_packages = '_find_missing_apk_packages';
724 } else {
725 0 warn "check for installed packages is NYI for $self->{os}/$self->{linuxdistro}";
726 }
727 6 ▶ if ($find_missing_packages) {
Branch: 1 branch
BranchTrueFalseTotal
if ($find_missing_packages) 6 0 6
728 6 my @plain_packages;
729 my @missing_packages;
730 6 for my $package_spec (@packages) {
731 7 ▶ if ($package_spec =~ m{\|}) { # has alternatives
Branch: 1 branch
BranchTrueFalseTotal
if ($package_spec =~ /\|/) { } 1 6 7
732 1 my @single_packages = split /\s*\|\s*/, $package_spec;
733 1 my @missing_in_packages_spec = $self->$find_missing_packages(@single_packages);
734 1 ▶ if (@missing_in_packages_spec == @single_packages) {
Branch: 1 branch
BranchTrueFalseTotal
if (@missing_in_packages_spec == @single_packages) 1 0 1
735 1 push @missing_packages, $single_packages[0]; # XXX this could go wrong if the first alternative is not available at all; see problem with jpeg|jpeg-turbo in Mapping.pm
736 }
737 } else {
738 6 push @plain_packages, $package_spec;
739 }
740 }
741 6 push @missing_packages, $self->$find_missing_packages(@plain_packages);
742 6 @packages = @missing_packages;
743 }
744 6 @packages;
745 }
746  
747 sub _install_packages_commands {
748 15 ▶ my($self, @packages) = @_;
Subroutine _install_packages_commands: called CC=31 SCAR=38.0
749 15 my @pre_cmd;
750 my @install_cmd;
751  
752 # sudo or not?
753 15 ▶ if ($self->{installer} eq 'homebrew') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'installer'} eq 'homebrew') { } 1 14 15
elsif ($self->{'installer'} eq 'chocolatey') { } 0 14 14
754 # may run as unprivileged user
755 } elsif ($self->{installer} eq 'chocolatey') {
756 # no sudo on Windows systems?
757 } else {
758 14 ▶ if ($< != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($< != 0) 14 0 14
759 14 push @install_cmd, 'sudo';
760 }
761 }
762  
763 # the installer executable
764 15 ▶ if ($self->{installer} eq 'homebrew') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'installer'} eq 'homebrew') { } 1 14 15
elsif ($self->{'installer'} eq 'chocolatey') { } 0 14 14
765 1 push @install_cmd, 'brew';
766 } elsif ($self->{installer} eq 'chocolatey') {
767 0 push @install_cmd, 'choco';
768 } else {
769 14 push @install_cmd, $self->{installer};
770 }
771  
772 # batch, default or interactive
773 15 ▶ if ($self->{batch}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'batch'}) { } 6 9 15
774 6 ▶ if ($self->_is_apt_installer) {
Branch: 5 branches
BranchTrueFalseTotal
if ($self->_is_apt_installer) { } 5 1 6
elsif ($self->{'installer'} eq 'yum' or $self->{'installer'} eq 'dnf') { } 0 1 1
elsif ($self->{'installer'} eq 'pkg') { } 0 1 1
elsif ($self->{'installer'} eq 'homebrew') { } 0 1 1
elsif ($self->{'installer'} eq 'apk') { } 1 0 1
775 5 push @install_cmd, '-y';
776 ▶ } elsif (($self->{installer} eq 'yum') || ($self->{installer} eq 'dnf')) {
Condition33%1/3
$self->{"installer"} eq "yum" or $self->{"installer"} eq "dnf"
l!l&&r!l&&!r
001
MC/DC0%0/2
$self->{"installer"} eq "yum" or $self->{"installer"} eq "dnf"
$self->{"installer"} eq "yum" $self->{"installer"} eq "dnf"
Truth table33%1/3
A or B
A= $self->{"installer"} eq "yum"B= $self->{"installer"} eq "dnf"
ABresult
1X1
011
000
777 0 push @install_cmd, '-y';
778 } elsif ($self->{installer} eq 'pkg') { # FreeBSD's pkg
779 # see below
780 } elsif ($self->{installer} eq 'homebrew') {
781 # batch by default
782 } elsif ($self->{installer} eq 'apk') {
783 # batch by default
784 } else {
785 0 warn "batch=1 NYI for $self->{installer}";
786 }
787 } else {
788 9 ▶ if ($self->_is_apt_installer) {
Branch: 6 branches
BranchTrueFalseTotal
if ($self->_is_apt_installer) { } 3 6 9
elsif ($self->{'installer'} eq 'yum' or $self->{'installer'} eq 'dnf') { } 2 4 6
elsif ($self->{'installer'} eq 'pkg') { } 1 3 4
elsif ($self->{'installer'} =~ /^(chocolatey)$/) { } 0 3 3
elsif ($self->{'installer'} eq 'homebrew') { } 1 2 3
elsif ($self->{'installer'} eq 'apk') { } 1 1 2
789 3 @pre_cmd = ('sh', '-c', 'echo -n "Install package(s) '."@packages".'? (y/N) "; read yn; [ "$yn" = "y" ]');
790 ▶ } elsif (($self->{installer} eq 'yum') || ($self->{installer} eq 'dnf')) {
Condition100%3/3
$self->{"installer"} eq "yum" or $self->{"installer"} eq "dnf"
l!l&&r!l&&!r
114
MC/DC100%2/2
$self->{"installer"} eq "yum" or $self->{"installer"} eq "dnf"
$self->{"installer"} eq "yum" $self->{"installer"} eq "dnf"
Truth table100%3/3
A or B
A= $self->{"installer"} eq "yum"B= $self->{"installer"} eq "dnf"
ABresult
1X1
011
000
791 # interactive by default
792 } elsif ($self->{installer} eq 'pkg') { # FreeBSD's pkg
793 # see below
794 } elsif ($self->{installer} =~ m{^(chocolatey)$}) {
795 # Nothing to do here
796 } elsif ($self->{installer} eq 'homebrew') {
797 # the sh builtin echo does not understand -n -> use printf
798 1 @pre_cmd = ('sh', '-c', 'printf %s "Install package(s) '."@packages".'? (y/N) "; read yn; [ "$yn" = "y" ]');
799 } elsif ($self->{installer} eq 'apk') {
800 1 @pre_cmd = ('sh', '-c', 'printf %s "Install package(s) '."@packages".'? (y/N) "; read yn; [ "$yn" = "y" ]');
801 } else {
802 1 warn "batch=0 NYI for $self->{installer}";
803 }
804 }
805  
806 # special options
807 15 ▶ if ($self->{installer} eq 'pkg') { # FreeBSD's pkg
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"installer"} eq "pkg") 1 14 15
808 1 push @install_cmd, '--option', 'LOCK_RETRIES=86400'; # wait quite long in case there are concurrent pkg runs
809 }
810  
811 # the installer subcommand
812 15 ▶ if ($self->{installer} eq 'apk') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'installer'} eq 'apk') { } 2 13 15
elsif ($self->{'installer'} ne 'pkg_add') { } 12 1 13
813 2 push @install_cmd, 'add';
814 } elsif ($self->{installer} ne 'pkg_add') {
815 12 push @install_cmd, 'install';
816 }
817  
818 # post options
819 15 ▶ if ($self->{batch} && $self->{installer} eq 'pkg') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"batch"} and $self->{"installer"} eq "pkg") 0 15 15
Condition66%2/3
$self->{"batch"} and $self->{"installer"} eq "pkg"
!ll&&!rl&&r
960
MC/DC0%0/2
$self->{"batch"} and $self->{"installer"} eq "pkg"
$self->{"batch"} $self->{"installer"} eq "pkg"
Truth table66%2/3
A and B
A= $self->{"batch"}B= $self->{"installer"} eq "pkg"
ABresult
0X0
100
111
820 0 push @install_cmd, '-y';
821 }
822 15 ▶ if ($self->{batch} && $self->{installer} eq 'chocolatey') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"batch"} and $self->{"installer"} eq "chocolatey") 0 15 15
Condition66%2/3
$self->{"batch"} and $self->{"installer"} eq "chocolatey"
!ll&&!rl&&r
960
MC/DC0%0/2
$self->{"batch"} and $self->{"installer"} eq "chocolatey"
$self->{"batch"} $self->{"installer"} eq "chocolatey"
Truth table66%2/3
A and B
A= $self->{"batch"}B= $self->{"installer"} eq "chocolatey"
ABresult
0X0
100
111
823 0 push @install_cmd, '-y';
824 }
825 15 ▶ if ($self->{batch} && $self->{installer} eq 'pkg_add') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"batch"} and $self->{"installer"} eq "pkg_add") 0 15 15
Condition66%2/3
$self->{"batch"} and $self->{"installer"} eq "pkg_add"
!ll&&!rl&&r
960
MC/DC0%0/2
$self->{"batch"} and $self->{"installer"} eq "pkg_add"
$self->{"batch"} $self->{"installer"} eq "pkg_add"
Truth table66%2/3
A and B
A= $self->{"batch"}B= $self->{"installer"} eq "pkg_add"
ABresult
0X0
100
111
826 0 push @install_cmd, '-I';
827 }
828  
829 15 push @install_cmd, @packages;
830
831 15 ▶ if ($self->{os} eq 'MSWin32') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"os"} eq "MSWin32") 0 15 15
832 # Wrap the thing in our small powershell program
833 0 @install_cmd = _win32_run_elevated(@install_cmd);
834 };
835  
836 15 ▶ ((@pre_cmd ? \@pre_cmd : ()), \@install_cmd);
Branch: 1 branch
BranchTrueFalseTotal
@pre_cmd ? : 5 10 15
837 }
838  
839 9 1;
840  
841 __END__
↑ Summary blib/lib/CPAN/Plugin/Sysdeps/Mapping.pm »