line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::EUMM::Upgrade; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
12888
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
56
|
|
4
|
2
|
|
|
2
|
|
7
|
use warnings; |
|
2
|
|
|
|
|
1
|
|
|
2
|
|
|
|
|
93
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
App::EUMM::Upgrade - Perl tool to upgrade ExtUtils::MakeMaker-based Makefile.PL |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Version 0.24 |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.24'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
eumm-upgrade is a tool to allow using new features of ExtUtils::MakeMaker without losing |
22
|
|
|
|
|
|
|
compatibility with older versions. It adds compatibility code to Makefile.PL and |
23
|
|
|
|
|
|
|
tries to automatically detect some properties like license, minimum Perl version required and |
24
|
|
|
|
|
|
|
repository used. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
Just run eumm-upgrade.pl in directory with Makefile.PL. Old file will be copied to Makefile.PL.bak. |
27
|
|
|
|
|
|
|
If you use Github, Internet connection is required. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
You need to check resulting Makefile.PL manually as transformation is done |
30
|
|
|
|
|
|
|
with regular expressions. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
If you need to declare number of spaces in indent in Makefile.PL, use following string at start of |
33
|
|
|
|
|
|
|
it (set 'c-basic-offset' to your value): |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# -*- mode: perl; c-basic-offset: 4; indent-tabs-mode: nil; -*- |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 new EUMM features |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
LICENSE - shows license on search.cpan.org |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
META_MERGE - add something (like repository URL or bugtracker UTL) to META.yml. Repository and |
42
|
|
|
|
|
|
|
bugtracker URL are used on search.cpan.org. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
MIN_PERL_VERSION - minimum version of Perl required for module work. Not used currently, but will |
45
|
|
|
|
|
|
|
be in the future. |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
CONFIGURE_REQUIRES - modules that are used in Makefile.PL and should be installed before running it. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
BUILD_REQUIRES - modules that are used in installation and testing, but are not required by module |
50
|
|
|
|
|
|
|
itself. Useful for ppm/OS package generaton and metadata parsing tools. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 AUTHOR |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Alexandr Ciornii, C<< >> |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 BUGS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
59
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
60
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SUPPORT |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
perldoc App::EUMM::Upgrade |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
You can also look for information at: |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=over 4 |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
L |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
L |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item * CPAN Ratings |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
L |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item * Search CPAN |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
L |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Copyright 2009-2015 Alexandr Ciornii. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
GPL v3 |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
2
|
|
|
2
|
|
31
|
use Exporter 'import'; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
386
|
|
104
|
|
|
|
|
|
|
our @EXPORT=qw/remove_conditional_code/; |
105
|
|
|
|
|
|
|
sub _indent_space_number { |
106
|
22
|
|
|
22
|
|
17
|
my $str=shift; |
107
|
22
|
100
|
|
|
|
63
|
$str=~/^(\s+)/ or return 0; |
108
|
17
|
|
|
|
|
21
|
my $ind=$1; |
109
|
17
|
|
|
|
|
28
|
$ind=~s/\t/ /gs; |
110
|
17
|
|
|
|
|
34
|
return length($ind); |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
0
|
|
0
|
sub _unindent_t { |
114
|
|
|
|
|
|
|
# my $replace |
115
|
|
|
|
|
|
|
# die unless |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
sub _unindent { |
118
|
6
|
|
|
6
|
|
17
|
my $space_string_to_set=shift; |
119
|
6
|
|
|
|
|
6
|
my $text=shift; |
120
|
6
|
|
|
|
|
1431
|
print "#'$space_string_to_set','$text'\n"; |
121
|
6
|
|
|
|
|
54
|
my @lines=split /(?<=[\x0A\x0D])/s,$text; |
122
|
2
|
|
|
2
|
|
37
|
use List::Util qw/min/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1266
|
|
123
|
6
|
|
|
|
|
10
|
my $minspace=min(map {_indent_space_number($_)} @lines); |
|
16
|
|
|
|
|
24
|
|
124
|
6
|
|
|
|
|
8
|
my $s1=_indent_space_number($space_string_to_set); |
125
|
|
|
|
|
|
|
#die "$s1 > $minspace" if $s1 > $minspace; |
126
|
6
|
50
|
|
|
|
13
|
return $text if $s1==$minspace; |
127
|
|
|
|
|
|
|
#if (grep { $_ !~ /^$space_string_to_set/ } @lines) { |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
#} |
130
|
|
|
|
|
|
|
#my $space_str |
131
|
6
|
|
|
|
|
4
|
my $line; |
132
|
6
|
|
|
|
|
4
|
my $i=0; |
133
|
6
|
|
|
|
|
9
|
foreach my $l (@lines) { |
134
|
16
|
50
|
|
|
|
21
|
next unless $l; |
135
|
16
|
100
|
|
|
|
22
|
if ($i==0) { |
136
|
6
|
|
|
|
|
9
|
$l =~ s/^\s+//; |
137
|
6
|
|
|
|
|
6
|
$i++; |
138
|
6
|
|
|
|
|
9
|
next; |
139
|
|
|
|
|
|
|
} |
140
|
10
|
50
|
|
|
|
43
|
unless ($l=~s/^$space_string_to_set//) { |
141
|
0
|
|
|
|
|
0
|
die "Text (line '$l') does not start with removal line ($space_string_to_set)"; |
142
|
|
|
|
|
|
|
} |
143
|
10
|
50
|
|
|
|
13
|
next unless $l; |
144
|
10
|
50
|
|
|
|
20
|
if ($l=~m/^(\s+)/) { |
145
|
10
|
|
|
|
|
11
|
my $space=$1; |
146
|
10
|
100
|
|
|
|
10
|
if (!defined $line) { |
147
|
2
|
|
|
|
|
3
|
$line=$space; |
148
|
2
|
|
|
|
|
4
|
next; |
149
|
|
|
|
|
|
|
} else { |
150
|
8
|
50
|
|
|
|
23
|
if ($space=~/^$line/) { |
|
|
0
|
|
|
|
|
|
151
|
8
|
|
|
|
|
13
|
next; |
152
|
|
|
|
|
|
|
} elsif ($line=~/^$space/) { |
153
|
0
|
|
|
|
|
0
|
$line=$space; |
154
|
0
|
0
|
|
|
|
0
|
if ($line eq '') { |
155
|
|
|
|
|
|
|
#warn("line set to '' on line '$l'"); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
} else { |
158
|
0
|
|
|
|
|
0
|
die "Cannot find common start, on line '$l'"; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
} else { |
162
|
0
|
|
|
|
|
0
|
return $text; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
} |
165
|
6
|
50
|
66
|
|
|
22
|
if (!$line and $i>1) { |
166
|
0
|
|
|
|
|
0
|
die "Cannot find common start"; |
167
|
|
|
|
|
|
|
} |
168
|
6
|
|
|
|
|
6
|
$i=0; |
169
|
6
|
|
|
|
|
5
|
foreach my $l (@lines) { |
170
|
16
|
50
|
|
|
|
18
|
next unless $l; |
171
|
16
|
100
|
|
|
|
21
|
if ($i==0) { |
172
|
6
|
|
|
|
|
9
|
$l="$space_string_to_set$l"; |
173
|
6
|
|
|
|
|
3
|
$i++; |
174
|
6
|
|
|
|
|
7
|
next; |
175
|
|
|
|
|
|
|
} |
176
|
10
|
50
|
|
|
|
62
|
unless ($l=~s/^$line//) { |
177
|
0
|
|
|
|
|
0
|
die "Text (line '$l') does not start with calculated removal line ($space_string_to_set)"; |
178
|
|
|
|
|
|
|
} |
179
|
10
|
|
|
|
|
15
|
$l="$space_string_to_set$l"; |
180
|
|
|
|
|
|
|
} |
181
|
6
|
|
|
|
|
28
|
return (join("",@lines).""); |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
#foreach |
184
|
|
|
|
|
|
|
#$text=~s/^(\s+)(\S)/_unindent_t(qq{$1},qq{$space_string_to_set}).qq{$2}/egm; |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
#my $style=shift; |
187
|
|
|
|
|
|
|
} |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
sub remove_conditional_code { |
190
|
8
|
|
|
8
|
0
|
3402
|
my $content=shift; |
191
|
8
|
|
|
|
|
12
|
my $space=shift; |
192
|
8
|
|
|
|
|
14
|
$content=~s/(WriteMakefile\()(\S)/$1\n$space$2/; |
193
|
|
|
|
|
|
|
|
194
|
8
|
|
|
|
|
15
|
$content=~s/ |
195
|
|
|
|
|
|
|
\(\s*\$\]\s*>=\s*5\.005\s*\?\s*(?:\#\#\s*\QAdd these new keywords supported since 5.005\E\s*)? |
196
|
|
|
|
|
|
|
\s+\(\s*ABSTRACT(?:_FROM)?\s*=>\s*'([^'\n]+)',\s*(?:\#\s*\Qretrieve abstract from module\E\s*)? |
197
|
|
|
|
|
|
|
\s+AUTHOR\s*=>\s*'([^'\n]+)' |
198
|
|
|
|
|
|
|
\s*\)\s*\Q: ()\E\s*\),\s+ |
199
|
|
|
|
|
|
|
/ABSTRACT_FROM => '$1',\n${space}AUTHOR => '$2',\n/sx; |
200
|
|
|
|
|
|
|
|
201
|
8
|
|
|
|
|
27
|
my $eumm_version_check=qr/\$ ExtUtils::MakeMaker::VERSION\s+ |
202
|
|
|
|
|
|
|
(?:g[et]\s+' [\d\._]+ ' \s* | >=?\s*[\d\._]+\s+) | |
203
|
|
|
|
|
|
|
eval\s*{\s*ExtUtils::MakeMaker->VERSION\([\d\._]+\)\s*}\s* |
204
|
|
|
|
|
|
|
/xs; |
205
|
8
|
|
|
|
|
172
|
$content=~s/ |
206
|
5
|
|
|
|
|
9
|
^(\s*)\(\s* $eumm_version_check |
207
|
|
|
|
|
|
|
\?\s+\(\s* #[\n\r] |
208
|
|
|
|
|
|
|
( [ \t]*[^()]+? ) #main text, should not contain () |
209
|
|
|
|
|
|
|
\s* |
210
|
|
|
|
|
|
|
\)\s*\:\s*\(\)\s*\), |
211
|
|
|
|
|
|
|
/_unindent($1,$2)/msxge; |
212
|
|
|
|
|
|
|
|
213
|
8
|
|
|
|
|
45
|
$content=~s/ |
214
|
|
|
|
|
|
|
\(\s*\$\]\s* \Q>=\E \s* 5[\d\._]+ \s* \?\s*\( \s* |
215
|
|
|
|
|
|
|
( [^()]+? ) ,? \s* |
216
|
|
|
|
|
|
|
\)\s*\:\s*\(\)\s*\), |
217
|
|
|
|
|
|
|
/$1,/sxg; |
218
|
|
|
|
|
|
|
# ($] >= 5.005 ? |
219
|
|
|
|
|
|
|
# (AUTHOR => 'Stephen Hardisty ') : ()), |
220
|
8
|
|
|
|
|
44
|
return $content; |
221
|
|
|
|
|
|
|
} |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
1; # End of App::EUMM::Upgrade |