You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by ph...@apache.org on 2009/01/09 02:30:11 UTC

svn commit: r732903 - in /perl/Apache-Bootstrap/trunk: Changes LICENSE MANIFEST META.yml Makefile.PL README lib/ lib/Apache/ lib/Apache/Bootstrap.pm t/ t/00-load.t t/pod-coverage.t t/pod.t

Author: phred
Date: Thu Jan  8 17:30:10 2009
New Revision: 732903

URL: http://svn.apache.org/viewvc?rev=732903&view=rev
Log:
Initial commit of Apache::Bootstrap to ASF repository.
Probably a bunch of stuff that needs to be cleaned up here, but so be it.
Thanks to pgollucci for setting up the repo and providing some motivation :)

Added:
    perl/Apache-Bootstrap/trunk/Changes
    perl/Apache-Bootstrap/trunk/LICENSE
    perl/Apache-Bootstrap/trunk/MANIFEST
    perl/Apache-Bootstrap/trunk/META.yml
    perl/Apache-Bootstrap/trunk/Makefile.PL
    perl/Apache-Bootstrap/trunk/README
    perl/Apache-Bootstrap/trunk/lib/
    perl/Apache-Bootstrap/trunk/lib/Apache/
    perl/Apache-Bootstrap/trunk/lib/Apache/Bootstrap.pm
    perl/Apache-Bootstrap/trunk/t/
    perl/Apache-Bootstrap/trunk/t/00-load.t
    perl/Apache-Bootstrap/trunk/t/pod-coverage.t
    perl/Apache-Bootstrap/trunk/t/pod.t

Added: perl/Apache-Bootstrap/trunk/Changes
URL: http://svn.apache.org/viewvc/perl/Apache-Bootstrap/trunk/Changes?rev=732903&view=auto
==============================================================================
--- perl/Apache-Bootstrap/trunk/Changes (added)
+++ perl/Apache-Bootstrap/trunk/Changes Thu Jan  8 17:30:10 2009
@@ -0,0 +1,23 @@
+Revision history for Apache-Bootstrap
+
+0.04_02  Sat Nov 08 17:07:56 PST 2008
+    - skip more tests if no versions of mod_perl are present
+    - clean up a bit more of the convoluted logic
+
+0.04_01  Fri Jun 27 20:58:58 PST 2008
+    - more tests, coverage for success conditions
+    - now we actually fail at compile time if base mod_perl is not present
+
+0.03  Sun Jun 22 01:28:13 PST 2008
+    - fail at compile time if mod_perl dependencies are not present
+    - put the constructor back now that it has a use case
+    - add a few helper methods, and WriteMakefile which uses the appropriate
+        build subsystem
+
+0.02  Fri Jun 20 15:28:27 PST 2008
+    - change interface call methods as class methods
+    - default to finding mp2 before finding mp1
+
+0.01  Thu May 10 00:13:05 PST 2008
+    - First version, released on an unsuspecting world.
+

Added: perl/Apache-Bootstrap/trunk/LICENSE
URL: http://svn.apache.org/viewvc/perl/Apache-Bootstrap/trunk/LICENSE?rev=732903&view=auto
==============================================================================
--- perl/Apache-Bootstrap/trunk/LICENSE (added)
+++ perl/Apache-Bootstrap/trunk/LICENSE Thu Jan  8 17:30:10 2009
@@ -0,0 +1,202 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

Added: perl/Apache-Bootstrap/trunk/MANIFEST
URL: http://svn.apache.org/viewvc/perl/Apache-Bootstrap/trunk/MANIFEST?rev=732903&view=auto
==============================================================================
--- perl/Apache-Bootstrap/trunk/MANIFEST (added)
+++ perl/Apache-Bootstrap/trunk/MANIFEST Thu Jan  8 17:30:10 2009
@@ -0,0 +1,10 @@
+Changes
+MANIFEST
+Makefile.PL
+README
+lib/Apache/Bootstrap.pm
+t/00-load.t
+t/pod-coverage.t
+t/pod.t
+LICENSE
+META.yml                                 Module meta-data (added by MakeMaker)

