You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-cvs@httpd.apache.org by st...@apache.org on 2003/06/18 10:55:57 UTC

cvs commit: httpd-test/perl-framework/Apache-Test install-pl MANIFEST Makefile.PL

stas        2003/06/18 01:55:57

  Modified:    .        Makefile.PL
               perl-framework/Apache-Test MANIFEST Makefile.PL
  Added:       perl-framework/Apache-Test install-pl
  Log:
  - since when mod_perl is installed, Apache-Test doesn't run its install
  targets, we have to do the trickery to do this from the top level
  Makefile.PL, hence abstracting the code to add targets which will nuke
  Apache/test.pl into a separate library install-pl, which is useful only
  during the build.
  - correct the uninstall code, to check the existance of the packlist file,
  so more than one 'make install' in a row will work without errors
  
  Revision  Changes    Path
  1.106     +17 -0     modperl-2.0/Makefile.PL
  
  Index: Makefile.PL
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/Makefile.PL,v
  retrieving revision 1.105
  retrieving revision 1.106
  diff -u -r1.105 -r1.106
  --- Makefile.PL	12 Jun 2003 23:42:23 -0000	1.105
  +++ Makefile.PL	18 Jun 2003 08:55:56 -0000	1.106
  @@ -2,6 +2,10 @@
   use strict;
   use warnings FATAL => 'all';
   
  +# useful for sub-Makefile.PL's to know whether they are invoked
  +# directly or via the top level Makefile.PL
  +$ENV{MOD_PERL_2_BUILD} = 1;
  +
   my $min_httpd_version = '2.0.36';
   
   my($old_modperl_version, $old_modperl_pm);
  @@ -382,6 +386,12 @@
   
   use Config;
   
  +BEGIN {
  +    use constant APACHE_TEST_INSTALL => -e 'Apache-Test';
  +    use lib './Apache-Test';
  +    require 'install-pl' if APACHE_TEST_INSTALL;
  +}
  +
   sub MY::top_targets {
       my $self = shift;
       my $string = $self->ModPerl::BuildMM::MY::top_targets;
  @@ -417,6 +427,9 @@
   
   EOF
   
  +    $string .= Apache::Test::install::nuke_Apache__test_target()
  +        if APACHE_TEST_INSTALL();
  +
       $string;
   }
   
  @@ -425,6 +438,10 @@
       my $string = $self->MM::install(@_);
       ModPerl::MM::add_dep(\$string, pure_install => 'modperl_lib_install');
       ModPerl::MM::add_dep(\$string, pure_install => 'modperl_xs_h_install');
  +
  +    ModPerl::MM::add_dep(\$string, pure_install => 'nuke_Apache__test')
  +          if APACHE_TEST_INSTALL();
  +
       $string;
   }
   
  
  
  
  1.7       +1 -0      httpd-test/perl-framework/Apache-Test/MANIFEST
  
  Index: MANIFEST
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/MANIFEST,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- MANIFEST	19 May 2003 23:30:22 -0000	1.6
  +++ MANIFEST	18 Jun 2003 08:55:57 -0000	1.7
  @@ -29,6 +29,7 @@
   t/conf/extra.conf.in
   t/ping.t
   t/request.t
  +install-pl
   Changes
   MANIFEST
   LICENSE
  
  
  
  1.13      +29 -69    httpd-test/perl-framework/Apache-Test/Makefile.PL
  
  Index: Makefile.PL
  ===================================================================
  RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/Makefile.PL,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Makefile.PL	18 Jun 2003 04:50:11 -0000	1.12
  +++ Makefile.PL	18 Jun 2003 08:55:57 -0000	1.13
  @@ -6,16 +6,17 @@
   use strict;
   use warnings;
   
  +# is this file was invoked directly via perl, or via the top-level
  +# Makefile.PL, top-level sets this env var
  +use constant TOP_LEVEL => !exists $ENV{MOD_PERL_2_BUILD};
  +
   use ExtUtils::MakeMaker;
   use Symbol;
   
  -use File::Spec::Functions qw(catfile catdir);
  -
   use Apache::TestMM qw(test); #enable 'make test'
   
   my $VERSION;
   
  -my $cleanup_packlist = ".mypacklist";
   
   Apache::TestMM::filter_args();
   
  @@ -27,7 +28,12 @@
   
   set_version();
   
  -nuke_Apache__test();
  +# if built with mod_perl 2.0, it top-level Makefile.PL already
  +# installs the uninstall code
  +if (TOP_LEVEL) {
  +    require "./install-pl";
  +    add_Apache__test_target();
  +}
   
   WriteMakefile(
       NAME      => 'Apache::Test',
  @@ -68,73 +74,27 @@
   }
   
   
  -# on Case-Insensitive systems Apache/Test.pm can't coexist with
  -# Apache/test.pm, since Apache::test is now deprecated (was renamed to
  -# Apache/testold.pm in mod_perl 1.28, we need to find and remove any
  -# occurrences of this file. CPAN authors should
  -# s/Apache::test/Apache::testold/ and can either require mod_perl 1.28
  -# which already carries it or simply bundle it. The best option is to
  -# port the test suite to use Apache::Test which works with both
  -# mod_perl generations.
  -#
  -# we could have done this cleanup only for case-insensitive systems,
  -# but I feel that doing it for all systems, will speedup the
  -# transitions from Apache::test to either Apache::Test or
  -# Apache::testold.
  -#
  -sub nuke_Apache__test {
  -
  -    my @convicts = ();
  -    foreach (@INC) {
  -        my $dir = catdir $_, "Apache";
  -        next unless -d $dir;
  -        opendir DIR, $dir or die "Cannot opendir $dir: $!\n";
  -        my @matches = grep /^test.pm$/, readdir DIR;
  -        closedir DIR;
  -        push @convicts, map { catfile $dir, $_ } @matches if @matches;
  -    }
  -
  -    if (@convicts) {
  -        print <<EOI;
  -!!! Makefile.PL has found old copies of Apache/test.pm which will
  -be removed during 'make install' to prevent collisions with Apache::Test:
  -
  -@{[join "\n", @convicts]}
  -
  -CPAN authors are advised to either use Apache::testold or port their
  -test suite to Apache::Test which works with both mod_perl generations.
  -EOI
  -    }
  -
  -    open PACKLIST, ">$cleanup_packlist"
  -        or die "Can't open $cleanup_packlist: $!";
  -    print PACKLIST join "", map "$_\n", @convicts;
  -    close PACKLIST;
  -}
  -
  -sub MY::install {
  -    my $self = shift;
  -
  -    my $string = $self->MM::install(@_);
  -    add_dep(\$string, pure_install => 'nuke_Apache__test');
  -
  -    $string;
  +sub add_dep {
  +    my($string, $targ, $add) = @_;
  +    $$string =~ s/($targ\s+::)/$1 $add/;
   }
   
  -sub MY::top_targets {
  -    my $self = shift;
  -    my $string = $self->MM::top_targets;
  -
  -    $string .= <<EOF;
  +sub add_Apache__test_target {
  +    use subs qw(MY::install MY::top_targets);
  +    *MY::install = sub {
  +        my $self = shift;
  +
  +        my $string = $self->MM::install(@_);
  +        add_dep(\$string, pure_install => 'nuke_Apache__test');
  +        $string;
  +    };
  +
  +    *MY::top_targets  = sub {
  +        my $self = shift;
  +        my $string = $self->MM::top_targets;
   
  -nuke_Apache__test:
  -\t\$(PERLRUN) -MExtUtils::Install -e "uninstall(qq{$cleanup_packlist}, 1, 0)"
  -EOF
  +        $string .= Apache::Test::install::nuke_Apache__test_target();
   
  -    $string;
  -}
  -
  -sub add_dep {
  -    my($string, $targ, $add) = @_;
  -    $$string =~ s/($targ\s+::)/$1 $add/;
  +        $string;
  +    };
   }
  
  
  
  1.1                  httpd-test/perl-framework/Apache-Test/install-pl
  
  Index: install-pl
  ===================================================================
  # this is just a helper module for the installation phase, so it can
  # be re-used during the standalone and mod_perl 2.0 install
  
  # it has this unusual filename: install-pl, to prevent MakeMaker from
  # installing it system-wide
  package Apache::Test::install;
  
  use strict;
  use warnings;
  
  use File::Spec::Functions qw(catfile catdir);
  
  # on Case-Insensitive systems Apache/Test.pm can't coexist with
  # Apache/test.pm, since Apache::test is now deprecated (was renamed to
  # Apache/testold.pm in mod_perl 1.28, we need to find and remove any
  # occurrences of this file. CPAN authors should
  # s/Apache::test/Apache::testold/ and can either require mod_perl 1.28
  # which already carries it or simply bundle it. The best option is to
  # port the test suite to use Apache::Test which works with both
  # mod_perl generations.
  #
  # we could have done this cleanup only for case-insensitive systems,
  # but I feel that doing it for all systems, will speedup the
  # transitions from Apache::test to either Apache::Test or
  # Apache::testold.
  #
  sub nuke_Apache__test_target {
  
      my $cleanup_packlist = ".mypacklist";
  
      my @convicts = ();
      foreach (@INC) {
          my $dir = catdir $_, "Apache";
          next unless -d $dir;
          opendir DIR, $dir or die "Cannot opendir $dir: $!\n";
          my @matches = grep /^test.pm$/, readdir DIR;
          closedir DIR;
          push @convicts, map { catfile $dir, $_ } @matches if @matches;
      }
  
      if (@convicts) {
          print <<EOI;
  !!! Makefile.PL has found old copies of Apache/test.pm which will
  be removed during 'make install' to prevent collisions with Apache::Test:
  
  @{[join "\n", @convicts]}
  
  CPAN authors are advised to either use Apache::testold or port their
  test suite to Apache::Test which works with both mod_perl generations.
  EOI
      }
  
      open PACKLIST, ">$cleanup_packlist"
          or die "Can't open $cleanup_packlist: $!";
      print PACKLIST join "", map "$_\n", @convicts;
      close PACKLIST;
  
      return <<EOF;
  
  nuke_Apache__test:
  \t\$(PERLRUN) -MExtUtils::Install -e \\
  \t"-e qq{$cleanup_packlist} && uninstall(qq{$cleanup_packlist}, 1, 0)"
  EOF
  
  }
  
  1;