INSTALL.PL

filter: Statementstmt 15.2% 13 / 85 Branchbran 2.2% 1 / 44 Conditioncond 11.1% 2 / 18 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 57.1% 4 / 7 Podpod n/a totaltotal 12.2% 20 / 164 CC 8 SCAR 30.0
CC
8
Cov
11%
repl
42.0
mysystem
6.0
insl
6.0
CRAP 20.0
« blib/lib/MYDan/Util/Gateway.pm ↑ Summary blib/lib/MYDan/Util/Contact.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 0 my @p = split /\//, $RealBin;
9 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
10 0 ▶my $mydan = @p ? join( '/', @p ) : '/opt/mydan';
Branch: 1 branch
BranchTrueFalseTotal
@p ? : 0 0 0
11  
12 0 ▶system "mkdir -p '$mydan'" unless -e $mydan;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $mydan 0 0 0
13  
14 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
15 0 my $cpan = $perl;$cpan =~ s/perl$/cpan/;
16 0 ▶$cpan = $ENV{cpan} unless -f $cpan;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $cpan 0 0 0
17 0 ▶die "no find cpan" unless -f $cpan;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $cpan 0 0 0
18  
19 sub mysystem
20 {
21 0 ▶ my $cmd = shift;
Subroutine mysystem: not called CC=2 SCAR=17.9
22 0 ▶ die "$cmd fail:$!" if system $cmd;
Branch: 1 branch
BranchTrueFalseTotal
if system $cmd 0 0 0
23 }
24  
25 sub repl
26 {
27 0 ▶ my ( $type, %reg ) = @_;
Subroutine repl: not called CC=6 SCAR=37.4
28 0 for my $file ( `find $type -type f` )
29 {
30 0 chomp $file;
31 0 tie my ( @file ), 'Tie::File', $file;
32
33 0 ▶ if( @file )
Branch: 1 branch
BranchTrueFalseTotal
if (@file) 0 0 0
34 {
35 0 ▶ if( %reg )
Branch: 1 branch
BranchTrueFalseTotal
if (%reg) { } 0 0 0
36 {
37 0 ▶ while( my ( $k, $v ) = each %reg )
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %reg) 0 0 0
38 {
39 0 map{ $_ =~ s/$k/$v/g }@file;
40 }
41 }
42 else
43 {
44 0 ▶ $file[0] = "#!$perl$1" if $file[0] =~ /#![^#]*perl(.*$)/o;
Branch: 1 branch
BranchTrueFalseTotal
if $file[0] =~ /#![^#]*perl(.*$)/o 0 0 0
45 }
46 }
47  
48 0 warn "$file\n";
49 0 untie @file;
50 }
51 }
52  
53 sub insl
54 {
55
56 0 ▶ print '#' x 30, " check module ", '#' x 30, "\n";
Subroutine insl: not called CC=2 SCAR=17.9
57
58 map{
59 0 $_ =~ s/'//g;
60 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
61 {
62 0 print "install $_\n";
63 0 mysystem( "$cpan install $_" );
64 }
65 0 else { print "$_=> ok.\n"; }
66 0 print '-' x 74, "\n";
67 }@_;
68
69 }
70  
71  
72 0 ▶if( $ENV{dan} )
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"dan"}) 0 0 0
73 {
74 0 mysystem "rsync -a dan/ dan.i/";
75 0 repl( 'dan.i' );
76 0 mysystem "rsync -a dan.i/ '$mydan/dan/'";
77  
78 0 my %m;
79 0 tie my ( @file ), 'Tie::File', 'Makefile.PL';
80 0 ▶ map{ $m{$1} = 1 if $_ =~ /\s+'?([:\w]+)'? => [\d\.]+/ }@file;
Branch: 1 branch
BranchTrueFalseTotal
if $_ =~ /\s+'?([:\w]+)'? => [\d\.]+/ 0 0 0
81 0 untie @file;
82  
83 0 insl( keys %m );
84 }
85  
86 0 ▶if( $ENV{box} )
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"box"}) 0 0 0
87 {
88  
89 0 mysystem "rsync -a box/ box.i/";
90 0 mysystem "rsync -a dan/node/ box.i/node/";
91 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 );
92
93  
94 0 my @sed = (
95 'box.i/tools/vssh' => [ 'logname', 'id -un' ],
96 'box.i/tools/vssh' => [ 'MYDan::VSSH::Execute::dan=1', 'MYDan::VSSH::Execute::dan=0' ],
97 'box.i/tools/mrsync' => [ 'MYDan::Agent::Mrsync', 'MYDan::Util::Mrsync' ],
98 );
99 0 ▶ while( my ( $f, $s ) = splice @sed, 0, 2 )
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@sed, 0, 2)) 0 0 0
100 {
101 0 tie my ( @file ), 'Tie::File', $f;
102 0 map{ s/$s->[0]/$s->[1]/g }@file;
103 0 untie @file;
104 }
105  
106 0 repl( 'box.i' );
107 0 mysystem "rsync -a box.i/ '$mydan/box/'";
108  
109 0 ▶ unless( $ENV{dan} )
Branch: 1 branch
BranchTrueFalseTotal
unless ($ENV{"dan"}) 0 0 0
110 {
111 0 my %m;
112 0 tie my ( @file ), 'Tie::File', 'Makefile.PL';
113 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
114 0 untie @file;
115  
116 0 insl( keys %m );
117 }
118 }
119  
120 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
121 {
122 0 mysystem "rsync -a bin/ bin.i/";
123 0 repl( 'bin.i' );
124 mysystem( "ln -fsn mydan bin.i/$ENV{nickname}" )
125 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
126 0 mysystem "rsync -a bin.i/ '$mydan/bin/'";
127 }
128  
129 0 ▶if( $ENV{def} )
Branch: 1 branch
BranchTrueFalseTotal
if ($ENV{"def"}) 0 0 0
130 {
131 0 mysystem( "rsync -av def/ def.i/" );
132 0 repl( 'def.i', MYDanROOT => $mydan );
133 0 mysystem( "rsync -av def.i/ ../" );
134 }
135  
136 0 exit 0;
« blib/lib/MYDan/Util/Gateway.pm ↑ Summary blib/lib/MYDan/Util/Contact.pm »