Added: perl/Apache-Bootstrap/trunk/META.yml
URL: http://svn.apache.org/viewvc/perl/Apache-Bootstrap/trunk/META.yml?rev=732903&view=auto
==============================================================================
--- perl/Apache-Bootstrap/trunk/META.yml (added)
+++ perl/Apache-Bootstrap/trunk/META.yml Thu Jan  8 17:30:10 2009
@@ -0,0 +1,10 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
+name:         Apache-Bootstrap
+version:      0.04_02
+version_from: lib/Apache/Bootstrap.pm
+installdirs:  site
+requires:
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.30

Added: perl/Apache-Bootstrap/trunk/Makefile.PL
URL: http://svn.apache.org/viewvc/perl/Apache-Bootstrap/trunk/Makefile.PL?rev=732903&view=auto
==============================================================================
--- perl/Apache-Bootstrap/trunk/Makefile.PL (added)
+++ perl/Apache-Bootstrap/trunk/Makefile.PL Thu Jan  8 17:30:10 2009
@@ -0,0 +1,26 @@
+use strict;
+use warnings;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+    NAME          => 'Apache::Bootstrap',
+    AUTHOR        => 'Fred Moyer <fr...@redhotpenguin.com>',
+    VERSION_FROM  => 'lib/Apache/Bootstrap.pm',
+    ABSTRACT_FROM => 'lib/Apache/Bootstrap.pm',
+    PL_FILES      => {},
+    dist          => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+    clean => { FILES => 'Apache-Bootstrap-*' },
+);
+
+package MY;
+
+sub test {
+    my $self = shift;
+
+    eval { require Test::More } or return <<EOF;
+test::
+\t\@echo sorry, cannot run tests without Test::More
+EOF
+
+    return $self->SUPER::test();
+}

Added: perl/Apache-Bootstrap/trunk/README
URL: http://svn.apache.org/viewvc/perl/Apache-Bootstrap/trunk/README?rev=732903&view=auto
==============================================================================
--- perl/Apache-Bootstrap/trunk/README (added)
+++ perl/Apache-Bootstrap/trunk/README Thu Jan  8 17:30:10 2009
@@ -0,0 +1,119 @@
+NAME
+    Apache::Bootstrap - Bootstraps dual life mod_perl1 and mod_perl2 Apache
+    modules
+
+SYNOPSIS
+    In your Makefile.PL
+
+     use Apache::Bootstrap 0.04;
+
+     my $bootstrap;
+
+     BEGIN {
+        # make sure we have at least one minimum version required
+        $bootstrap = Apache::Bootstrap->new({ mp2 => '1.99022', mp1 => 0, });
+     }
+
+     # write the Makefile using a mod_perl version dependent build subsystem
+     $bootstrap->WriteMakefile( %maker_options );
+
+     # check for Apache::Test, return the installed version if exists
+     my $has_apache_test = $bootstrap->check_for_apache_test();
+
+     # see if mod_perl2 is installed
+     my $mp_generation = $bootstrap->satisfy_mp_generation( 2 );
+
+     unless ($mp_generation) {
+
+         # no mod_perl2?  look for mod_perl 1
+         $mp_generation = $bootstrap->satisfy_mp_generation( 1 );
+     }
+
+     # any mod_perl version will do
+     $mp_generation = Apache::Bootstrap->satisfy_mp_generation();
+     unless ( $mp_generation ) {
+          warn( 'No mod_perl installation was found' )
+     } else {
+          warn( "mod_perl generation $mp_generation was found" );
+     }
+
+METHODS
+  new()
+     # try to find these versions of mod_perl, die if none are found
+     $bootstrap = Apache::Bootstrap->new({
+         mod_perl2 => 1.99022, # after mp2 renaming
+         mod_perl1 => 0,       # any verison of mp1
+     });
+
+  mp_prereqs()
+     # returns the prerequisites for mod_perl versions in a hash reference
+
+  check_for_apache_test()
+     $apache_test_version = Apache::Bootstrap->check_for_apache_test;
+
+    Returns the version of Apache::Test installed. Returns undefined if
+    Apache::Test is not installed.
+
+  satisfy_mp_generation()
+     # see if mod_perl2 is installed
+     my $mp_generation = Apache::Bootstrap->satisfy_mp_generation( 2 );
+
+     unless ($mp_generation) {
+
+         # no mod_perl2?  look for mod_perl 1
+         $mp_generation = Apache::Bootstrap->satisfy_mp_generation( 1 );
+     }
+
+     # any mod_perl version will do
+     $mp_generation = Apache::Bootstrap->satisfy_mp_generation();
+     unless ( $mp_generation ) {
+         warn( 'No mod_perl installation was found' )
+     } else {
+         warn( "mod_perl generation $mp_generation was found" );
+     }
+
+    Currently the logic for determining the mod_perl generation is as
+    follows.
+
+     # If a specific generation was passed as an argument,
+     #     if satisfied
+     #         return the same generation
+     #     else
+     #         die
+     # else @ARGV and %ENV will be checked for specific orders
+     #     if the specification will be found
+     #         if satisfied
+     #             return the specified generation
+     #         else
+     #             die
+     #     else if any mp generation is found
+     #              return it
+     #           else
+     #              die
+
+  apache_major_version()
+     $apache_major_version = $bootstrap->apache_major_version;
+
+    The major version number of the target apache install
+
+  WriteMakefile()
+     $bootstrap->write_makefile( %makefile_options );
+
+    Writes the makefile using the appropriate make engine depending on what
+    mod_perl version is in use. Same API as ExtUtils::MakeMaker or
+    ModPerl::BuildMM
+
+AUTHOR
+    Fred Moyer <fr...@redhotpenguin.com>
+
+    The mod_perl development team "<dev at perl.apache.org"> and numerous
+    contributors.
+
+    This code was lifted from Apache::SizeLimit in an effort to make it
+    useful to other modules such as Apache::Reload, Apache::Dispatch, any
+    dual life Apache module.
+
+BUGS
+    Please report bugs to the mod_perl development mailing list "<dev at
+    perl.apache.org">
+

