blib/lib/CPAN/Plugin/Sysdeps.pm

filter: Statementstmt 90.1% 1451 / 1609 Branchbran 55.9% 188 / 336 Conditioncond 65.3% 51 / 78 MC/DCmcdc 32.0% 16 / 50 Subroutinesub 97.8% 416 / 425 Podpod 100% 2 / 2 totaltotal 84.9% 2124 / 2500 CC 208 SCAR 27.6
CC
208
Cov
84%
new
89.0
_detect_linux_distribution_fallback
72.0
_detect_linux_distribution_lsb_release
56.0
CRAP 15.9
↑ Summary blib/lib/CPAN/Plugin/Sysdeps/Mapping.pm »
1 package CPAN::Plugin::Sysdeps;
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 our $VERSION = '0.81';
7  
8 8 ▶use List::Util 'first';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 8 our $TRAVERSE_ONLY; # only for testing
11  
12 8 ▶use constant SUPPORTED_NUMERICAL_OPS => ['<','<=','==','>','>='];
Subroutine BEGIN: called CC=1 SCAR=0.0
13 8 use constant SUPPORTED_NUMERICAL_OPS_RX => do {
14 8 my $rx = '^(' . join('|', map { quotemeta } @{SUPPORTED_NUMERICAL_OPS()}) . ')$';
15 8 qr{$rx};
16 8 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 8 our @OS_RELEASE_PATH_CANDIDATES = ('/etc/os-release', '/usr/lib/os-release');
19  
20 sub new {
21 42 ▶ my($class, @args) = @_;
Subroutine new: called CC=42 SCAR=44.9
Pod documented
22  
23 42 my $installer;
24 42 my $batch = 0;
25 42 my $dryrun = 0;
26 42 my $debug = 0;
27 42 my @additional_mappings;
28 my @args_errors;
29 42 my $options;
30 42 for my $arg (@args) {
31 117 ▶ if (ref $arg eq 'HASH') {
Branch: 7 branches
BranchTrueFalseTotal
if (ref $arg eq 'HASH') { } 15 102 117
elsif ($arg =~ /^(apt-get|aptitude|pkg|pkg_add|yum|dnf|chocolatey|homebrew|apk)$/) { } 24 78 102
elsif ($arg eq 'batch') { } 31 47 78
elsif ($arg eq 'interactive') { } 1 46 47
elsif ($arg eq 'dryrun') { } 30 16 46
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 31 $batch = 1;
41 } elsif ($arg eq 'interactive') {
42 1 $batch = 0;
43 } elsif ($arg eq 'dryrun') {
44 30 $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 42 ▶ if (@args_errors) {
Branch: 1 branch
BranchTrueFalseTotal
if (@args_errors) 0 42 42
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 42 ▶ if (exists $ENV{CPAN_PLUGIN_SYSDEPS_DEBUG}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ENV{"CPAN_PLUGIN_SYSDEPS_DEBUG"}) 0 42 42
58 0 $debug = $ENV{CPAN_PLUGIN_SYSDEPS_DEBUG};
59 }
60 42 ▶ if ($debug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug) 0 42 42
61 0 require Data::Dumper; # we'll need it
62 }
63  
64 42 ▶ my $os = $options->{os} || $^O;
Condition66%2/3
$options->{'os'} || $^O
l!l&&r!l&&!r
15270
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 42 my $osvers = '';
66 42 my $linuxdistro = '';
67 42 my $linuxdistroversion = 0;
68 42 my $linuxdistrocodename = '';
69 42 ▶ if ($os eq 'linux') {
Branch: 2 branches
BranchTrueFalseTotal
if ($os eq 'linux') { } 33 9 42
elsif ($os eq 'freebsd' or $os eq 'openbsd' or $os eq 'dragonfly') { } 9 0 9
70 33 my $linux_info;
71 my $get_linux_info = sub {
72 81 ▶ return $linux_info if $linux_info;
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $linux_info 54 27 81
73 27 return $linux_info = _detect_linux_distribution();
74 33 };
75 33 ▶ if (defined $options->{linuxdistro}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $options->{'linuxdistro'}) { } 6 27 33
76 6 $linuxdistro = $options->{linuxdistro};
77 } else {
78 27 $linuxdistro = $get_linux_info->()->{linuxdistro};
79 }
80  
81 33 ▶ if (defined $options->{linuxdistroversion}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $options->{'linuxdistroversion'}) { } 6 27 33
82 6 $linuxdistroversion = $options->{linuxdistroversion};
83 } else {
84 27 $linuxdistroversion = $get_linux_info->()->{linuxdistroversion}; # XXX make it a version object? or make sure it's just X.Y?
85 }
86  
87 33 ▶ if (defined $options->{linuxdistrocodename}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $options->{'linuxdistrocodename'}) { } 6 27 33
88 6 $linuxdistrocodename = $options->{linuxdistrocodename};
89 } else {
90 27 $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 42 ▶ if (!$installer) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($installer) 18 24 42
104 18 ▶ if ($os eq 'freebsd' || $os eq 'dragonfly') {
Branch: 6 branches
BranchTrueFalseTotal
if ($os eq 'freebsd' or $os eq 'dragonfly') { } 9 9 18
elsif ($os eq 'gnukfreebsd') { } 0 9 9
elsif ($os eq 'openbsd') { } 0 9 9
elsif ($os eq 'linux') { } 9 0 9
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
909
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 9 ▶ if (__PACKAGE__->_is_linux_debian_like($linuxdistro)) {
Branch: 3 branches
BranchTrueFalseTotal
if (__PACKAGE__->_is_linux_debian_like($linuxdistro)) { } 8 1 9
elsif (__PACKAGE__->_is_linux_fedora_like($linuxdistro)) { } 1 0 1
elsif (__PACKAGE__->_is_linux_alpine_like($linuxdistro)) { } 0 0 0
112 8 $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 42 my @mapping;
134 42 for my $mapping (@additional_mappings, 'CPAN::Plugin::Sysdeps::Mapping') {
135 58 ▶ if (-r $mapping) {
Branch: 1 branch
BranchTrueFalseTotal
if (-r $mapping) { } 16 42 58
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 42 ▶ eval "require $mapping"; die "Can't load $mapping: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 42 42
144 42 push @mapping, $mapping->mapping;
145 }
146 }
147  
148 42 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 );
161 42 my $self = bless \%config, $class;
162 42 ▶ if (eval { require Hash::Util; 1 }) {
Branch: 1 branch
BranchTrueFalseTotal
if (eval { do { require Hash::Util; 1 } }) 42 0 42
163 42 Hash::Util::lock_keys($self);
164 }
165 42 $self;
166 }
167  
168 # CPAN.pm plugin hook method
169 sub post_get {
170 15 ▶ my($self, $dist) = @_;
Subroutine post_get: called CC=6 SCAR=20.8
Pod documented
171  
172 15 my @packages = $self->_map_cpandist($dist);
173 14 ▶ if (@packages) {
Branch: 1 branch
BranchTrueFalseTotal
if (@packages) 2 12 14
174 2 my @uninstalled_packages = $self->_filter_uninstalled_packages(@packages);
175 2 ▶ if (@uninstalled_packages) {
Branch: 1 branch
BranchTrueFalseTotal
if (@uninstalled_packages) 2 0 2
176 2 my @cmds = $self->_install_packages_commands(@uninstalled_packages);
177 2 for my $cmd (@cmds) {
178 2 ▶ if ($self->{dryrun}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'dryrun'}) { } 2 0 2
179 2 warn "DRYRUN: @$cmd\n";
180 } else {
181 0 warn "INFO: run @$cmd...\n";
182  
183 0 system @$cmd;
184 0 ▶ if ($? != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
185 0 die "@$cmd failed, stop installation";
186 }
187 }
188 }
189 }
190 }
191 }
192  
193 # Helpers/Internal functions/methods
194 sub _detect_linux_distribution {
195 28 ▶ my $info = _detect_linux_distribution_os_release();
Subroutine _detect_linux_distribution: called CC=3 SCAR=17.3
196 28 ▶ return $info if $info;
Branch: 1 branch
BranchTrueFalseTotal
if $info 28 0 28
197 0 ▶ if (-x '/usr/bin/lsb_release') {
Branch: 1 branch
BranchTrueFalseTotal
if (-x '/usr/bin/lsb_release') { } 0 0 0
198 0 _detect_linux_distribution_lsb_release();
199 } else {
200 0 _detect_linux_distribution_fallback();
201 }
202 }
203  
204 sub _detect_linux_distribution_os_release {
205 41 ▶ my %info;
Subroutine _detect_linux_distribution_os_release: called CC=8 SCAR=20.8
206 41 for my $candidate_file (@OS_RELEASE_PATH_CANDIDATES) {
207 41 ▶ if (open my $fh, '<', $candidate_file) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, "<", $candidate_file) 40 1 41
208 40 my %c;
209 40 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 478 40 518
210 478 ▶ if (my($k,$v) = $_ =~ m{^(.*?)=["']?(.*?)["']?$}) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = $_ =~ /^(.*?)=["']?(.*?)["']?$/) 470 8 478
211 470 $c{$k} = $v;
212 }
213 }
214 40 $info{linuxdistro} = $c{ID};
215 40 $info{linuxdistroversion} = $c{VERSION_ID};
216 40 $info{linuxdistrocodename} = $c{VERSION_CODENAME};
217 # heuristics
218 40 ▶ 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 38 40
Condition83%5/6
not defined $info{"linuxdistrocodename"} and $info{"linuxdistro"} eq "debian" and $c{"VERSION"} =~ /^\d+\s+\((.+)\)$/
!ll&&!rl&&r
3802
not defined $info{"linuxdistrocodename"} and $info{"linuxdistro"} eq "debian"
!ll&&!rl&&r
3082
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
219 2 $info{linuxdistrocodename} = $1;
220 }
221 40 return \%info;
222 }
223 }
224 1 undef;
225 }
226  
227 sub _detect_linux_distribution_lsb_release {
228 0 ▶ my %info;
Subroutine _detect_linux_distribution_lsb_release: not called CC=7 SCAR=40.3
229 0 my @cmd = ('lsb_release', '-irc');
230 0 ▶ open my $fh, '-|', @cmd
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "-|", @cmd or die "Error while running '@{cmd}': $!" 0 0 0
231 or die "Error while running '@cmd': $!";
232 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
233 0 chomp;
234 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
235 0 $info{linuxdistro} = lc $1;
236 } elsif (m{^Release:\s+(.*)}) {
237 0 $info{linuxdistroversion} = $1;
238 } elsif (m{^Codename:\s+(.*)}) {
239 0 $info{linuxdistrocodename} = $1;
240 } else {
241 0 warn "WARNING: unexpected '@cmd' output '$_'";
242 }
243 }
244 0 ▶ close $fh
Branch: 1 branch
BranchTrueFalseTotal
close $fh or die "Error while running '@{cmd}': $!" 0 0 0
245 or die "Error while running '@cmd': $!";
246 0 \%info;
247 }
248  
249 sub _detect_linux_distribution_fallback {
250 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
251 0 my $contents = <$fh>;
252 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
253 0 ▶ return {linuxdistro => lc $1, linuxdistroversion => $2, linuxdistrocodename => defined $3 ? $3 : ''};
Branch: 1 branch
BranchTrueFalseTotal
defined $3 ? : 0 0 0
254 }
255 }
256 0 ▶ if (open my $fh, '<', '/etc/issue') {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, '<', '/etc/issue') { } 0 0 0
257 0 chomp(my $line = <$fh>);
258 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
259 0 return {linuxdistro => lc('LinuxMint'), linuxdistroversion => $1, linuxdistrocodename => $2};
260 } elsif ($line =~ m{^(Debian) GNU/Linux (\d+)}) {
261 0 my %info = (linuxdistro => lc $1, linuxdistroversion => $2);
262 $info{linuxdistrocodename} =
263 {
264 6 => 'squeeze',
265 7 => 'wheezy',
266 8 => 'jessie',
267 9 => 'stretch',
268 10 => 'buster',
269 11 => 'bullseye',
270 12 => 'bookworm',
271 13 => 'trixie',
272 0 }->{$info{linuxdistroversion}};
273 0 return \%info;
274 } elsif ($line =~ m{^(Ubuntu) (\d+\.\d+)}) {
275 0 my %info = (linuxdistro => lc $1, linuxdistroversion => $2);
276 $info{linuxdistrocodename} =
277 {
278 '12.04' => 'precise',
279 '14.04' => 'trusty',
280 '16.04' => 'xenial',
281 '18.04' => 'bionic',
282 '20.04' => 'focal',
283 '22.04' => 'jammy',
284 '24.04' => 'noble',
285 0 }->{$info{linuxdistroversion}};
286 0 return \%info;
287 } else {
288 0 warn "WARNING: don't know how to handle '$line'";
289 }
290 } else {
291 0 warn "WARNING: no /etc/issue available";
292 }
293 0 return {};
294 }
295  
296 sub _is_linux_debian_like {
297 4318 ▶ my(undef, $linuxdistro) = @_;
Subroutine _is_linux_debian_like: called CC=1 SCAR=0.0
298 4318 $linuxdistro =~ m{^(debian|ubuntu|linuxmint)$};
299 }
300  
301 sub _is_linux_fedora_like {
302 2713 ▶ my(undef, $linuxdistro) = @_;
Subroutine _is_linux_fedora_like: called CC=1 SCAR=0.0
303 2713 $linuxdistro =~ m{^(fedora|redhat|centos|rocky)$};
304 }
305  
306 sub _is_linux_alpine_like {
307 12 ▶ my(undef, $linuxdistro) = @_;
Subroutine _is_linux_alpine_like: called CC=1 SCAR=0.0
308 12 $linuxdistro =~ m{^(alpine)$};
309 }
310  
311 17 ▶sub _is_apt_installer { shift->{installer} =~m{^(apt-get|aptitude)$} }
Subroutine _is_apt_installer: called CC=1 SCAR=0.0
312  
313 # Run a process in an elevated window, wait for its exit
314 sub _win32_run_elevated {
315 0 ▶ my($exe, @args) = @_;
Subroutine _win32_run_elevated: not called CC=2 SCAR=17.9
316
317 0 ▶ my $args = join " ", map { if(/[ "]/) { s!"!\\"!g; qq{"$_"} } else { $_ }} @args;
Branch: 1 branch
BranchTrueFalseTotal
if (/[ "]/) { } 0 0 0
318  
319 0 my $ps1 = sprintf q{powershell -NonInteractive -NoProfile -Command "$process = Start-Process '%s' -PassThru -ErrorAction Stop -ArgumentList '%s' -Verb RunAs -Wait; Exit $process.ExitCode"},
320 $exe, $args;
321  
322 0 $ps1;
323 }
324  
325 sub _debug {
326 94417 ▶ my $self = shift;
Subroutine _debug: called CC=3 SCAR=19.2
327 94417 ▶ if ($self->{debug}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"debug"}) 0 94417 94417
328 0 print STDERR 'DEBUG: ';
329 print STDERR join('', map {
330 0 ▶ if (ref $_) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_) { } 0 0 0
331 0 Data::Dumper->new([$_])->Terse(1)->Indent(0)->Dump;
332 } else {
333 0 $_;
334 }
335 } @_);
336 0 print STDERR "\n";
337 }
338 }
339  
340 sub _map_cpandist {
341 29 ▶ my($self, $dist) = @_;
Subroutine _map_cpandist: called CC=7 SCAR=19.5
342  
343 # compat for older CPAN.pm (1.76)
344 29 ▶ if (!$dist->can('base_id')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($dist->can("base_id")) 0 29 29
345 8 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
346 *CPAN::Distribution::base_id = sub {
347 0 ▶ my $self = shift;
Subroutine __ANON__: not called CC=1 SCAR=6.9
348 0 my $id = $self->id();
349 0 my $base_id = File::Basename::basename($id);
350 0 $base_id =~ s{\.(?:tar\.(bz2|gz|Z)|t(?:gz|bz)|zip)$}{}i;
351 0 return $base_id;
352 0 };
353 }
354  
355 # smartmatch for regexp/string/array without ~~, 5.8.x compat!
356 # also add support for numerical comparisons
357 my $smartmatch = sub ($$) {
358 15402 ▶ my($left, $right) = @_;
Subroutine __ANON__: called CC=13 SCAR=25.6
359 8 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
360 15402 ▶ if (ref $right eq 'Regexp') {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $right eq 'Regexp') { } 180 15222 15402
elsif (ref $right eq 'ARRAY') { } 1951 13271 15222
elsif (ref $right eq 'HASH') { } 425 12846 13271
361 180 ▶ return 1 if $left =~ $right;
Branch: 1 branch
BranchTrueFalseTotal
if $left =~ /$right/ 3 177 180
362 } elsif (ref $right eq 'ARRAY') {
363 1951 ▶ 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 1830 1951
not defined $left || defined $_ or $_ eq $left 6247 0 6247
Condition66%2/3
defined $left || defined $_
l!l&&r!l&&!r
469515520
MC/DC0%0/2
defined $left || defined $_
defined $left defined $_
Truth table66%2/3
A || B
A= defined $leftB= defined $_
ABresult
1X1
011
000
364 } elsif (ref $right eq 'HASH') {
365 425 for my $op (keys %$right) {
366 434 ▶ if ($op !~ SUPPORTED_NUMERICAL_OPS_RX) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($op =~ /^(\<|\<\=|\=\=|\>|\>\=)$/) 0 434 434
367 0 die "Unsupported operator '$op', only supported: @{SUPPORTED_NUMERICAL_OPS()}";
368 }
369 434 my $val = $right->{$op};
370 434 my $code = 'no warnings q(numeric); $left '.$op.' $val';
371 434 ▶ 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
Subroutine BEGIN: called CC=1 SCAR=0.0
372 434 ▶ die "Evaluation of '$code' failed: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 434 434
373 434 ▶ return 0 if !$res;
Branch: 1 branch
BranchTrueFalseTotal
unless $res 259 175 434
374 }
375 166 return 1;
376 } else {
377 12846 ▶ return 1 if !defined $left && !defined $right;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $left or defined $right 0 12846 12846
Condition66%2/3
defined $left or defined $right
l!l&&r!l&&!r
12789570
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
378 12846 ▶ return 1 if $left eq $right;
Branch: 1 branch
BranchTrueFalseTotal
if $left eq $right 79 12767 12846
379 }
380 29 };
381  
382 29 my $handle_mapping_entry; $handle_mapping_entry = sub {
383 36149 ▶ my($entry, $level) = @_;
Subroutine __ANON__: called CC=36 SCAR=36.4
384 36149 ▶ for(my $map_i=0; $map_i <= $#$entry; $map_i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($map_i <= $entry->$#*) 65502 19148 84650
385 65502 my $key_or_subentry = $entry->[$map_i];
386 65502 ▶ if (ref $key_or_subentry eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $key_or_subentry eq 'ARRAY') { } 28656 36846 65502
elsif (ref $key_or_subentry eq 'CODE') { } 1 36845 36846
387 28656 $self->_debug(' ' x $level . ' traverse another tree level');
388 28656 my $res = $handle_mapping_entry->($key_or_subentry, $level+1);
389 28655 ▶ return $res if $res && !$TRAVERSE_ONLY;
Branch: 1 branch
BranchTrueFalseTotal
if $res and not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY 20 28635 28655
Condition100%3/3
$res and not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
!ll&&!rl&&r
142351440020
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
390 } elsif (ref $key_or_subentry eq 'CODE') {
391 1 my $res = $key_or_subentry->($self, $dist);
392 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
393 } else {
394 36845 my $key = $key_or_subentry;
395 36845 my $match = $entry->[++$map_i];
396 36845 $self->_debug(' ' x $level . " match '$key' against '", $match, "'");
397 36845 ▶ if ($key eq 'cpandist') {
Branch: 8 branches
BranchTrueFalseTotal
if ($key eq 'cpandist') { } 19 36826 36845
elsif ($key eq 'cpanmod') { } 7474 29352 36826
elsif ($key eq 'os') { } 5271 24081 29352
elsif ($key eq 'osvers') { } 178 23903 24081
elsif ($key eq 'linuxdistro') { } 7766 16137 23903
elsif ($key eq 'linuxdistroversion') { } 420 15717 16137
elsif ($key eq 'linuxdistrocodename') { } 1308 14409 15717
elsif ($key eq 'package') { } 14409 0 14409
398 19 ▶ return 0 if !$smartmatch->($dist->base_id, $match) && !$TRAVERSE_ONLY;
Branch: 1 branch
BranchTrueFalseTotal
unless &$smartmatch($dist->base_id, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY 6 13 19
Condition100%3/3
&$smartmatch($dist->base_id, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
l!l&&r!l&&!r
1126
MC/DC100%2/2
&$smartmatch($dist->base_id, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
&$smartmatch($dist->base_id, $match) $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
Truth table100%3/3
A or B
A= &$smartmatch($dist->base_id, $match)B= $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
ABresult
1X1
011
000
399 } elsif ($key eq 'cpanmod') {
400 7474 my $found = 0;
401 7474 for my $mod ($dist->containsmods) {
402 7474 $self->_debug(' ' x $level . " found module '$mod' in dist, check now against '", $match, "'");
403 7474 ▶ if ($smartmatch->($mod, $match)) {
Branch: 1 branch
BranchTrueFalseTotal
if (&$smartmatch($mod, $match)) 15 7459 7474
404 15 $found = 1;
405 15 last;
406 }
407 }
408 7474 ▶ return 0 if !$found && !$TRAVERSE_ONLY;
Branch: 1 branch
BranchTrueFalseTotal
unless $found or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY 2550 4924 7474
Condition100%3/3
$found or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
l!l&&r!l&&!r
1549092550
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
409 } elsif ($key eq 'os') {
410 5271 ▶ return 0 if !$smartmatch->($self->{os}, $match) && !$TRAVERSE_ONLY;
Branch: 1 branch
BranchTrueFalseTotal
unless &$smartmatch($self->{"os"}, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY 7 5264 5271
Condition100%3/3
&$smartmatch($self->{"os"}, $match) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
l!l&&r!l&&!r
2052447
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
411 } elsif ($key eq 'osvers') {
412 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
413 } elsif ($key eq 'linuxdistro') {
414 7766 ▶ if ($match =~ m{^~(debian|fedora|alpine)$}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($match =~ /^~(debian|fedora|alpine)$/) { } 7033 733 7766
elsif ($match =~ /^~/) { } 1 732 733
415 7033 my $method = "_is_linux_$1_like";
416 7033 $self->_debug(' ' x $level . " translate $match to $method");
417 7033 ▶ 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 7033 7033
Condition66%2/3
$self->$method($self->{"linuxdistro"}) or $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
l!l&&r!l&&!r
260844250
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
418 } elsif ($match =~ m{^~}) {
419 1 die "'like' matches only for debian, fedora, and alpine";
420 } else {
421 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
422 }
423 } elsif ($key eq 'linuxdistroversion') {
424 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
425 } elsif ($key eq 'linuxdistrocodename') {
426 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
427 } elsif ($key eq 'package') {
428 14409 $self->_debug(' ' x $level . " found $match"); # XXX array?
429 14409 return { package => $match };
430 } else {
431 0 die "Invalid key '$key'"; # XXX context/position?
432 }
433 }
434 }
435 29 };
436  
437 29 ▶ for my $entry (@{ $self->{mapping} || [] }) {
Branch: 1 branch
BranchTrueFalseTotal
$self->{"mapping"} or [] 0 29 29
438 7493 my $res = $handle_mapping_entry->($entry, 0);
439 7492 ▶ if ($res && !$TRAVERSE_ONLY) {
Branch: 1 branch
BranchTrueFalseTotal
if ($res and not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY) 10 7482 7492
Condition66%2/3
$res and not $CPAN::Plugin::Sysdeps::TRAVERSE_ONLY
!ll&&!rl&&r
7482010
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
440 10 ▶ return ref $res->{package} eq 'ARRAY' ? @{ $res->{package} } : $res->{package};
Branch: 1 branch
BranchTrueFalseTotal
ref $res->{'package'} eq 'ARRAY' ? : 2 8 10
441 }
442 }
443  
444 18 ();
445 }
446  
447 sub _detect_dnf {
448 1 ▶ my @cmd = ('dnf', '--help');
Subroutine _detect_dnf: called CC=2 SCAR=7.8
449 1 require IPC::Open3;
450 1 require Symbol;
451 1 my $err = Symbol::gensym();
452 1 my $fh;
453 1 return eval {
454 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
455 0 waitpid $pid, 0;
456 0 return $? == 0;
457 }
458 };
459 }
460  
461 sub _find_missing_deb_packages {
462 5 ▶ my($self, @packages) = @_;
Subroutine _find_missing_deb_packages: called CC=8 SCAR=24.8
463 5 ▶ return () if !@packages;
Branch: 1 branch
BranchTrueFalseTotal
unless @packages 1 4 5
464  
465 # taken from ~/devel/deb-install.pl
466 4 my %seen_packages;
467 my @missing_packages;
468  
469 4 my @cmd = ('dpkg-query', '-W', '-f=${Package} ${Status}\n', @packages);
470 4 require IPC::Open3;
471 4 require Symbol;
472 4 my $err = Symbol::gensym();
473 4 my $fh;
474 4 ▶ 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 4 4
475 or die "Error running '@cmd': $!";
476 4 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 4 4
477 0 chomp;
478 0 ▶ if (m{^(\S+) (.*)}) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^(\S+) (.*)/) { } 0 0 0
479 0 ▶ if ($2 ne 'install ok installed') {
Branch: 1 branch
BranchTrueFalseTotal
if ($2 ne "install ok installed") 0 0 0
480 0 push @missing_packages, $1;
481 }
482 0 $seen_packages{$1} = 1;
483 } else {
484 0 warn "ERROR: cannot parse $_, ignore line...\n";
485 }
486 }
487 4 waitpid $pid, 0;
488 4 for my $package (@packages) {
489 6 ▶ if (!$seen_packages{$package}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($seen_packages{$package}) 6 0 6
490 6 push @missing_packages, $package;
491 }
492 }
493 4 @missing_packages;
494 }
495  
496 sub _find_missing_rpm_packages {
497 6 ▶ my($self, @packages) = @_;
Subroutine _find_missing_rpm_packages: called CC=11 SCAR=24.2
498 6 ▶ return () if !@packages;
Branch: 1 branch
BranchTrueFalseTotal
unless @packages 1 5 6
499  
500 5 my @missing_packages;
501 {
502 5 my %packages = map{($_,1)} @packages;
503  
504 5 local $ENV{LC_ALL} = 'C';
505 5 my @cmd = ('rpm', '-q', @packages);
506 5 ▶ open my $fh, '-|', @cmd
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "-|", @cmd or die "Error running '@{cmd}': $!" 0 5 5
507 or die "Error running '@cmd': $!";
508 5 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 8 5 13
509 8 ▶ if (m{^package (\S+) is not installed}) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^package (\S+) is not installed/) 4 4 8
510 4 my $package = $1;
511 4 ▶ if (!exists $packages{$package}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $packages{$package}) 0 4 4
512 0 die "Unexpected: package $package listed as non-installed, but not queried in '@cmd'?!";
513 }
514 4 push @missing_packages, $package;
515 }
516 }
517 }
518 5 ▶ return () if !@missing_packages;
Branch: 1 branch
BranchTrueFalseTotal
unless @missing_packages 1 4 5
519  
520 # maybe the packages are just provided by another package?
521 4 my @definitively_missing_packages;
522 {
523 4 my %packages = map{($_,1)} @missing_packages;
524  
525 4 local $ENV{LC_ALL} = 'C';
526 4 my @cmd = ('rpm', '-q', '--whatprovides', @missing_packages);
527 4 ▶ open my $fh, '-|', @cmd
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "-|", @cmd or die "Error running '@{cmd}': $!" 0 4 4
528 or die "Error running '@cmd': $!";
529 4 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 5 4 9
530 5 ▶ if (m{^no package provides (\S+)}) {
Branch: 1 branch
BranchTrueFalseTotal
if (/^no package provides (\S+)/) 3 2 5
531 3 my $package = $1;
532 3 ▶ if (!exists $packages{$package}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $packages{$package}) 0 3 3
533 0 die "Unexpected: package $package listed as non-installed, but not queried in '@cmd'?!";
534 }
535 3 push @definitively_missing_packages, $package;
536 }
537 }
538 }
539  
540 4 @definitively_missing_packages;
541 }
542  
543 sub _find_missing_freebsd_pkg_packages {
544 0 ▶ my($self, @packages) = @_;
Subroutine _find_missing_freebsd_pkg_packages: not called CC=4 SCAR=30.0
545 0 ▶ return () if !@packages;
Branch: 1 branch
BranchTrueFalseTotal
unless @packages 0 0 0
546  
547 0 my @missing_packages;
548 0 for my $package (@packages) {
549 0 my @cmd = ('pkg', 'info', '--exists', $package);
550 0 system @cmd;
551 0 ▶ if ($? != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
552 0 push @missing_packages, $package;
553 }
554 }
555  
556 0 @missing_packages;
557 }
558  
559 sub _find_missing_openbsd_pkg_packages {
560 0 ▶ my($self, @packages) = @_;
Subroutine _find_missing_openbsd_pkg_packages: not called CC=7 SCAR=40.3
561 0 ▶ return () if !@packages;
Branch: 1 branch
BranchTrueFalseTotal
unless @packages 0 0 0
562  
563 0 require IPC::Open3;
564 0 require Symbol;
565  
566 0 my @missing_packages;
567 0 for my $package (@packages) {
568 0 my $err = Symbol::gensym();
569 0 my $fh;
570 my $package_in_repository;
571 0 eval {
572 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
573 0 waitpid $pid, 0;
574 0 ▶ if ($? == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? == 0) 0 0 0
575 0 $package_in_repository = 1;
576 }
577 }
578 };
579 0 ▶ if ($package_in_repository) {
Branch: 1 branch
BranchTrueFalseTotal
if ($package_in_repository) 0 0 0
580 0 my @cmd = ('pkg_info', '-q', '-e', "${package}->=0");
581 0 system @cmd;
582 0 ▶ if ($? != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
583 0 push @missing_packages, $package;
584 }
585 }
586 }
587  
588 0 @missing_packages;
589 }
590  
591 sub _find_missing_homebrew_packages {
592 0 ▶ my($self, @packages) = @_;
Subroutine _find_missing_homebrew_packages: not called CC=6 SCAR=37.4
593 0 ▶ return () if !@packages;
Branch: 1 branch
BranchTrueFalseTotal
unless @packages 0 0 0
594  
595 0 my @missing_packages;
596 0 for my $package (@packages) {
597 0 my @cmd = ('brew', 'ls', '--versions', $package);
598 0 ▶ open my $fh, '-|', @cmd
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "-|", @cmd or die "Error running @{cmd}: $!" 0 0 0
599 or die "Error running @cmd: $!";
600 0 my $has_package;
601 0 ▶ while(<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 0 0 0
602 0 $has_package = 1;
603 0 last;
604 }
605 0 close $fh; # earlier homebrew versions returned always 0,
606 # newer (since Oct 2016) return 1 if the package is
607 # missing
608 0 ▶ if (!$has_package) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($has_package) 0 0 0
609 0 push @missing_packages, $package;
610 }
611 }
612 0 @missing_packages;
613 }
614  
615 sub _find_missing_chocolatey_packages {
616 0 ▶ my($self, @packages) = @_;
Subroutine _find_missing_chocolatey_packages: not called CC=3 SCAR=24.8
617 0 ▶ return () if !@packages;
Branch: 1 branch
BranchTrueFalseTotal
unless @packages 0 0 0
618  
619 my %installed_packages = map {
620 0 ▶ /^(.*)\|(.*)$/
Branch: 1 branch
BranchTrueFalseTotal
/^(.*)\|(.*)$/ or next 0 0 0
621 or next;
622 0 $1 => $2
623 } grep {
624 0 /^(.*)\|(.*)$/
625 } `choco list --localonly --limit-output`;
626 0 my @missing_packages = grep { ! $installed_packages{ $_ }} @packages;
627 0 @missing_packages;
628 }
629  
630 sub _find_missing_apk_packages {
631 0 ▶ my($self, @packages) = @_;
Subroutine _find_missing_apk_packages: not called CC=4 SCAR=30.0
632 0 ▶ return () if !@packages;
Branch: 1 branch
BranchTrueFalseTotal
unless @packages 0 0 0
633  
634 0 my @missing_packages;
635 0 for my $package (@packages) {
636 0 my @cmd = ('apk', 'info', '-e', $package);
637 0 system @cmd;
638 0 ▶ if ($? != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
639 0 push @missing_packages, $package;
640 }
641 }
642  
643 0 @missing_packages;
644 }
645  
646 sub _filter_uninstalled_packages {
647 4 ▶ my($self, @packages) = @_;
Subroutine _filter_uninstalled_packages: called CC=14 SCAR=39.2
648 4 my $find_missing_packages;
649 4 ▶ if ($self->_is_apt_installer) {
Branch: 7 branches
BranchTrueFalseTotal
if ($self->_is_apt_installer) { } 4 0 4
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
650 4 $find_missing_packages = '_find_missing_deb_packages';
651 ▶ } 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
652 0 $find_missing_packages = '_find_missing_rpm_packages';
653 ▶ } 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
654 0 $find_missing_packages = '_find_missing_freebsd_pkg_packages';
655 } elsif ($self->{os} eq 'openbsd') {
656 0 $find_missing_packages = '_find_missing_openbsd_pkg_packages';
657 } elsif ($self->{os} eq 'MSWin32') {
658 0 $find_missing_packages = '_find_missing_chocolatey_packages';
659 } elsif ($self->{installer} eq 'homebrew') {
660 0 $find_missing_packages = '_find_missing_homebrew_packages';
661 } elsif ($self->{installer} eq 'apk') {
662 0 $find_missing_packages = '_find_missing_apk_packages';
663 } else {
664 0 warn "check for installed packages is NYI for $self->{os}/$self->{linuxdistro}";
665 }
666 4 ▶ if ($find_missing_packages) {
Branch: 1 branch
BranchTrueFalseTotal
if ($find_missing_packages) 4 0 4
667 4 my @plain_packages;
668 my @missing_packages;
669 4 for my $package_spec (@packages) {
670 5 ▶ if ($package_spec =~ m{\|}) { # has alternatives
Branch: 1 branch
BranchTrueFalseTotal
if ($package_spec =~ /\|/) { } 1 4 5
671 1 my @single_packages = split /\s*\|\s*/, $package_spec;
672 1 my @missing_in_packages_spec = $self->$find_missing_packages(@single_packages);
673 1 ▶ if (@missing_in_packages_spec == @single_packages) {
Branch: 1 branch
BranchTrueFalseTotal
if (@missing_in_packages_spec == @single_packages) 1 0 1
674 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
675 }
676 } else {
677 4 push @plain_packages, $package_spec;
678 }
679 }
680 4 push @missing_packages, $self->$find_missing_packages(@plain_packages);
681 4 @packages = @missing_packages;
682 }
683 4 @packages;
684 }
685  
686 sub _install_packages_commands {
687 13 ▶ my($self, @packages) = @_;
Subroutine _install_packages_commands: called CC=31 SCAR=38.0
688 13 my @pre_cmd;
689 my @install_cmd;
690  
691 # sudo or not?
692 13 ▶ if ($self->{installer} eq 'homebrew') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'installer'} eq 'homebrew') { } 1 12 13
elsif ($self->{'installer'} eq 'chocolatey') { } 0 12 12
693 # may run as unprivileged user
694 } elsif ($self->{installer} eq 'chocolatey') {
695 # no sudo on Windows systems?
696 } else {
697 12 ▶ if ($< != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($< != 0) 12 0 12
698 12 push @install_cmd, 'sudo';
699 }
700 }
701  
702 # the installer executable
703 13 ▶ if ($self->{installer} eq 'homebrew') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'installer'} eq 'homebrew') { } 1 12 13
elsif ($self->{'installer'} eq 'chocolatey') { } 0 12 12
704 1 push @install_cmd, 'brew';
705 } elsif ($self->{installer} eq 'chocolatey') {
706 0 push @install_cmd, 'choco';
707 } else {
708 12 push @install_cmd, $self->{installer};
709 }
710  
711 # batch, default or interactive
712 13 ▶ if ($self->{batch}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'batch'}) { } 4 9 13
713 4 ▶ if ($self->_is_apt_installer) {
Branch: 5 branches
BranchTrueFalseTotal
if ($self->_is_apt_installer) { } 3 1 4
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
714 3 push @install_cmd, '-y';
715 ▶ } 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
716 0 push @install_cmd, '-y';
717 } elsif ($self->{installer} eq 'pkg') { # FreeBSD's pkg
718 # see below
719 } elsif ($self->{installer} eq 'homebrew') {
720 # batch by default
721 } elsif ($self->{installer} eq 'apk') {
722 # batch by default
723 } else {
724 0 warn "batch=1 NYI for $self->{installer}";
725 }
726 } else {
727 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
728 3 @pre_cmd = ('sh', '-c', 'echo -n "Install package(s) '."@packages".'? (y/N) "; read yn; [ "$yn" = "y" ]');
729 ▶ } 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
730 # interactive by default
731 } elsif ($self->{installer} eq 'pkg') { # FreeBSD's pkg
732 # see below
733 } elsif ($self->{installer} =~ m{^(chocolatey)$}) {
734 # Nothing to do here
735 } elsif ($self->{installer} eq 'homebrew') {
736 # the sh builtin echo does not understand -n -> use printf
737 1 @pre_cmd = ('sh', '-c', 'printf %s "Install package(s) '."@packages".'? (y/N) "; read yn; [ "$yn" = "y" ]');
738 } elsif ($self->{installer} eq 'apk') {
739 1 @pre_cmd = ('sh', '-c', 'printf %s "Install package(s) '."@packages".'? (y/N) "; read yn; [ "$yn" = "y" ]');
740 } else {
741 1 warn "batch=0 NYI for $self->{installer}";
742 }
743 }
744  
745 # special options
746 13 ▶ if ($self->{installer} eq 'pkg') { # FreeBSD's pkg
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"installer"} eq "pkg") 1 12 13
747 1 push @install_cmd, '--option', 'LOCK_RETRIES=86400'; # wait quite long in case there are concurrent pkg runs
748 }
749  
750 # the installer subcommand
751 13 ▶ if ($self->{installer} eq 'apk') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'installer'} eq 'apk') { } 2 11 13
elsif ($self->{'installer'} ne 'pkg_add') { } 10 1 11
752 2 push @install_cmd, 'add';
753 } elsif ($self->{installer} ne 'pkg_add') {
754 10 push @install_cmd, 'install';
755 }
756  
757 # post options
758 13 ▶ if ($self->{batch} && $self->{installer} eq 'pkg') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"batch"} and $self->{"installer"} eq "pkg") 0 13 13
Condition66%2/3
$self->{"batch"} and $self->{"installer"} eq "pkg"
!ll&&!rl&&r
940
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
759 0 push @install_cmd, '-y';
760 }
761 13 ▶ if ($self->{batch} && $self->{installer} eq 'chocolatey') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"batch"} and $self->{"installer"} eq "chocolatey") 0 13 13
Condition66%2/3
$self->{"batch"} and $self->{"installer"} eq "chocolatey"
!ll&&!rl&&r
940
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
762 0 push @install_cmd, '-y';
763 }
764 13 ▶ if ($self->{batch} && $self->{installer} eq 'pkg_add') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"batch"} and $self->{"installer"} eq "pkg_add") 0 13 13
Condition66%2/3
$self->{"batch"} and $self->{"installer"} eq "pkg_add"
!ll&&!rl&&r
940
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
765 0 push @install_cmd, '-I';
766 }
767  
768 13 push @install_cmd, @packages;
769
770 13 ▶ if ($self->{os} eq 'MSWin32') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"os"} eq "MSWin32") 0 13 13
771 # Wrap the thing in our small powershell program
772 0 @install_cmd = _win32_run_elevated(@install_cmd);
773 };
774  
775 13 ▶ ((@pre_cmd ? \@pre_cmd : ()), \@install_cmd);
Branch: 1 branch
BranchTrueFalseTotal
@pre_cmd ? : 5 8 13
776 }
777  
778 8 1;
779  
780 __END__
↑ Summary blib/lib/CPAN/Plugin/Sysdeps/Mapping.pm »