4 # cmpVERSION - compare two Perl source trees for modules
5 # that have identical version numbers but different contents.
7 # withg -d option, output the diffs too
9 # Original by slaven@rezic.de, modified by jhi.
14 use ExtUtils::MakeMaker;
17 use File::Spec::Functions qw(rel2abs abs2rel catfile catdir curdir);
22 usage: $0 [ -d ] source_dir1 source_dir2
27 getopts('d', \%opts) or usage;
31 die "$0: '$_' does not look like Perl directory\n"
32 unless -f catfile($_, "perl.h") && -d catdir($_, "Porting");
35 my $dir2 = rel2abs($ARGV[1]);
36 chdir $ARGV[0] or die "$0: chdir '$ARGV[0]' failed: $!\n";
38 # Files to skip from the check for one reason or another,
39 # usually because they pull in their version from some other file.
42 './lib/Carp/Heavy.pm',
43 './lib/Exporter/Heavy.pm',
46 my $skip_dirs = qr|^\./t/lib|;
52 $File::Find::dir !~ $skip_dirs &&
53 ! exists $skip{$File::Find::name}
56 catfile(catdir($dir2, $File::Find::dir), $_);
57 (my $xs_file1 = $_) =~ s/\.pm$/.xs/;
58 (my $xs_file2 = $file2) =~ s/\.pm$/.xs/;
59 my $eq1 = compare($_, $file2) == 0;
61 if (-e $xs_file1 && -e $xs_file2) {
62 $eq2 = compare($xs_file1, $xs_file2) == 0;
64 return if $eq1 && $eq2;
65 my $version1 = eval {MM->parse_version($_)};
66 my $version2 = eval {MM->parse_version($file2)};
70 $version1 eq $version2;
71 push @wanted, $File::Find::name;
72 push @diffs, [ "$File::Find::dir/$_", $file2 ] unless $eq1;
73 push @diffs, [ "$File::Find::dir/$xs_file1", $xs_file2 ]
80 for (sort { $a->[0] cmp $b->[0] } @diffs) {
82 system "diff -du '$_->[0]' '$_->[1]'";