| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Module::Build::PM_Filter; |
|
2
|
2
|
|
|
2
|
|
121541
|
use base qw(Module::Build); |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
4786
|
|
|
3
|
2
|
|
|
2
|
|
341068
|
use strict; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
57
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
|
2
|
|
|
|
|
10
|
|
|
|
2
|
|
|
|
|
45
|
|
|
5
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
162
|
|
|
6
|
2
|
|
|
2
|
|
12
|
use utf8; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
19
|
|
|
7
|
2
|
|
|
2
|
|
1888
|
use English qw(-no_match_vars); |
|
|
2
|
|
|
|
|
10275
|
|
|
|
2
|
|
|
|
|
15
|
|
|
8
|
2
|
|
|
2
|
|
4746
|
use File::Temp; |
|
|
2
|
|
|
|
|
14667
|
|
|
|
2
|
|
|
|
|
218
|
|
|
9
|
2
|
|
|
2
|
|
14
|
use File::Path; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
118
|
|
|
10
|
2
|
|
|
2
|
|
11
|
use File::Basename qw(dirname); |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
129
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
20
|
use version; our $VERSION = qv(1.21); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
19
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub process_pm_files { |
|
15
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
16
|
0
|
|
|
|
|
|
my $ext = shift; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
### is there a pm_filter file ? ... |
|
19
|
0
|
0
|
|
|
|
|
if (not $self->_check_pm_filter_file( q(pm_filter) )) { |
|
20
|
|
|
|
|
|
|
### dispatch to super method ... |
|
21
|
0
|
|
|
|
|
|
return $self->SUPER::process_pm_files( $ext ); |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
### build the install directory |
|
25
|
0
|
|
|
|
|
|
my $target_dir = $self->blib; |
|
26
|
0
|
0
|
|
|
|
|
if (not -e $target_dir) { |
|
27
|
0
|
|
|
|
|
|
File::Path::mkpath( $target_dir ); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
### build the method name for finding files according to the extension |
|
31
|
0
|
|
|
|
|
|
my $method = "find_${ext}_files"; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
### build a hash with module names and targets. |
|
34
|
0
|
0
|
|
|
|
|
my $files = $self->can($method) ? $self->$method() : |
|
35
|
|
|
|
|
|
|
$self->_find_file_by_type($ext, 'lib'); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
### only filter and install the module if it's not updated |
|
38
|
0
|
|
|
|
|
|
while (my ($file, $dest) = each %{ $files }) { |
|
|
0
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
my $derived = File::Spec->catfile($target_dir, $dest); |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
if (not $self->up_to_date( $file, $derived )) { |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
### filter to a temporary file |
|
44
|
0
|
|
|
|
|
|
my $temp_source = File::Temp->new(); |
|
45
|
0
|
|
|
|
|
|
$self->_do_filter( $file, $temp_source ); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
### and install into the distribution directory |
|
48
|
0
|
|
|
|
|
|
$self->copy_if_modified( from => $temp_source, to => $derived ); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
return; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub process_script_files { |
|
56
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
### is there a pm_filter file ? ... |
|
59
|
0
|
0
|
|
|
|
|
if (not $self->_check_pm_filter_file( q(pm_filter) )) { |
|
60
|
|
|
|
|
|
|
### dispatch to super method ... |
|
61
|
0
|
|
|
|
|
|
return $self->SUPER::process_script_files( ); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# find script files |
|
65
|
0
|
|
|
|
|
|
my $files = $self->find_script_files; |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# do nothing if not files |
|
68
|
0
|
0
|
|
|
|
|
return if not keys %{ $files }; |
|
|
0
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# make the install directory |
|
71
|
0
|
|
|
|
|
|
my $script_dir = File::Spec->catdir($self->blib, 'script'); |
|
72
|
0
|
0
|
|
|
|
|
if (not -e $script_dir) { |
|
73
|
0
|
|
|
|
|
|
File::Path::mkpath( $script_dir ); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# filter every script and make executable |
|
77
|
0
|
|
|
|
|
|
foreach my $file (keys %{ $files }) { |
|
|
0
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Isn't it already fresh ? |
|
79
|
0
|
0
|
|
|
|
|
if (not $self->up_to_date( $file, $script_dir)) { |
|
80
|
0
|
|
|
|
|
|
my $tmp_from = File::Temp->new(); |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# use a temporary file for filter ... |
|
83
|
0
|
|
|
|
|
|
$self->_do_filter( $file, $tmp_from ); |
|
84
|
0
|
|
|
|
|
|
$self->fix_shebang_line( $tmp_from ); |
|
85
|
0
|
|
|
|
|
|
$self->make_executable( $tmp_from ); |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# ... previous to the canonical installation |
|
88
|
0
|
|
|
|
|
|
$self->copy_if_modified( from => $tmp_from, to_dir => $script_dir ); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
return; |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _do_filter { |
|
96
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
97
|
0
|
|
|
|
|
|
my $source = shift; |
|
98
|
0
|
|
|
|
|
|
my $target = shift; |
|
99
|
0
|
|
|
|
|
|
my $cmd = sprintf './pm_filter < %s > %s', $source, $target; |
|
100
|
|
|
|
|
|
|
|
|
101
|
0
|
0
|
|
|
|
|
if (not $self->do_system($cmd)) { |
|
102
|
0
|
|
|
|
|
|
croak "pm_filter failed: ${ERRNO}"; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
return; |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
### INTERNAL UTILITY ### |
|
109
|
|
|
|
|
|
|
# Usage : _check_pm_filter_file( $pm_filter_path ) |
|
110
|
|
|
|
|
|
|
# Purpose : Check if there is a valid pm_filter |
|
111
|
|
|
|
|
|
|
# Returns : 0 Not valid |
|
112
|
|
|
|
|
|
|
# : 1 Valid |
|
113
|
|
|
|
|
|
|
# Parameters : - File path |
|
114
|
|
|
|
|
|
|
# Throws : no exceptions |
|
115
|
|
|
|
|
|
|
# Commments : none |
|
116
|
|
|
|
|
|
|
# See also : n/a |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub _check_pm_filter_file { |
|
119
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
120
|
0
|
|
|
|
|
|
my $file = shift; |
|
121
|
|
|
|
|
|
|
|
|
122
|
0
|
0
|
|
|
|
|
if (-e $file) { |
|
123
|
0
|
0
|
|
|
|
|
if (not -x $file) { |
|
124
|
0
|
|
|
|
|
|
croak q(pm_filter exists but is not executable); |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
return 1; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
### CLASS METHOD ### |
|
132
|
|
|
|
|
|
|
# Usage : internal use only |
|
133
|
|
|
|
|
|
|
# Purpose : Verify that a pm_filter exists and it's executable in the |
|
134
|
|
|
|
|
|
|
# : distribution directory. |
|
135
|
|
|
|
|
|
|
# Returns : Some of the inherited method |
|
136
|
|
|
|
|
|
|
# Parameters : |
|
137
|
|
|
|
|
|
|
# Throws : no exceptions |
|
138
|
|
|
|
|
|
|
# Commments : none |
|
139
|
|
|
|
|
|
|
# See also : n/a |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
sub ACTION_distdir { |
|
142
|
0
|
|
|
0
|
1
|
|
my ($self, @params) = @_; |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
# dispatch to up |
|
145
|
0
|
|
|
|
|
|
$self->SUPER::ACTION_distdir(@params); |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# build the distribution path |
|
148
|
0
|
|
|
|
|
|
my $dir = $self->dist_dir(); |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
# verify that the next files are executables ... |
|
151
|
0
|
|
|
|
|
|
$self->_make_exec( "${dir}/pm_filter" ); |
|
152
|
0
|
|
|
|
|
|
$self->_make_exec( "${dir}/debian/rules" ); |
|
153
|
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
|
return; |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub _make_exec { |
|
158
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
159
|
0
|
|
|
|
|
|
my $file = shift; |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# if the file exists and is not executable ... |
|
162
|
0
|
0
|
0
|
|
|
|
if (-e $file and not -x $file) { |
|
163
|
0
|
|
|
|
|
|
$self->make_executable( $file ); |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
return; |
|
167
|
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
1; |
|
170
|
|
|
|
|
|
|
__END__ |