Subject: | ExtUtils::MakeMaker doesn't handle VERSION defined with version.pm |
ExtUtils::MakeMaker doesn't deal well when module versions are defined using the 'version.pm' module. Attached is a patch that handles the situation by checking if the line with the $VERSION definition contains the 'version->new' code. I have also updated the 'parse_version.t' test case to check for this.
I tested this code on perl 5.8.6. I did not do any checks to see if the version module was installed though. This may pose an issue if the version module is not installed on the target machine.
diff -ru ExtUtils-MakeMaker-6.25-orig/lib/ExtUtils/MM_Unix.pm ExtUtils-MakeMaker-6.25/lib/ExtUtils/MM_Unix.pm
--- ExtUtils-MakeMaker-6.25-orig/lib/ExtUtils/MM_Unix.pm 2004-12-15 04:01:32.000000000 -0800
+++ ExtUtils-MakeMaker-6.25/lib/ExtUtils/MM_Unix.pm 2005-02-03 18:37:16.000000000 -0800
@@ -3051,6 +3051,9 @@
$_
}; \$$2
};
+ # Check if we need to load version.pm
+ $eval =~ s/(no strict;)/$1 use version;/
+ if $_ =~ m/version->new/ or $_ =~ m/new version/;
local $^W = 0;
$result = eval($eval);
warn "Could not eval '$eval' in $parsefile: $@" if $@;
diff -ru ExtUtils-MakeMaker-6.25-orig/t/parse_version.t ExtUtils-MakeMaker-6.25/t/parse_version.t
--- ExtUtils-MakeMaker-6.25-orig/t/parse_version.t 2004-12-04 12:06:00.000000000 -0800
+++ ExtUtils-MakeMaker-6.25/t/parse_version.t 2005-02-03 18:45:01.000000000 -0800
@@ -11,7 +11,7 @@
}
chdir 't';
-use Test::More tests => 10;
+use Test::More tests => 12;
use ExtUtils::MakeMaker;
my %versions = ('$VERSION = 0.02' => 0.02,
@@ -19,6 +19,7 @@
'$VERSION = -1.0' => -1.0,
'$VERSION = undef' => 'undef',
'$wibble = 1.0' => 'undef',
+ '$VERSION = version->new( \'1.1.1\' )' => '1.1.1',
);
while( my($code, $expect) = each %versions ) {