INSTALL.PL

filter: Statementstmt 13.9% 13 / 93 Branchbran 2.0% 1 / 50 Conditioncond 11.1% 2 / 18 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 50.0% 4 / 8 Podpod n/a totaltotal 11.1% 20 / 179 CC 15 SCAR 36.6
CC
15
Cov
10%
mydanpath
72.0
repl
42.0
mysystem
6.0
CRAP 38.9
« blib/lib/MYDan/Collector/Stat/Coredump.pm ↑ Summary blib/lib/MYDan/Util/DirConf.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use FindBin qw( $Bin $RealBin );
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Tie::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶exit 0 unless $ENV{dan} || $ENV{box} || $ENV{def};
Branch: 1 branch
BranchTrueFalseTotal
unless $ENV{"dan"} or $ENV{"box"} or $ENV{"def"} 1 0 1
Condition33%2/6
$ENV{"dan"} or $ENV{"box"} or $ENV{"def"}
l!l&&r!l&&!r
001
$ENV{"dan"} or $ENV{"box"}
l!l&&r!l&&!r
001
MC/DC0%0/3
$ENV{"dan"} or $ENV{"box"} or $ENV{"def"}
$ENV{"dan"} $ENV{"box"} $ENV{"def"}
Truth table0%0/4
A or B or C
A= $ENV{"dan"}B= $ENV{"box"}C= $ENV{"def"}
ABCresult
1XX1
01X1
0011
0000
7  
8 sub mydanpath
9 {
10 0 ▶ if ( my $path = $ENV{mydan} )
Subroutine mydanpath: not called CC=8 SCAR=42.8
Branch: 1 branch
BranchTrueFalseTotal
if (my $path = $ENV{"mydan"}) 0 0 0
11 {
12 0 my @p = split /\//, $path;
13 0 ▶ die "The directory name must be mydan. example: /tmp/abc/mydan\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $p[-1] eq "mydan" 0 0 0
14 unless $p[-1] eq 'mydan';
15 0 return $path;
16 }
17 0 for ( $RealBin, $ENV{PERL_PATH}, $^X )
18 {
19 0 ▶ next unless $_;
Branch: 1 branch
BranchTrueFalseTotal
unless $_ 0 0 0
20 0 my @p = split /\//, $_;
21 0 ▶ while ( @p ) { $p[-1] eq 'mydan' ? last : pop @p; }
Branch: 2 branches
BranchTrueFalseTotal
if (@p) 0 0 0
$p[-1] eq 'mydan' ? : 0 0 0
22 0 ▶ return join( '/', @p ) if @p;
Branch: 1 branch
BranchTrueFalseTotal
if @p 0 0 0
23 }
24 0 return '/opt/mydan';
25 }
26  
27 0 my $mydan = mydanpath();
28 0 ▶system "mkdir -p '$mydan'" unless -e $mydan;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $mydan 0 0 0
29  
30 0 ▶my $perl = $ENV{PERL_PATH} || $^X;
Condition0%0/3
$ENV{'PERL_PATH'} || $^X
l!l&&r!l&&!r
000
MC/DC0%0/2
$ENV{'PERL_PATH'} || $^X
$ENV{'PERL_PATH'} $^X
Truth table0%0/3
A || B
A= $ENV{'PERL_PATH'}B= $^X
ABresult
1X1
011
000
31 0 my $cpan = $perl;$cpan =~ s/perl$/cpan/;
32 0 ▶$cpan = $ENV{cpan} unless -f $cpan;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $cpan 0 0 0
33 0 ▶die "no find cpan" unless -f $cpan;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $cpan 0 0 0
34  
35 sub mysystem
36 {
37 0 ▶ my $cmd = shift;
Subroutine mysystem: not called CC=2 SCAR=17.9
38 0 ▶ die "$cmd fail:$!" if system $cmd;
Branch: 1 branch
BranchTrueFalseTotal
if system $cmd 0 0 0
39 }
40  
41 sub repl
42 {
43 0 ▶ my ( $type, %reg ) = @_;
Subroutine repl: not called CC=6 SCAR=37.4
44 0 for my $file ( `find $type -type f` )
45 {
46 0 chomp $file;
47 0 tie my ( @file ), 'Tie::File', $file;
48
49 0 ▶ if( @file )
Branch: 1 branch
BranchTrueFalseTotal
if (@file) 0 0 0
50 {
51 0 ▶ if( %reg )
Branch: 1 branch
BranchTrueFalseTotal
if (%reg) { } 0 0 0
52 {
53 0 ▶ while( my ( $k, $v ) = each %reg )
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %reg) 0 0 0
54 {
55 0 map{ $_ =~ s/$k/$v/g }@file;
56 }
57 }
58 else
59 {
60 0 ▶ $file[0] = "#!$perl$1" if $file[0] =~ /#![^#]*perl(.*$)/o;
Branch: 1 branch
BranchTrueFalseTotal
if $file[0] =~ /#![^#]*perl(.*$)/o 0 0 0
61 }
62 }
63  
64 0 warn "$file\n";
65 0 untie @file;
66 }
67 }
68  
69 sub insl
70 {
71
72 0 ▶ print '#' x 30, " check module ", '#' x 30, "\n";
Subroutine insl: not called CC=2 SCAR=17.9
73
74 map{
75 0 $_ =~ s/'//g;
76 0 ▶ if( system "$perl -e \"use $_\" >/dev/null 2>&1" )
Branch: 1 branch
BranchTrueFalseTotal
if (system qq[$perl -e "use $_" >/dev/null 2>&1]) { } 0 0 0
77 {
78 0 print "install $_\n";
79 0 mysystem( "$cpan install $_" );
80 }
81 0 else { print "$_=> ok.\n"; }
82 0 print '-' x 74, "\n";
83 }@_;
84
85 }
86  
87  
88 0 ▶if( $ENV{dan} )
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"dan"}) 0 0 0
89 {
90 0 mysystem "rsync -a dan/ dan.i/";
91 0 repl( 'dan.i' );
92 0 mysystem "rsync -a dan.i/ '$mydan/dan/'";
93  
94 0 my %m;
95 0 tie my ( @file ), 'Tie::File', 'Makefile.PL';
96 0 ▶ map{ $m{$1} = 1 if $_ =~ /\s+'?([:\w]+)'? => [\d\.]+,\s*#/ }@file;
Branch: 1 branch
BranchTrueFalseTotal
if $_ =~ /\s+'?([:\w]+)'? => [\d\.]+,\s*#/ 0 0 0
97 0 untie @file;
98  
99 0 insl( keys %m );
100 }
101  
102 0 ▶if( $ENV{box} )
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"box"}) 0 0 0
103 {
104  
105 0 mysystem "rsync -a box/ box.i/";
106 0 mysystem "rsync -a dan/node/ box.i/node/";
107 0 map { mysystem "rsync -a dan/tools/$_ box.i/tools/" } qw(range mcmd mssh expect vssh go mrsync rsync alias unalias sync config whois gateway git );
108
109  
110 0 my @sed = (
111 'box.i/tools/vssh' => [ 'logname', 'id -un' ],
112 'box.i/tools/vssh' => [ 'MYDan::VSSH::Execute::dan=1', 'MYDan::VSSH::Execute::dan=0' ],
113 'box.i/tools/mrsync' => [ 'MYDan::Agent::Mrsync', 'MYDan::Util::Mrsync' ],
114 );
115 0 ▶ while( my ( $f, $s ) = splice @sed, 0, 2 )
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@sed, 0, 2)) 0 0 0
116 {
117 0 tie my ( @file ), 'Tie::File', $f;
118 0 map{ s/$s->[0]/$s->[1]/g }@file;
119 0 untie @file;
120 }
121  
122 0 repl( 'box.i' );
123 0 mysystem "rsync -a box.i/ '$mydan/box/'";
124  
125 0 ▶ unless( $ENV{dan} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($ENV{"dan"}) 0 0 0
126 {
127 0 my %m;
128 0 tie my ( @file ), 'Tie::File', 'Makefile.PL';
129 0 ▶ map{ $m{$1} = 1 if $_ =~ /\s+'?([:\w]+)'? => [\d\.]+,\s*#box/ }@file;
Branch: 1 branch
BranchTrueFalseTotal
if $_ =~ /\s+'?([:\w]+)'? => [\d\.]+,\s*#box/ 0 0 0
130 0 untie @file;
131  
132 0 insl( keys %m );
133 }
134 }
135  
136 0 ▶if( $ENV{dan} || $ENV{box} || $ENV{bin} )
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"dan"} or $ENV{"box"} or $ENV{"bin"}) 0 0 0
Condition0%0/6
$ENV{"dan"} or $ENV{"box"} or $ENV{"bin"}
l!l&&r!l&&!r
000
$ENV{"dan"} or $ENV{"box"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$ENV{"dan"} or $ENV{"box"} or $ENV{"bin"}
$ENV{"dan"} $ENV{"box"} $ENV{"bin"}
Truth table0%0/4
A or B or C
A= $ENV{"dan"}B= $ENV{"box"}C= $ENV{"bin"}
ABCresult
1XX1
01X1
0011
0000
137 {
138 0 mysystem "rsync -a bin/ bin.i/";
139 0 repl( 'bin.i' );
140 mysystem( "ln -fsn mydan bin.i/$ENV{nickname}" )
141 0 ▶ if $ENV{nickname} && $ENV{nickname} =~ /^[a-z0-9]+$/;
Branch: 1 branch
BranchTrueFalseTotal
if $ENV{"nickname"} and $ENV{"nickname"} =~ /^[a-z0-9]+$/ 0 0 0
Condition0%0/3
$ENV{"nickname"} and $ENV{"nickname"} =~ /^[a-z0-9]+$/
!ll&&!rl&&r
000
MC/DC0%0/2
$ENV{"nickname"} and $ENV{"nickname"} =~ /^[a-z0-9]+$/
$ENV{"nickname"} $ENV{"nickname"} =~ /^[a-z0-9]+$/
Truth table0%0/3
A and B
A= $ENV{"nickname"}B= $ENV{"nickname"} =~ /^[a-z0-9]+$/
ABresult
0X0
100
111
142 0 mysystem "rsync -a bin.i/ '$mydan/bin/'";
143 }
144  
145 0 ▶if( $ENV{def} )
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"def"}) 0 0 0
146 {
147 0 mysystem( "rsync -av def/ def.i/" );
148 0 repl( 'def.i', MYDanROOT => $mydan );
149 0 mysystem( "rsync -av def.i/ ../" );
150 }
151  
152 0 exit 0;
« blib/lib/MYDan/Collector/Stat/Coredump.pm ↑ Summary blib/lib/MYDan/Util/DirConf.pm »