| 1 | #!/usr/bin/perl -w
|
|---|
| 2 |
|
|---|
| 3 | #
|
|---|
| 4 | # cmpVERSION - compare two Perl source trees for modules
|
|---|
| 5 | # that have identical version numbers but different contents.
|
|---|
| 6 | #
|
|---|
| 7 | # Original by [email protected], modified by jhi.
|
|---|
| 8 | #
|
|---|
| 9 |
|
|---|
| 10 | use strict;
|
|---|
| 11 |
|
|---|
| 12 | use ExtUtils::MakeMaker;
|
|---|
| 13 | use File::Compare;
|
|---|
| 14 | use File::Find;
|
|---|
| 15 | use File::Spec::Functions qw(rel2abs abs2rel catfile catdir curdir);
|
|---|
| 16 |
|
|---|
| 17 | for (@ARGV[0, 1]) {
|
|---|
| 18 | die "$0: '$_' does not look like Perl directory\n"
|
|---|
| 19 | unless -f catfile($_, "perl.h") && -d catdir($_, "Porting");
|
|---|
| 20 | }
|
|---|
| 21 |
|
|---|
| 22 | my $dir2 = rel2abs($ARGV[1]);
|
|---|
| 23 | chdir $ARGV[0] or die "$0: chdir '$ARGV[0]' failed: $!\n";
|
|---|
| 24 |
|
|---|
| 25 | # Files to skip from the check for one reason or another,
|
|---|
| 26 | # usually because they pull in their version from some other file.
|
|---|
| 27 | my %skip;
|
|---|
| 28 | @skip{'./lib/Exporter/Heavy.pm'} = ();
|
|---|
| 29 |
|
|---|
| 30 | my @wanted;
|
|---|
| 31 | find(
|
|---|
| 32 | sub { /\.pm$/ &&
|
|---|
| 33 | ! exists $skip{$File::Find::name}
|
|---|
| 34 | &&
|
|---|
| 35 | do { my $file2 =
|
|---|
| 36 | catfile(catdir($dir2, $File::Find::dir), $_);
|
|---|
| 37 | (my $xs_file1 = $_) =~ s/\.pm$/.xs/;
|
|---|
| 38 | (my $xs_file2 = $file2) =~ s/\.pm$/.xs/;
|
|---|
| 39 | if (-e $xs_file1 && -e $xs_file2) {
|
|---|
| 40 | return if compare($_, $file2) == 0 &&
|
|---|
| 41 | compare($xs_file1, $xs_file2) == 0;
|
|---|
| 42 | } else {
|
|---|
| 43 | return if compare($_, $file2) == 0;
|
|---|
| 44 | }
|
|---|
| 45 | my $version1 = eval {MM->parse_version($_)};
|
|---|
| 46 | my $version2 = eval {MM->parse_version($file2)};
|
|---|
| 47 | push @wanted, $File::Find::name
|
|---|
| 48 | if defined $version1 &&
|
|---|
| 49 | defined $version2 &&
|
|---|
| 50 | $version1 eq $version2
|
|---|
| 51 | } }, curdir);
|
|---|
| 52 | print map { $_, "\n" } sort @wanted;
|
|---|
| 53 |
|
|---|