Added: perl/Apache-Bootstrap/trunk/lib/Apache/Bootstrap.pm
URL: http://svn.apache.org/viewvc/perl/Apache-Bootstrap/trunk/lib/Apache/Bootstrap.pm?rev=732903&view=auto
==============================================================================
--- perl/Apache-Bootstrap/trunk/lib/Apache/Bootstrap.pm (added)
+++ perl/Apache-Bootstrap/trunk/lib/Apache/Bootstrap.pm Thu Jan  8 17:30:10 2009
@@ -0,0 +1,419 @@
+package Apache::Bootstrap;
+
+use warnings;
+use strict;
+
+=head1 NAME
+
+Apache::Bootstrap - Bootstraps dual life mod_perl1 and mod_perl2 Apache modules
+
+=cut
+
+our $VERSION = '0.04_02';
+
+use constant MIN_MP2_VER => '1.99022';    # mp2 renaming
+
+=head1 SYNOPSIS
+
+In your Makefile.PL
+
+ use Apache::Bootstrap 0.04;
+
+ my $bootstrap;
+
+ BEGIN {
+    # check to make sure we have mod_perl 1 installed
+    $bootstrap = Apache::Bootstrap->new({ mp1 => 0 });
+
+    # or check for mod_perl 2
+    $bootstrap = Apache::Bootstrap->new({ mp2 => '1.99022' });
+ }
+
+ # check for Apache::Test, return the installed version if exists
+ my $has_apache_test = $bootstrap->check_for_apache_test();
+
+ # see if mod_perl2 is installed (useful when both mp1 and mp2 are installed)
+ my $mp_generation = $bootstrap->satisfy_mp_generation( 2 );
+
+ unless ($mp_generation) {
+
+     # no mod_perl2?  look for mod_perl 1
+     $mp_generation = $bootstrap->satisfy_mp_generation( 1 );
+ }
+
+ # any mod_perl version will do
+ $mp_generation = Apache::Bootstrap->satisfy_mp_generation();
+ unless ( $mp_generation ) {
+      warn( 'No mod_perl installation was found' )
+ } else {
+      warn( "mod_perl generation $mp_generation was found" );
+ }
+
+ # write the Makefile using a mod_perl version dependent build subsystem
+ $bootstrap->WriteMakefile( %maker_options );
+
+=head1 DESCRIPTION
+
+Writing modules for mod_perl that work under both mod_perl1 and mod_perl2 is not fun.
+
+This module is here to make that endeavour less painful.  mod_perl2 is great, but
+a lot of users are still using mod_perl1.  Migrating to mod_perl2 while maintaining
+mod_perl1 compatibility isn't easy, and this module is here to make that transition
+as painless as possible.
+
+=head1 METHODS
+
+=head2 new()
+
+ # try to find these versions of mod_perl, die if none are found
+ $bootstrap = Apache::Bootstrap->new({
+     mod_perl2 => 1.99022, # after mp2 renaming
+     mod_perl1 => 0,       # any verison of mp1
+ });
+
+=cut
+
+sub new {
+    my ( $class, $args ) = @_;
+
+    die 'perldoc Apache::Bootstrap'
+      unless $args
+      && ref $args eq 'HASH'
+      && ( defined $args->{mod_perl1} or defined $args->{mod_perl2} );
+
+    my %self;
+    if ( defined $args->{mod_perl1} ) {
+
+        # delete mp2 from inc first, note that we don't delete mod_perl2.pm
+        delete $INC{'mod_perl.pm'};
+
+        # look for mp1
+        eval { require mod_perl };
+        if ($@) {
+
+            die 'mod_perl1 not present, cannot bootstrap mp1:  ' . $@ if $@;
+
+        }
+        elsif (( $mod_perl::VERSION < $args->{mod_perl1} )
+            or ( $mod_perl::VERSION >= MIN_MP2_VER ) )
+        {
+
+            die sprintf( "mod_perl1 version %s not found, we have %s",
+                $args->{mod_perl1}, $mod_perl::VERSION );
+
+        }
+        else {
+
+            # store the version we have
+            $self{mod_perl1} = $mod_perl::VERSION;
+        }
+
+    }
+
+    if ( defined $args->{mod_perl2} ) {
+
+        # look for mp2
+        eval { require mod_perl2 };
+
+        if ($@) {
+            die 'mod_perl2 not present, cannot bootstrap mp2:  ' . $@ if $@;
+
+        }
+        elsif ( $mod_perl2::VERSION < $args->{mod_perl2} ) {
+
+            die sprintf( "mod_perl2 version %s not found, we have %s",
+                $args->{mod_perl2}, $mod_perl2::VERSION );
+
+        }
+        else {
+
+            # store the version we have
+            $self{mod_perl2} = $mod_perl2::VERSION;
+        }
+
+    }
+
+    # make sure that we have at least one mod_perl version present
+    die "no versions of mod_perl could be found matching your constraints\n"
+      unless ( defined $self{mod_perl1} or defined $self{mod_perl2} );
+
+    bless \%self, $class;
+
+    return \%self;
+}
+
+=head2 mp_prereqs()
+
+ returns the prerequisites for mod_perl versions in a hash reference
+
+=cut
+
+sub mp_prereqs {
+    my $self = shift;
+    return {
+        map { $_ => $self->{$_} }
+          grep { /^mod_perl[12]$/ } keys %{$self}
+    };
+}
+
+=head2 check_for_apache_test()
+
+ $apache_test_version = Apache::Bootstrap->check_for_apache_test;
+
+Returns the version of Apache::Test installed.  Returns undefined if
+Apache::Test is not installed.
+
+=cut
+
+sub check_for_apache_test {
+    my ( $self, $at_min_ver ) = @_;
+
+    return unless eval {
+        require Apache::Test;
+        if ( $Apache::Test::VERSION < ( $at_min_ver || 0 ) ) {
+            warn "Apache::Test version is "
+              . $Apache::Test::VERSION
+              . ", minimum version required is $at_min_ver"
+              . ", tests will be skipped\n";
+            die;
+        }
+        require Apache::TestMM;
+        require Apache::TestRunPerl;
+        1;
+    };
+
+    Apache::TestMM::filter_args();
+
+    no warnings;    # silence '@Apache::TestMM::Argv used only once' warning
+    my %args = @Apache::TestMM::Argv;
+
+    return
+      unless (
+        (
+            Apache::TestConfig->can('custom_config_path')
+            and -f Apache::TestConfig->custom_config_path()
+        )
+        or $args{apxs}
+        or $args{httpd}
+        or $ENV{APACHE_TEST_HTTPD}
+        or $ENV{APACHE_TEST_APXS}
+      );
+
+    Apache::TestRunPerl->generate_script();
+
+    return $Apache::Test::VERSION;
+}
+
+=head2 satisfy_mp_generation()
+
+ # see if mod_perl2 is installed
+ my $mp_generation = $bootstrap->satisfy_mp_generation( 2 );
+
+ unless ($mp_generation) {
+
+     # no mod_perl2?  look for mod_perl 1
+     $mp_generation = $bootstrap->satisfy_mp_generation( 1 );
+ }
+
+ # any mod_perl version will do, check for mp2 first
+ $mp_generation = $bootstrap->satisfy_mp_generation();
+ unless ( $mp_generation ) {
+     warn( 'No mod_perl installation was found' )
+ } else {
+     warn( "mod_perl generation $mp_generation was found" );
+ }
+
+
+=cut
+
+sub satisfy_mp_generation {
+    my ( $self, $wanted ) = @_;
+
+    $wanted ||= $self->_wanted_mp_generation();
+
+    unless ( $wanted == 1 || $wanted == 2 ) {
+        die "don't know anything about mod_perl generation: $wanted\n"
+          . "currently supporting only generations 1 and 2";
+    }
+
+    my $selected = 0;
+
+    if ( $wanted == 1 ) {
+
+        eval { require mod_perl };
+        if ($@) {
+            warn("could not satisfy mp1: $@");
+            return;
+        }
+
+        $selected = 1;
+    }
+    elsif ( $wanted == 2 ) {
+
+        eval { require mod_perl2 };
+        if ($@) {
+            warn("could not satisfy mp2: $@");
+            return;
+        }
+
+        $selected = 2;
+    }
+    else {
+
+        # try mp2 first
+        eval { require mod_perl2 };
+        if ($@) {
+            warn("could not satisfy mp2, trying mp1: $@");
+
+            eval { require mod_perl };
+            if ($@) {
+                warn("could not satisfy mp1, giving up: $@");
+                return;
+            }
+        }
+
+        $selected = $mod_perl::VERSION >= MIN_MP2_VER ? 2 : 1;
+    }
+
+    # make sure we have the needed build modules
+    my $build_pkg =
+      ( $selected == 2 ) ? 'ModPerl::BuildMM' : 'ExtUtils::MakeMaker';
+    eval "require $build_pkg";
+    die "could not require package $build_pkg: $@" if $@;
+
+    $self->{maker} = $build_pkg;
+
+    return $self->{mp_gen} = $selected;
+}
+
+# _wanted_mp_generation()
+#
+# the function looks at %ENV and Makefile.PL option to figure out
+# whether a specific mod_perl generation was requested.
+# It uses the following logic:
+# via options:
+# perl Makefile.PL MOD_PERL=2
+# or via %ENV:
+# env MOD_PERL=1 perl Makefile.PL
+#
+# return value is:
+# 1 or 2 if the specification was found (mp 1 and mp 2 respectively)
+# 0 otherwise
+
+# Currently the logic for determining the mod_perl generation
+# is as follows.
+
+# If a specific generation was passed as an argument,
+#     if satisfied
+#         return the same generation
+#     else
+#         die
+# else @ARGV and %ENV will be checked for specific orders
+#     if the specification will be found
+#         if satisfied
+#             return the specified generation
+#         else
+#             die
+#     else if any mp generation is found
+#              return it
+#           else
+#              die
+
+sub _wanted_mp_generation {
+    my $self = shift;
+
+    # check if we have a command line specification
+    # flag: 0: unknown, 1: mp1, 2: mp2
+    my $flag = 0;
+    foreach my $key (@ARGV) {
+        if ( $key =~ /^MOD_PERL=([12])$/ ) {
+            $flag = $1;
+        }
+    }
+
+    # check %ENV
+    my $env = exists $ENV{MOD_PERL} ? $ENV{MOD_PERL} : 0;
+
+    # check for contradicting requirements
+    if ( $env && $flag && $flag != $env ) {
+        warn <<EOF;
+Can\'t decide which mod_perl version should be used, since you have
+supplied contradicting requirements:
+    enviroment variable MOD_PERL=$env
+    Makefile.PL option  MOD_PERL=$flag
+EOF
+        die;
+    }
+
+    my $wanted = 0;
+    $wanted = 2 if $env == 2 || $flag == 2;
+    $wanted = 1 if $env == 1 || $flag == 1;
+
+    unless ($wanted) {
+
+        # if still unknown try to require mod_perl2.pm
+        eval { require mod_perl2 };
+        if ($@) {
+
+            # if we don't have mp2, check for mp1
+            eval { require mod_perl } if ($@);
+            unless ($@) {
+                $wanted = 1;
+            }
+        }
+        else {
+            $wanted = 2;
+        }
+    }
+
+    return $wanted;
+}
+
+=head2 apache_major_version()
+
+ $apache_major_version = $bootstrap->apache_major_version;
+
+The major version number of the target apache install
+
+=cut
+
+sub apache_major_version {
+    return ( shift->{mp_gen} == 1 ) ? 'Apache' : 'Apache2';
+}
+
+=head2 WriteMakefile()
+
+ $bootstrap->write_makefile( %makefile_options );
+
+Writes the makefile using the appropriate make engine depending on what
+mod_perl version is in use.  Same API as ExtUtils::MakeMaker or ModPerl::BuildMM
+
+=cut
+
+sub WriteMakefile {
+    my ( $self, %maker_opts ) = @_;
+
+    # write the makefile
+    my $sub = "$self->{maker}\:\:WriteMakefile";
+    {
+        no strict 'refs';
+        $sub->(%maker_opts);
+    }
+}
+
+=head1 AUTHOR
+
+Fred Moyer <fr...@redhotpenguin.com>
+
+The mod_perl development team C<<dev at perl.apache.org>> and numerous contributors.
+
+This code was lifted from Apache::SizeLimit in an effort to make it useful to
+other modules such as Apache::Reload, Apache::Dispatch, any dual life Apache module.
+
+=head1 BUGS
+
+Please report bugs to the mod_perl development mailing list C<<dev at perl.apache.org>>
+
+=cut
+
+1;

