6 use Config qw(%Config);
14 eval { require File::Spec::Functions ; File::Spec::Functions->import() } ;
17 *catfile = sub { return "$_[0]/$_[1]" }
21 require VMS::Filespec if $^O eq 'VMS';
24 unless($ENV{PERL_CORE}) {
25 $ENV{PERL_CORE} = 1 if grep { $_ eq 'PERL_CORE=1' } @ARGV;
28 $ENV{SKIP_FOR_CORE} = 1 if $ENV{PERL_CORE} || $ENV{MY_PERL_CORE} ;
38 if $path =~ /(~|\.bak|_bak)$/ ||
39 $path =~ /\..*\.sw(o|p)$/ ||
50 my @files = getPerlFiles('MANIFEST');
52 # Note: Once you remove all the layers of shell/makefile escaping
53 # the regular expression below reads
55 # /^\s*local\s*\(\s*\$^W\s*\)/
60 @echo Checking for $$^W in files: '. "@files" . '
62 exit 1 if /^\s*local\s*\(\s*\$$\^W\s*\)/; \' \
63 ' . " @files || " . ' \
64 (echo found unexpected $$^W ; exit 1)
78 for my $manifest (@manifests)
83 if $manifest =~ m#^(.*/)#;
86 or die "Cannot open '$manifest': $!\n";
90 next if /^\s*#/ || /^\s*$/ ;
97 my ($file, $rest) = ($1, $2);
99 if ($file =~ /\.(pm|pl|t)$/ and $file !~ /MakeUtil.pm/)
101 push @files, "$prefix$file";
103 elsif ($rest =~ /perl/i)
105 push @files, "$prefix$file";
117 return if defined $ENV{TipTop};
121 # our and use bytes/utf8 is stable from 5.6.0 onward
122 # warnings is stable from 5.6.1 onward
124 # Note: this code assumes that each statement it modifies is not
125 # split across multiple lines.
135 my $caller = (caller(1))[3] || '';
137 if ($caller =~ /downgrade/)
141 elsif ($caller =~ /upgrade/)
153 # my $opt = shift @ARGV || '' ;
154 # $upgrade = ($opt =~ /^-upgrade/i);
155 # $downgrade = ($opt =~ /^-downgrade/i);
156 # push @ARGV, $opt unless $downgrade || $upgrade;
160 if ($downgrade || $do_downgrade) {
161 # From: use|no warnings "blah"
162 # To: local ($^W) = 1; # use|no warnings "blah"
164 s/^(\s*)(no\s+warnings)/${1}local (\$^W) = 0; #$2/ ;
165 s/^(\s*)(use\s+warnings)/${1}local (\$^W) = 1; #$2/ ;
168 #elsif ($] >= 5.006001 || $upgrade) {
170 # From: local ($^W) = 1; # use|no warnings "blah"
171 # To: use|no warnings "blah"
173 s/^(\s*)local\s*\(\$\^W\)\s*=\s*\d+\s*;\s*#\s*((no|use)\s+warnings.*)/$1$2/ ;
177 if ($downgrade || $do_downgrade) {
179 if ( /^(\s*)our\s+\(\s*([^)]+\s*)\)/ ) {
181 my $vars = join ' ', split /\s*,\s*/, $2;
182 $_ = "${indent}use vars qw($vars);\n";
184 elsif ( /^(\s*)((use|no)\s+(bytes|utf8)\s*;.*)$/)
190 #elsif ($] >= 5.006000 || $upgrade) {
193 if ( /^(\s*)use\s+vars\s+qw\((.*?)\)/ ) {
195 my $vars = join ', ', split ' ', $2;
196 $_ = "${indent}our ($vars);\n";
198 elsif ( /^(\s*)#\s*((use|no)\s+(bytes|utf8)\s*;.*)$/)
205 if (! $our_sub && ! $warn_sub) {
206 warn "Up/Downgrade not needed.\n";
207 if ($upgrade || $downgrade)
215 { doUpDown($our_sub, $warn_sub, $_) }
217 #{ doUpDownViaCopy($our_sub, $warn_sub, $_) }
220 warn "Up/Downgrade complete.\n" ;
221 exit 0 if $upgrade || $downgrade;
229 my $warn_sub = shift;
233 local ($^I) = ($^O eq 'VMS') ? "_bak" : ".bak";
234 local (@ARGV) = shift;
238 print, last if /^__(END|DATA)__/ ;
240 &{ $our_sub }() if $our_sub ;
241 &{ $warn_sub }() if $warn_sub ;
254 my $warn_sub = shift;
261 my $backup = $file . ($^O eq 'VMS') ? "_bak" : ".bak";
264 or die "Cannot copy $file to $backup: $!";
270 or die "Cannot open $file: $!\n" ;
273 if (/^__(END|DATA)__/)
279 &{ $our_sub }() if $our_sub ;
280 &{ $warn_sub }() if $warn_sub ;
294 or die "Cannot open $file: $!\n";
301 sub FindBrokenDependencies
303 my $version = shift ;
304 my %thisModule = map { $_ => 1} @_;
308 IO::Compress::Base::Common
314 IO::Compress::RawDeflate
315 IO::Uncompress::RawInflate
316 IO::Compress::Deflate
317 IO::Uncompress::Inflate
319 IO::Compress::Gzip::Constants
320 IO::Uncompress::Gunzip
322 IO::Uncompress::Unzip
325 IO::Uncompress::Bunzip2
328 IO::Uncompress::UnLzf
331 IO::Uncompress::UnLzop
338 foreach my $module ( grep { ! $thisModule{$_} } @modules)
340 my $hasVersion = getInstalledVersion($module);
342 # No need to upgrade if the module isn't installed at all
344 if ! defined $hasVersion;
346 # If already have C::Z version 1, then an upgrade to any of the
347 # IO::Compress modules will not break it.
349 if $module eq 'Compress::Zlib' && $hasVersion < 2;
351 if ($hasVersion < $version)
353 push @broken, $module
360 sub getInstalledVersion
365 eval " require $module; ";
370 $version = ${ $module . "::VERSION" };