#!/usr/local/bin/perl -w
###########################################################################
# Global definitions
###########################################################################
use diagnostics;
use strict;
use Devel::ptkdb;
###########################################################################
# Check required module
###########################################################################
#
# Here we check for --MODULES--
#
print "\nChecking perl modules ...\n";
unless (eval "require 5.005") {
die "Sorry, you need at least Perl 5.005\n";
}
sub vers_cmp {
if (@_ < 2) { die "not enough parameters for vers_cmp" }
if (@_ > 2) { die "too many parameters for vers_cmp" }
my ($a, $b) = @_;
my (@A) = ($a =~ /(\.|\d+|[^\.\d]+)/g);
my (@B) = ($b =~ /(\.|\d+|[^\.\d]+)/g);
my ($A,$B);
while (@A and @B) {
$A = shift @A;
$B = shift @B;
if ($A eq "." and $B eq ".") {
next;
} elsif ( $A eq "." ) {
return -1;
} elsif ( $B eq "." ) {
return 1;
} elsif ($A =~ /^\d+$/ and $B =~ /^\d+$/) {
return $A <=> $B if $A <=> $B;
} else {
$A = uc $A;
$B = uc $B;
return $A cmp $B if $A cmp $B;
}
}
@A <=> @B;
}
# This was originally clipped from the libnet Makefile.PL, adapted here to
# use the above vers_cmp routine for accurate version checking.
sub have_vers {
my ($pkg, $wanted) = @_;
my ($msg, $vnum, $vstr);
no strict 'refs';
printf("Checking for %15s %-9s ", $pkg, !$wanted?'(any)':"(v$wanted)");
eval { my $p; ($p = $pkg . ".pm") =~ s!::!/!g; require $p; };
$vnum = ${"${pkg}::VERSION"} || ${"${pkg}::Version"} || 0;
$vnum = -1 if $@;
if ($vnum eq "-1") { # string compare just in case it's non-numeric
$vstr = "not found";
}
elsif (vers_cmp($vnum,"0") > -1) {
$vstr = "found v$vnum";
}
else {
$vstr = "found unknown version";
}
my $vok = (vers_cmp($vnum,$wanted) > -1);
print ((($vok) ? "ok: " : " "), "$vstr\n");
return $vok;
}
# Check versions of dependencies. 0 for version = any version acceptible
my $modules = [
{
name => 'Getopt::Long',
version => ''
},
{
name => 'File::Find',
version => ''
},
{
name => 'File::Copy',
version => ''
},
{
name => 'FileHandle',
version => ''
},
{
name => 'mod_perl',
version => ''
}
];
my %missing = ();
foreach my $module (@{$modules}) {
unless (have_vers($module->{name}, $module->{version})) {
$missing{$module->{name}} = $module->{version};
}
}
system("perl -v");
system("cvs -v");