Author: stas
Date: Sat Dec  4 07:39:58 2004
New Revision: 109804

URL: http://svn.apache.org/viewcvs?view=rev&rev=109804
Log:
require Cwd 2.06 or higher (to solve File::Spec::rel2abs problems
under -T). Enforce the modules version requirements for those who
aren't running under CPAN/CPANPLUS shell)

Modified:
   httpd/test/trunk/perl-framework/Apache-Test/Changes
   httpd/test/trunk/perl-framework/Apache-Test/Makefile.PL

Modified: httpd/test/trunk/perl-framework/Apache-Test/Changes
Url: 
http://svn.apache.org/viewcvs/httpd/test/trunk/perl-framework/Apache-Test/Changes?view=diff&rev=109804&p1=httpd/test/trunk/perl-framework/Apache-Test/Changes&r1=109803&p2=httpd/test/trunk/perl-framework/Apache-Test/Changes&r2=109804
==============================================================================
--- httpd/test/trunk/perl-framework/Apache-Test/Changes (original)
+++ httpd/test/trunk/perl-framework/Apache-Test/Changes Sat Dec  4 07:39:58 2004
@@ -8,6 +8,10 @@
 
 =item 1.17-dev
 
+require Cwd 2.06 or higher (to solve File::Spec::rel2abs problems
+under -T). Enforce the modules version requirements for those who
+aren't running under CPAN/CPANPLUS shell) [Stas]
+
 Apache::TestTrace: don't export by default the 'todo' utility's symbol
 since it collides with Test::More [Stas]
 

Modified: httpd/test/trunk/perl-framework/Apache-Test/Makefile.PL
Url: 
http://svn.apache.org/viewcvs/httpd/test/trunk/perl-framework/Apache-Test/Makefile.PL?view=diff&rev=109804&p1=httpd/test/trunk/perl-framework/Apache-Test/Makefile.PL&r1=109803&p2=httpd/test/trunk/perl-framework/Apache-Test/Makefile.PL&r2=109804
==============================================================================
--- httpd/test/trunk/perl-framework/Apache-Test/Makefile.PL     (original)
+++ httpd/test/trunk/perl-framework/Apache-Test/Makefile.PL     Sat Dec  4 
07:39:58 2004
@@ -54,10 +54,15 @@
        Makefile.old
       );
 
+my %prereq = (
+    'File::Spec' => '0.8',
+    'Cwd'        => '2.06',
+);
+
 WriteMakefile(
     NAME      => 'Apache::Test',
     VERSION   => $VERSION,
-    PREREQ_PM => { 'File::Spec' => '0.8' },
+    PREREQ_PM => \%prereq,
     dist      => {
         COMPRESS => 'gzip -9f', SUFFIX=>'gz',
     },
@@ -65,6 +70,45 @@
         FILES => "@clean_files",
     },
 );
+
+# after CPAN/CPANPLUS had a chance to satisfy the requirements,
+# enforce those (for those who run things manually)
+check_prereqs();
+
+sub check_prereqs {
+    my %fail = ();
+    for (keys %prereq) {
+        unless (chk_version($_, $prereq{$_})) {
+            $fail{$_} = $prereq{$_};
+        }
+    }
+    if (%fail) {
+        error "\nThe following Apache-Test dependencies aren't satisfied:",
+            map { "\t$_: $fail{$_}" } keys %fail;
+        error "Install those from http://search.cpan.org and try again";
+        exit 0;
+    }
+}
+
+sub chk_version {
+    my($pkg, $wanted) = @_;
+
+    no strict 'refs';
+    local $| = 1;
+
+    print "Checking for $pkg...";
+    (my $p = $pkg . ".pm") =~ s#::#/#g;
+    eval { require $p;};
+    print("not ok\n$@"), return if $@;
+
+    my $vstr = ${"${pkg}::VERSION"} ? "found v" . ${"${pkg}::VERSION"}
+        : "not found";
+    my $vnum = ${"${pkg}::VERSION"} || 0;
+
+    print $vnum >= $wanted ? "ok\n" : " " . $vstr . "\n";
+
+    $vnum >= $wanted;
+}
 
 sub set_version {
     $VERSION = $Apache::Test::VERSION;

Reply via email to