| 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
Condition33%2/6
$ENV{"dan"} or $ENV{"box"} or $ENV{"def"}
$ENV{"dan"} or $ENV{"box"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | sub mydanpath | ||||||||||||||||||||||||||||||||||||||||||
| 9 | { | ||||||||||||||||||||||||||||||||||||||||||
| 10 | 0 | ▶ | if ( my $path = $ENV{mydan} ) | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mydanpath: not called CC=8 SCAR=42.8
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | { | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 0 | my @p = split /\//, $path; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 0 | ▶ | die "The directory name must be mydan. example: /tmp/abc/mydan\n" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | 0 | my @p = split /\//, $_; | |||||||||||||||||||||||||||||||||||||||||
| 21 | 0 | ▶ | while ( @p ) { $p[-1] eq 'mydan' ? last : pop @p; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | return join( '/', @p ) if @p; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | my $perl = $ENV{PERL_PATH} || $^X; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$ENV{'PERL_PATH'} || $^X
MC/DC0%0/2
$ENV{'PERL_PATH'} || $^X
$ENV{'PERL_PATH'}
$^X
Truth table0%0/3
A || B
A= $ENV{'PERL_PATH'}B= $^X
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | my $cpan = $perl;$cpan =~ s/perl$/cpan/; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | $cpan = $ENV{cpan} unless -f $cpan; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | die "no find cpan" unless -f $cpan; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | { | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | if( %reg ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | while( my ( $k, $v ) = each %reg ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | untie @file; | |||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | insl( keys %m ); | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | if( $ENV{box} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/6
$ENV{"dan"} or $ENV{"box"} or $ENV{"bin"}
$ENV{"dan"} or $ENV{"box"}
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"}
| |||||||||||||||||||||||||||||||||||||||||||
| 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
Condition0%0/3
$ENV{"nickname"} and $ENV{"nickname"} =~ /^[a-z0-9]+$/
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]+$/
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | mysystem "rsync -a bin.i/ '$mydan/bin/'"; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | if( $ENV{def} ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 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; | |||||||||||||||||||||||||||||||||||||||||