perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From do...@locus.apache.org
Subject cvs commit: modperl/lib/Apache test.pm
Date Fri, 13 Oct 2000 17:21:27 GMT
dougm       00/10/13 10:21:22

  Modified:    .        Changes
               lib/Apache test.pm
  Log:
  new Apache::test::static_modules() method
  
  Revision  Changes    Path
  1.547     +3 -0      modperl/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/modperl/Changes,v
  retrieving revision 1.546
  retrieving revision 1.547
  diff -u -r1.546 -r1.547
  --- Changes	2000/10/10 16:46:13	1.546
  +++ Changes	2000/10/13 17:21:11	1.547
  @@ -10,6 +10,9 @@
   
   =item 1.24_02-dev
   
  +new Apache::test::static_modules() method
  +[Ken Williams <ken@forum.swarthmore.edu>]
  +
   =item 1.24_01 - October 10, 2000
   
   fix bug in $r->args that treats ?0 as the empty string instead of zero,
  
  
  
  1.20      +36 -23    modperl/lib/Apache/test.pm
  
  Index: test.pm
  ===================================================================
  RCS file: /home/cvs/modperl/lib/Apache/test.pm,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- test.pm	2000/10/02 21:06:19	1.19
  +++ test.pm	2000/10/13 17:21:18	1.20
  @@ -138,13 +138,12 @@
   }
   
   sub _read_existing_conf {
  -    # Returns some config text 
  -    shift;
  -    my ($server_conf) = @_;
  +    # Returns some "(Add|Load)Module" config lines, generated from the
  +    # existing config file and a few must-have modules.
  +    my ($self, $server_conf) = @_;
       
  -    
       open SERVER_CONF, $server_conf or die "Couldn't open $server_conf: $!";
  -    my @lines = grep {!m/^\s*#/} <SERVER_CONF>;
  +    my @lines = grep {!m/^\s*\#/} <SERVER_CONF>;
       close SERVER_CONF;
       
       my @modules       =   grep /^\s*(Add|Load)Module/, @lines;
  @@ -154,41 +153,47 @@
       foreach (@modules) {
   	s!(\s)([^/\s]\S+/)!$1$server_root/$2!;
       }
  -    
  -    # Directories where apache DSOs live.
  -    my (@module_dirs) = map {m,(/\S*/),} @modules;
  -    
  -    # Have to make sure that dir, autoindex and perl are loaded.
  -    my @required  = qw(dir autoindex perl);
       
  -    my @l = `t/httpd -l`;
  -    my @compiled_in = map /^\s*(\S+)/, @l[1..@l-2];
  +    my $static_mods = $self->static_modules('t/httpd');
       
       my @load;
  -    foreach my $module (@required) {
  -	if (!grep /$module/i, @compiled_in, @modules) {
  +    # Have to make sure that dir, autoindex and perl are loaded.
  +    foreach my $module (qw(dir autoindex perl)) {
  +       unless ($static_mods->{"mod_$module"} or grep /$module/i, @modules) {
  +           warn "Will attempt to load mod_$module dynamically.\n";
   	    push @load, $module;
   	}
       }
       
  +    # Directories where apache DSOs live.
  +    my @module_dirs = map {m,(/\S*/),} @modules;
  +    
       # Finally compute the directives to load modules that need to be loaded.
    MODULE:
       foreach my $module (@load) {
   	foreach my $module_dir (@module_dirs) {
  -	    if (-e "$module_dir/mod_$module.so") {
  -		push @modules, "LoadModule ${module}_module $module_dir/mod_$module.so\n"; next MODULE;
  -	    } elsif (-e "$module_dir/lib$module.so") {
  -		push @modules, "LoadModule ${module}_module $module_dir/lib$module.so\n"; next MODULE;
  -	    } elsif (-e "$module_dir/ApacheModule\u$module.dll") {
  -		push @modules, "LoadModule ${module}_module $module_dir/ApacheModule\u$module.dll\n";
next MODULE;
  +           foreach my $filename ("mod_$module.so", "lib$module.so", "ApacheModule\u$module.dll")
{
  +               if (-e "$module_dir/$filename") {
  +                   push @modules, "LoadModule ${module}_module $module_dir/$filename\n";
next MODULE;
  +               }
   	    }
   	}
  +       warn "Warning: couldn't find anything to load for 'mod_$module'.\n";
       }
  -		      
  -    print "found the following modules: \n@modules";
  +    
  +    print "Adding the following dynamic config lines: \n@modules";
       return join '', @modules;
   }
   
  +sub static_modules {
  +    # Returns a hashref whose keys are each of the modules compiled
  +    # statically into the given httpd binary.
  +    my ($self, $httpd) = @_;
  +
  +    my @l = `$httpd -l`;
  +    return {map {lc($_) => 1} map /(\S+)\.c/, @l};
  +}
  +
   # Find an executable in the PATH.
   sub which {
       foreach (map { "$_/$_[0]" } split /:/, $ENV{PATH}) {
  @@ -628,6 +633,14 @@
   response.  In a list context, fetch() returns the content and the
   HTTP::Response object itself.  This can be handy if you need to check
   the response headers, or the HTTP return code, or whatever.
  +
  +=head2 static_modules
  +
  + Example: $mods = Apache::test->static_modules('/path/to/httpd');
  +
  +This method returns a hashref whose keys are all the modules
  +statically compiled into the given httpd binary.  The corresponding
  +values are all 1.
   
   =head1 EXAMPLES
   
  
  
  

Mime
View raw message