Added: perl/Apache-Bootstrap/trunk/t/00-load.t
URL: http://svn.apache.org/viewvc/perl/Apache-Bootstrap/trunk/t/00-load.t?rev=732903&view=auto
==============================================================================
--- perl/Apache-Bootstrap/trunk/t/00-load.t (added)
+++ perl/Apache-Bootstrap/trunk/t/00-load.t Thu Jan  8 17:30:10 2009
@@ -0,0 +1,102 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 11;
+
+my ( $pkg, $mp1_bootstrap, $mp2_bootstrap, $dual_bootstrap, $skip_all,
+    $skip_mp1, $skip_mp2 );
+
+BEGIN {
+    $pkg = 'Apache::Bootstrap';
+    use_ok($pkg);
+
+    can_ok(
+        $pkg, qw( new satisfy_mp_generation _wanted_mp_generation
+          check_for_apache_test apache_major_version )
+    );
+
+    # try bootstrapping just mp1
+    $mp1_bootstrap = eval { $pkg->new( { mod_perl1 => 0 } ) };
+    $skip_mp1 = $@ if $@;
+
+  SKIP: {
+        skip $skip_mp1, 1 if $skip_mp1;
+
+        isa_ok( $mp1_bootstrap, $pkg );
+    }
+
+    # try bootstrapping just mp2
+    $mp2_bootstrap = eval { $pkg->new( { mod_perl2 => 1.99022 } ) };
+    $skip_mp2 = $@ if $@;
+
+  SKIP: {
+        skip $skip_mp2, 1 if $skip_mp2;
+
+        isa_ok( $mp2_bootstrap, $pkg );
+    }
+
+  SKIP: {
+        skip "Skipping dual bootstrap", 2 if ( $skip_mp1 or $skip_mp2 );
+
+        $dual_bootstrap =
+          eval { $pkg->new( { mod_perl1 => 0, mod_perl2 => 1.99022 } ); };
+
+        # this should not throw an exception since individual bootstraps worked
+        ok( !$@, 'no exception thrown for dual bootstrap: ' . $@ );
+
+        isa_ok( $dual_bootstrap, $pkg );
+    }
+
+}
+
+diag("Testing Apache::Bootstrap $Apache::Bootstrap::VERSION, Perl $], $^X");
+
+eval { require Apache::Test };
+my $skip = $@ ? 'Apache::Test not installed, skipping test' : undef;
+
+SKIP: {
+    skip $skip, 1 if ( $skip or ( !$mp2_bootstrap && !$mp1_bootstrap ) );
+
+    # need a bootstrap object
+    my $bootstrap = $dual_bootstrap || $mp2_bootstrap || $mp1_bootstrap;
+
+    my $at_version = $bootstrap->check_for_apache_test;
+
+    cmp_ok( $at_version, '==', $Apache::Test::VERSION, 'check a:t version' );
+}
+
+# TODO - figure out how to test absence of apache::test
+
+# delete mod_perl from INC
+delete $INC{'mod_perl.pm'};
+
+SKIP: {
+    skip 'could not bootstrap mp1, skipping', 1 if !$mp1_bootstrap;
+
+    # test mp1 functions
+    my $mp1_version = $mp1_bootstrap->satisfy_mp_generation(1);
+    cmp_ok( $mp1_version, '==', 1, 'mod_perl1 present' );
+
+}
+
+SKIP: {
+    skip 'could not bootstrap mp1/mp2, skipping', 2 if !$dual_bootstrap;
+
+    # test mp2 functions with dual bootstrap
+    my $mp2_version = $dual_bootstrap->satisfy_mp_generation(2);
+    cmp_ok( $mp2_version, '==', 2, 'mod_perl2 present' );
+
+    my $mp1_version = $dual_bootstrap->satisfy_mp_generation(1);
+    cmp_ok( $mp1_version, '==', 1, 'mod_perl1 present' );
+
+}
+
+delete $INC{'mod_perl.pm'};
+
+SKIP: {
+    skip 'could not bootstrap mp2, skipping', 1 if !$mp2_bootstrap;
+    my $mp2_version = $mp2_bootstrap->satisfy_mp_generation(2);
+    cmp_ok( $mp2_version, '==', 2, 'mod_perl2 present' );
+}

Added: perl/Apache-Bootstrap/trunk/t/pod-coverage.t
URL: http://svn.apache.org/viewvc/perl/Apache-Bootstrap/trunk/t/pod-coverage.t?rev=732903&view=auto
==============================================================================
--- perl/Apache-Bootstrap/trunk/t/pod-coverage.t (added)
+++ perl/Apache-Bootstrap/trunk/t/pod-coverage.t Thu Jan  8 17:30:10 2009
@@ -0,0 +1,18 @@
+use strict;
+use warnings;
+use Test::More;
+
+# Ensure a recent version of Test::Pod::Coverage
+my $min_tpc = 1.08;
+eval "use Test::Pod::Coverage $min_tpc";
+plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
+    if $@;
+
+# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
+# but older versions don't recognize some common documentation styles
+my $min_pc = 0.18;
+eval "use Pod::Coverage $min_pc";
+plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
+    if $@;
+
+all_pod_coverage_ok();

Added: perl/Apache-Bootstrap/trunk/t/pod.t
URL: http://svn.apache.org/viewvc/perl/Apache-Bootstrap/trunk/t/pod.t?rev=732903&view=auto
==============================================================================
--- perl/Apache-Bootstrap/trunk/t/pod.t (added)
+++ perl/Apache-Bootstrap/trunk/t/pod.t Thu Jan  8 17:30:10 2009
@@ -0,0 +1,12 @@
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More;
+
+# Ensure a recent version of Test::Pod
+my $min_tp = 1.22;
+eval "use Test::Pod $min_tp";
+plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
+
+all_pod_files_ok();