httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: resolving Apache::Test vs. Apache::test collision
Date Tue, 17 Jun 2003 02:58:42 GMT
Stas Bekman wrote:
> David Wheeler wrote:
> 
>> On Monday, June 16, 2003, at 08:02  PM, Stas Bekman wrote:
>>
>>> Any idea why has it failed to delete the file? I've copied the code 
>>> from forceunlink sub in MakeMaker (which is called on UNINST=1), it 
>>> changes the mode to 0666 and then attempts to delete the file.
>>
>>
>>
>> Because I ran it as a non-root user.
> 
> 
> This makes sense :) so it doesn't fit the idiom:
> 
> % perl Makefile.PL
> % make
> % make test
> % su
> % make install
> 
> in that case we need to override the 'make install' target to delete the 
> files. instead of doind that during 'perl Makefile.PL'.

David, please test this patch. This version performs the cleanup only during 
'make install'. what I'm not sure about is whether it handles correctly some 
weird paths when creating the packlist. I think it should work, since nothing 
is passed via shell, but goes perl-2-perl.

Index: Makefile.PL
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/Makefile.PL,v
retrieving revision 1.8
diff -u -r1.8 Makefile.PL
--- Makefile.PL	29 Apr 2003 06:37:47 -0000	1.8
+++ Makefile.PL	17 Jun 2003 02:51:17 -0000
@@ -1,5 +1,7 @@
  use 5.005;

+use strict;
+
  use ExtUtils::MakeMaker;
  use Symbol;

@@ -7,10 +9,14 @@

  my $VERSION;

+use File::Spec::Functions qw(catfile catdir);
+
  use Apache::Test5005compat;

  use Apache::TestMM qw(test); #enable 'make test'

+my $cleanup_packlist = ".mypacklist";
+
  Apache::TestMM::filter_args();

  my @scripts = qw(t/TEST);
@@ -21,6 +27,8 @@

  set_version();

+nuke_Apache__test();
+
  WriteMakefile(
      NAME      => 'Apache::Test',
      VERSION   => $VERSION,
@@ -59,3 +67,74 @@
      return $string;
  }

+
+# 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 MY::top_targets {
+    my $self = shift;
+    my $string = $self->MY::top_targets;
+
+    $string .= <<EOF;
+
+nuke_Apache__test:
+\t\$(PERLRUN) -MExtUtils::Install -e 'uninstall("$cleanup_packlist", 1, 0)'
+EOF
+
+    $string;
+}
+
+sub add_dep {
+    my($string, $targ, $add) = @_;
+    $$string =~ s/($targ\s+::)/$1 $add/;
+}


Mime
View raw message