line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sys::Path; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
88928
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
27
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.15'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
4
|
use File::Spec; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
9
|
1
|
|
|
1
|
|
4
|
use Text::Diff 'diff'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
10
|
1
|
|
|
1
|
|
259
|
use JSON::Util; |
|
1
|
|
|
|
|
21160
|
|
|
1
|
|
|
|
|
47
|
|
11
|
1
|
|
|
1
|
|
9
|
use Digest::MD5 qw(md5_hex); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
49
|
|
12
|
1
|
|
|
1
|
|
5
|
use List::MoreUtils 'any', 'none'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
6
|
|
13
|
1
|
|
|
1
|
|
625
|
use Carp 'croak', 'confess'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
14
|
1
|
|
|
1
|
|
5
|
use Cwd 'cwd'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
11
|
use base 'Sys::Path::SPc'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
274
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub find_distribution_root { |
19
|
4
|
|
|
4
|
1
|
1964
|
my $self = shift; |
20
|
4
|
|
|
|
|
6
|
my $module_name = shift; |
21
|
|
|
|
|
|
|
|
22
|
4
|
50
|
|
|
|
8
|
croak 'pass module_name as argument' |
23
|
|
|
|
|
|
|
if not $module_name; |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
8
|
my $module_filename = $module_name.'.pm'; |
26
|
4
|
|
|
|
|
16
|
$module_filename =~ s{::}{/}g; |
27
|
|
|
|
|
|
|
eval 'use '.$module_name |
28
|
1
|
100
|
|
1
|
|
189
|
unless $INC{$module_filename}; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
4
|
|
|
|
|
66
|
|
29
|
|
|
|
|
|
|
|
30
|
4
|
|
|
|
|
7
|
my @path; |
31
|
4
|
100
|
|
|
|
9
|
if ($INC{$module_filename}) { |
32
|
3
|
|
|
|
|
35
|
$module_filename = File::Spec->rel2abs($INC{$module_filename}); |
33
|
|
|
|
|
|
|
|
34
|
3
|
|
|
|
|
15
|
@path = File::Spec->splitdir($module_filename); |
35
|
3
|
|
|
|
|
10
|
my @package_names = split('::',$module_name); |
36
|
3
|
|
|
|
|
11
|
@path = splice(@path,0,-1-@package_names); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
1
|
|
|
|
|
2516
|
@path = File::Spec->splitdir(cwd); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
4
|
|
100
|
|
|
136
|
while ( |
|
|
|
66
|
|
|
|
|
43
|
|
|
|
|
|
|
(not -f File::Spec->catdir(@path, 'MANIFEST')) |
44
|
|
|
|
|
|
|
and (not -f File::Spec->catdir(@path, 'Build.PL')) |
45
|
|
|
|
|
|
|
and (not -f File::Spec->catdir(@path, 'Makefile.PL')) |
46
|
|
|
|
|
|
|
) { |
47
|
0
|
|
|
|
|
0
|
pop @path; |
48
|
0
|
0
|
|
|
|
0
|
confess 'failed to find distribution root' |
49
|
|
|
|
|
|
|
if not @path; |
50
|
|
|
|
|
|
|
} |
51
|
4
|
|
|
|
|
2090
|
return File::Spec->catdir(@path); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub prompt_cfg_file_changed { |
55
|
2
|
|
|
2
|
1
|
3065
|
my $self = shift; |
56
|
2
|
|
|
|
|
4
|
my $src_file = shift; |
57
|
2
|
|
|
|
|
5
|
my $dst_file = shift; |
58
|
2
|
|
|
|
|
3
|
my $prompt_function = shift; |
59
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
3
|
my $answer = ''; |
61
|
2
|
|
|
12
|
|
21
|
while (none { $answer eq $_ } qw(Y I N O) ) { |
|
12
|
|
|
|
|
19
|
|
62
|
2
|
|
|
|
|
51
|
print qq{ |
63
|
|
|
|
|
|
|
Installing new version of config file $dst_file ... |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Configuration file `$dst_file' |
66
|
|
|
|
|
|
|
==> Modified (by you or by a script) since installation. |
67
|
|
|
|
|
|
|
==> Package distributor has shipped an updated version. |
68
|
|
|
|
|
|
|
What would you like to do about it ? Your options are: |
69
|
|
|
|
|
|
|
Y or I : install the package maintainer's version |
70
|
|
|
|
|
|
|
N or O : keep your currently-installed version |
71
|
|
|
|
|
|
|
D : show the differences between the versions |
72
|
|
|
|
|
|
|
Z : background this process to examine the situation |
73
|
|
|
|
|
|
|
The default action is to keep your current version. |
74
|
|
|
|
|
|
|
}; |
75
|
|
|
|
|
|
|
|
76
|
2
|
|
|
|
|
11
|
$answer = uc $prompt_function->('*** '.$dst_file.' (Y/I/N/O/D/Z) ?', 'N'); |
77
|
2
|
50
|
|
|
|
20
|
if ($answer eq 'D') { |
|
|
50
|
|
|
|
|
|
78
|
0
|
|
|
|
|
0
|
print "\n\n"; |
79
|
0
|
|
|
|
|
0
|
print diff($src_file, $dst_file, { STYLE => 'Unified' }); |
80
|
0
|
|
|
|
|
0
|
print "\n"; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
elsif ($answer eq 'Z') { |
83
|
0
|
|
|
|
|
0
|
print "Type `exit' when you're done.\n"; |
84
|
0
|
|
|
|
|
0
|
system('bash'); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
2
|
100
|
|
3
|
|
15
|
return 1 if any { $answer eq $_ } qw(Y I); |
|
3
|
|
|
|
|
10
|
|
89
|
1
|
|
|
|
|
5
|
return 0; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub changed_since_install { |
93
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
94
|
0
|
|
|
|
|
0
|
my $dest_file = shift; |
95
|
0
|
|
0
|
|
|
0
|
my $file = shift || $dest_file; |
96
|
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
0
|
my %files_checksums = $self->install_checksums; |
98
|
0
|
|
|
|
|
0
|
my $checksum = md5_hex(IO::Any->slurp([$file])); |
99
|
0
|
|
0
|
|
|
0
|
$files_checksums{$dest_file} ||= ''; |
100
|
0
|
|
|
|
|
0
|
return $files_checksums{$dest_file} ne $checksum; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub install_checksums { |
104
|
3
|
|
|
3
|
1
|
329
|
my $self = shift; |
105
|
3
|
|
|
|
|
7
|
my @args = @_; |
106
|
3
|
|
|
|
|
9
|
my $checksums_filename = File::Spec->catfile( |
107
|
|
|
|
|
|
|
Sys::Path::SPc->sharedstatedir, |
108
|
|
|
|
|
|
|
'syspath', |
109
|
|
|
|
|
|
|
'install-checksums.json' |
110
|
|
|
|
|
|
|
); |
111
|
|
|
|
|
|
|
|
112
|
3
|
100
|
|
|
|
10
|
if (@args) { |
113
|
1
|
|
|
|
|
25
|
print 'Updating ', $checksums_filename, "\n"; |
114
|
1
|
|
|
|
|
7
|
my %conffiles_md5 = ( |
115
|
|
|
|
|
|
|
$self->install_checksums, |
116
|
|
|
|
|
|
|
@args, |
117
|
|
|
|
|
|
|
); |
118
|
1
|
|
|
|
|
193
|
JSON::Util->encode(\%conffiles_md5, [ $checksums_filename ]); |
119
|
1
|
|
|
|
|
1163
|
return %conffiles_md5; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
# create empty json file if non available |
123
|
2
|
100
|
|
|
|
38
|
JSON::Util->encode({}, [ $checksums_filename ]) |
124
|
|
|
|
|
|
|
if not -f $checksums_filename; |
125
|
|
|
|
|
|
|
|
126
|
2
|
|
|
|
|
452
|
return %{JSON::Util->decode([ $checksums_filename ])}; |
|
2
|
|
|
|
|
11
|
|
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
1; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
__END__ |