Branch Coverage

lib/Provision/Unix/Utility.pm
Criterion Covered Total %
branch 173 656 26.3


line true false branch
33 0 15 unless ($Provision::Unix::Utility::log)
44 15 0 if defined $p{'debug'}
45 15 0 if defined $p{'fatal'}
80 0 0 unless ($self->is_interactive)
85 0 0 unless $question =~ /\A \p{Any}* \z/msx
90 0 0 if defined $p{'test_ok'}
94 0 0 if $default and not $pass
97 0 0 if $pass
99 0 0 if ($p{'timeout'}) { }
106 0 0 if ($Provision::Unix::Utility::EVAL_ERROR)
107 0 0 $Provision::Unix::Utility::EVAL_ERROR eq "alarm\n" ? :
114 0 0 if ($pass)
117 0 0 unless ($response eq $response2)
127 0 0 if defined $response
128 0 0 if defined $default
134 0 5 unless my $file = shift()
145 1 4 unless -e $file
150 0 4 if ($p{'destdir'} and -d $p{'destdir'})
156 4 0 if ($self->is_writable($file, %args) and $self->is_writable($archive, %args))
161 4 0 if (-e $archive)
163 0 4 if $p{'mode'}
169 0 0 if $p{'sudo'} and $< != 0
171 0 0 unless -e $archive
174 0 0 if $p{'mode'}
187 0 0 if ($sudo and $cp)
212 0 3 unless my $file = $p{'file'} || $p{'file_or_dir'} || $p{'dir'}
215 0 3 if ($p{'sudo'})
218 0 0 unless $self->syscmd("$sudo $chmod $mode $file", 'debug', 0)
223 0 3 unless CORE::chmod oct $mode, $file
243 0 3 unless $file
244 0 3 unless -e $file
249 0 3 if $sudo
257 0 3 if ($uid =~ /\A[0-9]+\z/) { }
263 1 2 unless defined $nuid
267 0 2 if ($gid =~ /\A[0-9\-]+\z/) { }
273 0 2 unless defined $ngid
277 0 2 unless CORE::chown $nuid, $ngid, $file
297 0 1 unless $dir
300 0 1 if $recurse
302 0 1 if $group
307 0 1 unless $self->syscmd($cmd, %args)
311 0 1 if $recurse
333 0 2 unless chdir $dir
337 0 5 unless $_
343 4 1 if (-f $file) { }
1 0 elsif (-d $file) { }
344 0 4 unless unlink $file
349 0 1 unless rmtree($file)
362 0 2 unless my $dir = shift()
373 0 2 if -e $dir and not -d $dir
377 1 1 unless (-d $dir)
381 0 1 unless (-d $dir)
385 0 0 unless (-d $dir)
387 0 0 unless $self->mkdir_system('dir', $dir, 'sudo', 1, %args)
393 0 2 unless chdir $dir
399 0 1 unless mkpath($dir, 0, 493)
407 0 2 unless my $archive = shift()
413 1 1 unless (-e $archive)
414 0 1 if (-e "$archive.tar.gz") { }
0 1 elsif (-e "$archive.tgz") { }
0 1 elsif (-e "$archive.tar.bz2") { }
426 0 1 unless $archive =~ /[bz2|gz]$/
439 1 0 $archive =~ /gz$/ ? :
0 1 $archive =~ /bz2$/ ? :
445 0 1 unless grep /$types{$type}{'content'}/, `$file $archive`
450 0 1 unless $self->syscmd("$bin -c $archive | $tar -xf -")
468 1 5 unless -e $file
470 5 0 if (-w $file)
473 0 5 unless unlink $file
479 0 0 unless ($p{'sudo'})
480 0 0 -e $file ? :
487 0 0 if ($< != 0)
493 0 0 unless $self->syscmd($rm_command, %args)
496 0 0 -e $file ? :
521 1 1 if $stat2 > $stat1
534 0 4 unless my $file = shift()
547 0 4 unless -e $file
548 0 4 unless -r $file
550 0 4 unless open my $FILE, '<', $file
555 4 0 unless ($max_lines)
564 0 0 if ($max_length) { }
587 0 1 unless -e $file
605 0 9 unless my $file = shift()
620 0 9 if -d $file
621 0 9 unless $self->is_writable($file, %args)
627 3 6 if ($append)
630 3 0 if (-f $file)
631 0 3 unless copy($file, "$file.tmp")
636 0 9 unless open my $HANDLE, $write_mode, "$file.tmp"
641 0 9 unless close $HANDLE
645 0 9 unless move("$file.tmp", $file)
649 0 9 if $p{'mode'}
670 0 5 unless (-e $f1 and -e $f2)
675 2 3 if $type ne 'text'
696 0 2 if $Provision::Unix::Utility::EVAL_ERROR
707 2 2 if (-f "$f.md5")
713 3 1 if (not -f "$f.md5" && $sum =~ /[0-9a-f]+/i or $self->file_is_newer('f1', "$f.md5", 'f2', $f, %$args))
727 3 1 if $changed
730 1 1 if $md5sums[0] eq $md5sums[1]
736 0 44 unless my $bin = shift()
747 0 44 if ($bin =~ m[^/] and -x $bin)
753 0 44 if $p{'dir'}
762 28 323 if (-x "$prefix/$bin")
763 28 0 if $found = "$prefix/$bin"
767 28 16 if ($found)
784 0 1 if ($Provision::Unix::Utility::OSNAME eq 'darwin')
789 0 1 unless (-e $fstab)
790 0 0 if $p{'debug'}
870 0 3 unless -d $dir
873 0 3 unless opendir D, $dir
876 6 140 if $f =~ /^\.\.?$/
922 0 0 if $p{'exclude_ipv6'}
923 0 0 if $p{'exclude_localhost'}
924 0 0 if $p{'exclude_internals'}
928 0 0 if (@ips < 1 or $ips[0] eq '')
929 0 0 if $debug
932 0 0 if $once < 2
937 0 0 if $only eq 'first'
938 0 0 if $only eq 'last'
958 1 4 if $bump
960 1 4 if $time != $offset_time
964 5 0 unless ($Provision::Unix::Utility::EVAL_ERROR)
1005 0 1 unless -x $mount
1013 17 0 if ($m and $m =~ m[^/])
1014 17 0 if $p{'debug'}
1039 0 0 if $Provision::Unix::Utility::EVAL_ERROR
1045 0 0 if $dir
1050 0 0 if ($response)
1051 0 0 if ($response == 404) { }
0 0 elsif ($response == 304) { }
0 0 elsif ($response == 200) { }
1065 0 0 unless -e $file_path
1085 0 0 if ($Provision::Unix::Utility::OSNAME eq 'freebsd') { }
0 0 elsif ($Provision::Unix::Utility::OSNAME eq 'darwin') { }
1087 0 0 if ($fetchbin and -x $fetchbin)
1089 0 0 unless $debug
1094 0 0 if ($fetchbin and -x $fetchbin)
1096 0 0 unless $debug
1100 0 0 unless ($found)
1102 0 0 if $fetchbin and -x $fetchbin
1105 0 0 unless $found
1111 0 0 unless ($timeout)
1112 0 0 unless $self->syscmd($fetchcmd, %args)
1116 0 0 if (-e $file and $dir and -d $dir)
1131 0 0 if ($Provision::Unix::Utility::EVAL_ERROR)
1132 0 0 if $Provision::Unix::Utility::EVAL_ERROR eq "alarm\n"
1136 0 0 unless $r
1164 0 1 unless ($newfile =~ m[/])
1171 0 1 unless -e $newfile
1174 0 1 unless -f $newfile
1178 0 1 unless ($self->is_writable($existing, 'fatal', 0) and $self->is_writable($newfile, 'fatal', 0))
1182 0 0 if $Provision::Unix::Utility::UID == 0
1184 0 0 if ($sudo)
1185 0 0 unless $sudo = $self->find_bin('sudo', %args)
1191 1 0 if (-f $existing)
1196 1 0 unless ($diffie = $self->files_diff(%args, 'f1', $newfile, 'f2', $existing, 'type', 'text'))
1198 0 1 if $p{'clean'}
1205 0 0 if $uid and $gid
1214 0 0 if -e $existing and $mode
1223 0 0 if -e $existing and $p{'archive'}
1226 0 0 if $uid and $gid
1233 0 0 if $mode
1250 0 0 if ($sudo) { }
1254 0 0 if -e $existing
1258 0 0 if ($clean) { }
1269 0 0 if -e $existing
1271 0 0 if ($clean) { }
1272 0 0 unless move($newfile, $existing)
1276 0 0 unless copy($newfile, $existing)
1286 0 0 unless $notify
1287 0 0 unless -f $existing
1293 0 0 if $Provision::Unix::Utility::EVAL_ERROR
1324 2 0 if defined $p{'test_ok'}
1333 0 0 if $p{'source_sub_dir'}
1339 0 0 if ($bintest and $self->find_bin($bintest, 'fatal', 0, 'debug', 0))
1340 0 0 unless $self->yes_or_no("$bintest exists, suggesting that " . "$package is installed. Do you want to reinstall?", 'timeout', 60)
1349 0 0 unless $self->install_from_source_cleanup($package, $src)
1350 0 0 unless $self->install_from_source_get_files($package, $site, $url, $p{'patch_url'}, $patches)
1352 0 0 unless $self->extract_archive($package)
1357 0 0 if (-d $package) { }
1358 0 0 unless chdir $package
1368 0 0 if $sub_path
1369 0 0 unless -d $sub_path and chdir $sub_path
1373 0 0 unless $self->install_from_source_apply_patches($src, $patches, $patch_args)
1376 0 0 unless (@$targets[0])
1383 0 0 if $debug
1388 0 0 if ($target =~ /^cd (.*)$/)
1390 0 0 unless chdir $1
1394 0 0 unless $self->syscmd($target, 'debug', $debug)
1400 0 0 if -d $package
1402 0 0 if defined $sub_path and -d "$package/$sub_path"
1413 0 0 unless $patches
1414 0 0 unless $$patches[0]
1418 0 0 unless $self->syscmd("$patchbin $patch_args < $src/$patch")
1429 0 0 unless -d $package
1431 0 0 unless $self->source_warning('package', $package, 'clean', 1, 'src', $src)
1445 0 0 unless $self->sources_get('package', $package, 'site', $site, 'path', $url)
1451 0 0 unless ($patches and $$patches[0])
1456 0 0 unless $patch_url
1461 0 0 unless $patch
1462 0 0 if -e $patch
1466 0 0 unless $self->get_url($url)
1476 0 0 if (lc $Provision::Unix::Utility::OSNAME eq 'freebsd')
1478 0 0 unless my $portname = $$info{'port'}
1481 0 0 if (`/usr/sbin/pkg_info | /usr/bin/grep $app`)
1489 0 0 unless -d $portdir and chdir $portdir
1492 0 0 if system 'make install clean'
1497 0 0 if (lc $Provision::Unix::Utility::OSNAME eq 'linux')
1498 0 0 unless my $rpm = $$info{'rpm'}
1500 0 0 unless -x $yum
1511 0 0 defined $info{'debug'} ? :
1516 0 0 unless ($Provision::Unix::Utility::EVAL_ERROR)
1520 0 0 if (lc $Provision::Unix::Utility::OSNAME eq 'darwin') { }
0 0 elsif (lc $Provision::Unix::Utility::OSNAME eq 'freebsd') { }
0 0 elsif (lc $Provision::Unix::Utility::OSNAME eq 'linux') { }
1521 0 0 if $self->install_module_darwin($module)
1524 0 0 if $self->install_module_freebsd($module, \%info)
1527 0 0 if $self->install_module_linux($module, \%info)
1535 0 0 unless ($Provision::Unix::Utility::EVAL_ERROR)
1555 0 0 if ($module eq 'Provision::Unix' and $version)
1567 0 0 unless -x $dport
1572 0 0 unless system "sudo $dport install $port"
1581 0 0 unless ($portname)
1587 0 0 if $r
1591 0 0 if ($portdir and -d $portdir and chdir $portdir)
1619 0 0 if (-d $module)
1620 0 0 unless ($self->source_warning('package', $module, 'src', $src, %args))
1628 0 0 unless $self->sources_get('site', $site, 'path', $url, 'package', $p{'archive'} || $module, %args)
1634 0 0 unless $self->extract_archive($module)
1640 0 0 unless -d $file
1641 0 0 unless $file =~ /$module/
1647 0 0 unless (@$targets[0] and @$targets[0] ne '')
1654 0 0 unless $self->syscmd('cmd', $_, %args)
1670 0 0 if ($rpm)
1674 0 0 if -x $yum
1686 0 0 unless -t $out_handle
1689 0 0 if (openhandle(*ARGV))
1692 0 0 if defined $ARGV and $ARGV eq '-'
1695 0 0 if eof ARGV
1713 2 0 unless ($Provision::Unix::Utility::EVAL_ERROR)
1716 2 0 if (scalar @{$t->table;})
1718 0 20 if $p->cmndline =~ /$process/i
1726 0 0 if (lc($Provision::Unix::Utility::OSNAME) =~ /solaris/i) { }
0 0 elsif (lc($Provision::Unix::Utility::OSNAME) =~ /irix/i) { }
0 0 elsif (lc($Provision::Unix::Utility::OSNAME) =~ /linux/i) { }
1738 0 2 unless my $file = shift()
1743 1 1 unless -e $file
1744 0 1 unless -r $file
1753 0 22 unless my $file = shift()
1759 0 22 if $ENV{'GATEWAY_INTERFACE'}
1761 8 14 unless (-e $file)
1765 0 8 if -e $path and not -w $path
1771 0 14 unless -w $file
1793 0 3 unless open my $LOG_FILE, '>>', $file
1827 0 1 if -d $dir
1829 0 1 unless my $mkdir = $self->find_bin('mkdir', %args)
1832 1 0 if ($< == 0)
1833 0 1 unless $self->syscmd("$mkdir -p $dir", %args)
1834 0 1 if $mode
1836 1 0 if -d $dir
1840 0 0 if ($p{'sudo'})
1850 0 0 if $mode
1852 0 0 -d $dir ? :
1858 0 0 unless $self->syscmd("$mkdir -p $dir", %args)
1860 0 0 if $mode
1862 0 0 if -d $dir
1872 0 1 if ($dir =~ m[/$])
1894 0 3 unless $file
1895 1 2 if -e $file and not -f $file
1900 0 2 unless ($self->is_writable($file, %args))
1907 1 1 unless (-e $file)
1909 1 0 if $self->file_write($file, 'lines', [$Provision::Unix::Utility::PROCESS_ID], %args)
1914 1 0 if ($age < 1200) { }
0 0 elsif ($age < 3600) { }
1950 0 1 if ($pbp)
1951 0 0 if ($string =~ /($exp)/msx) { }
1952 0 0 if $debug
1956 0 0 if $debug
1961 1 0 if ($string =~ /($exp)/)
1962 0 1 if $debug
1966 0 0 if $debug
1988 0 0 unless my $filet = $self->find_bin('file', %args)
1989 0 0 unless my $grep = $self->find_bin('grep', %args)
1994 0 0 unless -e $tarball
1995 0 0 if -e $tarball
1997 0 0 if (`$filet $tarball | $grep compress`)
1998 0 0 if $self->yes_or_no("$tarball exists, shall I use it?: ")
2010 0 0 unless $self->get_url("$site$path/$tarball", 'fatal', 0)
2013 0 0 unless -e $tarball
2017 0 0 if (`$filet $tarball | $grep zip`)
2048 1 0 unless -d $package
2050 0 0 if (-e $package)
2055 0 0 unless $p{'clean'}
2058 0 0 unless ($self->yes_or_no("\n\tMay I remove the sources for you?", 'timeout', $p{'timeout'}))
2066 0 0 unless rmtree("$src/$package")
2076 1 0 if ($Provision::Unix::Utility::REAL_USER_ID == 0)
2085 0 0 if ($path_to_sudo and -x $path_to_sudo)
2093 0 0 unless ($self->yes_or_no('may I try to install sudo?', 'timeout', 20))
2098 0 0 unless -x $self->find_bin('sudo', 'fatal', 0)
2111 0 0 unless (-x $path_to_sudo)
2121 0 15 unless my $cmd = shift()
2136 15 0 if ($cmd =~ /\s+/mx) { }
2145 0 0 unless ($cmd =~ m[\./])
2148 0 15 if ($is_safe and not $bin)
2153 15 0 if $bin
2154 15 0 if $is_safe
2157 5 10 if ($bin and not -e $bin)
2158 0 5 unless $bin = $self->find_bin($bin, 'fatal', 0, 'debug', 0)
2164 0 15 if &Scalar::Util::tainted($cmd)
2171 0 15 if $tainted and not $is_safe
2174 15 0 if ($is_safe)
2176 0 15 if -d '/opt/local'
2182 1 14 if (defined $p{'timeout'})
2188 1 14 if defined $p{'timeout'}
2191 0 15 if ($Provision::Unix::Utility::EVAL_ERROR)
2192 0 0 if ($Provision::Unix::Utility::EVAL_ERROR eq "alarm\n") { }
2212 13 2 if $exit_code == 0
2217 0 2 if ($err == -1) { }
0 2 elsif ($err & 127) { }
2221 0 0 $? & 128 ? :
2241 1 0 if $question eq 'test'
2244 0 0 unless ($p{'force'} or $self->is_interactive)
2251 0 0 if $p{'timeout'}
2268 0 0 if ($p{'timeout'})
2280 0 0 if ($@)
2281 0 0 $@ eq "alarm\n" ? :
2284 0 0 $response && $response eq 'y' ? :
2293 0 0 $response eq 'y' ? :