[Bps-public-commit] Module-Install-RTx branch, better-versions, created. 0.28-2-g4621ce9
Kevin Falcone
falcone at bestpractical.com
Tue Mar 22 14:17:54 EDT 2011
The branch, better-versions has been created
at 4621ce9a12fb84ec2922ebebc1818cf1b635dd2b (commit)
- Log -----------------------------------------------------------------
commit 50f86869e207320acf1e0f594166af343a2db4b7
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Tue Mar 22 12:57:58 2011 -0400
fix a trailing whitespace
diff --git a/lib/Module/Install/RTx.pm b/lib/Module/Install/RTx.pm
index 3fd0c8c..5b3da64 100644
--- a/lib/Module/Install/RTx.pm
+++ b/lib/Module/Install/RTx.pm
@@ -43,7 +43,7 @@ sub RTx {
local @INC = (
$ENV{RTHOME} ? ( $ENV{RTHOME}, "$ENV{RTHOME}/lib" ) : (),
@INC,
- map { ( "$_/rt4/lib", "$_/lib/rt4", "$_/rt3/lib", "$_/lib/rt3", "$_/lib" )
+ map { ( "$_/rt4/lib", "$_/lib/rt4", "$_/rt3/lib", "$_/lib/rt3", "$_/lib" )
} grep $_, @prefixes
);
until ( eval { require RT; $RT::LocalPath } ) {
commit 4621ce9a12fb84ec2922ebebc1818cf1b635dd2b
Author: Kevin Falcone <falcone at bestpractical.com>
Date: Tue Mar 22 14:17:27 2011 -0400
Steal cmp_version from RT::Handle for better version comparisions
We don't mesh well with perl version numbers, so we'll just go it alone
diff --git a/lib/Module/Install/RTx.pm b/lib/Module/Install/RTx.pm
index 5b3da64..2053298 100644
--- a/lib/Module/Install/RTx.pm
+++ b/lib/Module/Install/RTx.pm
@@ -185,6 +185,44 @@ sub RTxInit {
die "Cannot load RT" unless $RT::Handle and $RT::DatabaseType;
}
+# stolen from RT::Handle so we work on 3.6 (cmp_versions came in with 3.8)
+{ my %word = (
+ a => -4,
+ alpha => -4,
+ b => -3,
+ beta => -3,
+ pre => -2,
+ rc => -1,
+ head => 9999,
+);
+sub cmp_version($$) {
+ my ($a, $b) = (@_);
+ my @a = grep defined, map { /^[0-9]+$/? $_ : /^[a-zA-Z]+$/? $word{$_}|| -10 : undef }
+ split /([^0-9]+)/, $a;
+ my @b = grep defined, map { /^[0-9]+$/? $_ : /^[a-zA-Z]+$/? $word{$_}|| -10 : undef }
+ split /([^0-9]+)/, $b;
+ @a > @b
+ ? push @b, (0) x (@a- at b)
+ : push @a, (0) x (@b- at a);
+ for ( my $i = 0; $i < @a; $i++ ) {
+ return $a[$i] <=> $b[$i] if $a[$i] <=> $b[$i];
+ }
+ return 0;
+}}
+sub requires_rt {
+ my ($self,$version) = @_;
+
+ # if we're exactly the same version as what we want, silently return
+ return if ($version eq $RT::VERSION);
+
+ my @sorted = sort cmp_version $version,$RT::VERSION;
+
+ if ($sorted[-1] eq $version) {
+ # should we die?
+ warn "\nWarning: prerequisite RT $version not found. Your installed version of RT ($RT::VERSION) is too old.\n\n";
+ }
+}
+
1;
__END__
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list