Apache-Roaming

 view release on metacpan or  search on metacpan

Makefile.PL  view on Meta::CPAN

# -*- perl -*-
#
#   $Id: Makefile.PL,v 1.2 1999/02/13 00:24:43 joe Exp $
#
#
#   Apache::Roaming - A mod_perl handler for Roaming Profiles
#
#
#   Based on mod_roaming by
#	Vincent Partington <vincentp@xs4all.nl>
#	See http://www.xs4all.nl/~vincentp/software/mod_roaming.html
#
#
#   Copyright (C) 1999    Jochen Wiedmann
#                         Am Eisteich 9
#                         72555 Metzingen
#                         Germany
#
#                         Phone: +49 7123 14887
#                         Email: joe@ispsoft.de
#
#   All rights reserved.
#
#   You may distribute this module under the terms of either
#   the GNU General Public License or the Artistic License, as
#   specified in the Perl README file.
#
############################################################################

require 5.004;
use strict;


use ExtUtils::MakeMaker;
use Getopt::Long;
use Cwd;


use vars qw($opt_config);
Getopt::Long::GetOptions('config');


my %prereq = ('File::Spec' => 0,
	      'Data::Dumper' => 0,
	      'URI::Escape' => 0,
	      'Apache' => 0);

use lib 'lib';
eval { require Apache::Roaming::LiPrefs::Config };

my $cfg;
eval {require File::Spec; require Data::Dumper};
if (!$@  &&
    (!($cfg = eval { require ".status"})  or  $opt_config)) {
    $cfg = {} if !$cfg or ref($cfg) ne 'HASH';
    my $httpd_path = $cfg->{'httpd_path'};
    if (!$httpd_path) {
	foreach my $dir (File::Spec->path()) {
	    my $file = File::Spec->catfile($dir, "httpd");
	    if (-x $file) {
		$httpd_path = $file;
		last;
	    }
	}
    }
    $cfg->{'httpd_path'} = prompt("Path of the Apache server: ",
				  $httpd_path || '/usr/sbin/httpd');
    die "Cannot execute HTTPD server $cfg->{'httpd_path'}: No such file"
	unless -x $cfg->{'httpd_path'};

    my $httpd_V_output = `$cfg->{'httpd_path'} -V`;
    my $httpd_conf_path =
	($httpd_V_output =~ /\s+-D\s+SERVER_CONFIG_FILE="(.*?)"/) ?
	    $1 : "/etc/httpd/httpd.conf";
    $cfg->{'httpd_conf_path'} = prompt("Path of the httpd.conf file: ",
				       $httpd_conf_path);
    my $httpd_conf_contents;
    die "Failed to read httpd config file $cfg->{'httpd_conf_path'}: $!"
	unless open(FILE, "<$cfg->{'httpd_conf_path'}");

    my(@module_list, $server_root);
    while (defined(my $line = <FILE>)) {
	if ($line =~ /\s*ServerRoot\s+\"?(.*?)\"?\s*$/) {
	    $server_root = $1;
	}
	if ($line =~ /^\s*(AddModule|LoadModule)\s+/  ||
	    $line =~ /^\s*ClearModuleList\s*$/) {
	    push(@module_list, $line);
	}
    }
    close(FILE);
    @module_list = map {
	if ($_ =~ /^\s*LoadModule\s+(\S+)\s+(.*)/) {
	    my $module = $1;
	    my $path = $2;
	    if ($path !~ /^\//) {
		die "Cannot parse httpd config file $cfg->{'httpd_conf_path'}:"
		    . " Missing ServerRoot" unless $server_root;
		$_ = "LoadModule $module $server_root/$path\n";
	    }
	}
	$_;
    } @module_list;
    $cfg->{'dynamic_module_list'} = join("", @module_list);

    $cfg->{'httpd_user'} = prompt("HTTPD's UID for running tests: ",
				  $cfg->{'httpd_user'} || ('#' . $>));
    my $gid = $);



( run in 2.066 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )