Репозиторий ALT Linux backports/2.4
Последнее обновление: 9 июля 2008 | Пакетов: 497 | Посещений: 1575125
 поиск   регистрация   авторизация 
 
Группа :: Система/Серверы
Пакет: apache

 Главная   Изменения   Спек   Патчи   Загрузить   Bugs and FR 

Патч: apache-1.3.31-apxs.patch


diff -Naur apache_1.3.31-orig/src/support/apxs.pl apache_1.3.31/src/support/apxs.pl
--- apache_1.3.31-orig/src/support/apxs.pl	2004-02-21 00:02:24 +0200
+++ apache_1.3.31/src/support/apxs.pl	2004-05-12 20:54:20 +0300
@@ -1,4 +1,4 @@
-#!/usr/local/bin/perl
+#!/usr/bin/perl
 #
 # Copyright 1999-2004 The Apache Software Foundation
 #
@@ -173,7 +173,7 @@
                 print STDERR "apxs:Error: no config variable $var\n";
                 &usage;
             }
-	    $val=~s/"/\\"/g;
+            $val=~s/"/\\"/g;
             eval "\$CFG_${var}=\"${val}\"";
         } else {
             print STDERR "apxs:Error: malformatted -S option\n";
@@ -186,17 +186,17 @@
 ##  Initial DSO support check
 ##
 if ($^O ne "MSWin32") {
-if (not -x "$CFG_SBINDIR/$CFG_TARGET") {
-    print STDERR "apxs:Error: $CFG_SBINDIR/$CFG_TARGET not found or not executable\n";
-    exit(1);
-}
-if (not grep(/mod_so/, `$CFG_SBINDIR/$CFG_TARGET -l`)) {
-    print STDERR "apxs:Error: Sorry, no DSO support for Apache available\n";
-    print STDERR "apxs:Error: under your platform. Make sure the Apache\n";
-    print STDERR "apxs:Error: module mod_so is compiled into your server\n";
-    print STDERR "apxs:Error: binary `$CFG_SBINDIR/$CFG_TARGET'.\n";
-    exit(1);
-}
+    if (not -x "$CFG_SBINDIR/$CFG_TARGET") {
+        print STDERR "apxs:Warning: $CFG_SBINDIR/$CFG_TARGET not found or not executable\n";
+        print STDERR "apxs:Warning: Continuing anyway...\n";
+    }
+    if (not grep(/mod_so/, `$CFG_SBINDIR/$CFG_TARGET -l`)) {
+        print STDERR "apxs:Warning: No shared object support for Apache\n";
+        print STDERR "apxs:Warning: available under your platform. Make sure\n";
+        print STDERR "apxs:Warning: the Apache module mod_so is compiled into\n";
+        print STDERR "apxs:Warning: your server binary `$CFG_SBINDIR/$CFG_TARGET'.\n";
+        print STDERR "apxs:Warning: Continuing anyway...\n";
+    }
 }
 
 ##
@@ -409,9 +409,10 @@
     ##
 
     #   determine installation commands
-    #   and corresponding LoadModule/AddModule directives
+    #   and corresponding LoadModule/AddModule/Include directives
     my @lmd = ();
     my @amd = ();
+    my @inc = ();
     my @cmds = ();
     my $f;
     foreach $f (@args) {
@@ -468,11 +469,13 @@
         if ($filename eq '') {
             $filename = "mod_${name}.c";
         }
-        my $dir = $CFG_LIBEXECDIR;
-        $dir =~ s|^$CFG_PREFIX/?||;
-        $dir =~ s|(.)$|$1/|;
-        push(@lmd, sprintf("LoadModule %-18s %s", "${name}_module", "$dir$t"));
-        push(@amd, sprintf("AddModule %s", $filename));
+        my $modconfname = "addon-modules/mod_${name}.conf";
+        if (($opt_a or $opt_A) and ! -f "$CFG_SYSCONFDIR/$modconfname") {
+            push @cmds, "install -d -m755 $CFG_SYSCONFDIR/addon-modules";
+            push @cmds, "touch $CFG_SYSCONFDIR/$modconfname";
+        }
+        push(@lmd, sprintf("LoadModule %-18s %s", join("_", reverse(split("_", ${name}))) . "_module", "modules/$t")); push(@amd, sprintf("AddModule %s", $filename));
+        push(@inc, $modconfname);
     }
 
     #   activate module via LoadModule/AddModule directive
@@ -487,18 +490,38 @@
         my $content = join('', <FP>);
         close(FP);
 
-        if ($content !~ m|\n#?\s*LoadModule\s+|) {
+        my @inc_contents;
+        my $inc;
+        foreach $inc (@inc) {
+            if (open(FP, "<$CFG_SYSCONFDIR/$inc")) {
+                push @inc_contents, join('', <FP>);
+                close(FP);
+            }  
+            else { 
+                print STDERR "apxs:Warning: Could not open config file $CFG_SYSCONFDIR/$inc\n";
+                push @inc_contents, '';
+            }
+        }
+
+        my $total_content = $content . join('', @inc_contents);
+           
+        if ($total_content !~ m|^[\s#]*LoadModule\s|m) {
+
             print STDERR "apxs:Error: Activation failed for custom $cfgbase.conf file.\n";
             print STDERR "apxs:Error: At least one `LoadModule' directive already has to exist.\n";
             exit(1);
         }
 
+        my $what = $opt_A ? "preparing" : "activating";
+        my $i;
         my $lmd;
         my $c = '';
         $c = '#' if ($opt_A);
+        $i = 0;
         foreach $lmd (@lmd) {
-            my $what = $opt_A ? "preparing" : "activating";
-            if ($content !~ m|\n#?\s*$lmd|) {
+            my $lmd_pat = quotemeta($lmd);
+            $lmd_pat =~ s{(\\ )+}'\s+'g;
+            if ($total_content !~ m|^[ \t#]*$lmd_pat|m) {
                 # check for open <containers>, so that the new LoadModule
                 # directive always appears *outside* of an <container>.
 
@@ -561,14 +584,19 @@
                 }
             } else {
                 # replace already existing LoadModule line
-                $content =~ s|^(.*\n)#?\s*$lmd[^\n]*\n|$1$c$lmd\n|s;
+                $content =~ s|^[ \t#]*$lmd_pat[^\n]*$|$c$lmd|m
+                or $inc_contents[$i] =~ s|^[ \t#]*$lmd_pat[^\n]*$|$c$lmd|m;
             }
+            ++$i;
             $lmd =~ m|LoadModule\s+(.+?)_module.*|;
             print STDERR "[$what module `$1' in $cfgbase.conf]\n";
         }
         my $amd;
+        $i = 0;
         foreach $amd (@amd) {
-            if ($content !~ m|\n#?\s*$amd|) {
+            my $amd_pat = quotemeta($amd);
+            $amd_pat =~ s{(\\ )+}'\s+'g;
+            if ($total_content !~ m|^[ \t#]*$amd_pat|m) {
                 # check for open <containers> etc. see above for explanations.
 
                 my $before = ($content =~ m|^(.*\n)#?\s*AddModule\s+[^\n]+\n|s)[0];
@@ -596,7 +624,16 @@
                 }
             } else {
                 # replace already existing AddModule line
-                $content =~ s|^(.*\n)#?\s*$amd[^\n]*\n|$1$c$amd\n|s;
+                $content =~ s|^[ \t#]*$amd_pat[^\n]*$|$c$amd|m
+                or $inc_contents[$i] =~ s|^[ \t#]*$amd_pat[^\n]*$|$c$amd|m;
+            }
+            ++$i;
+        }
+        foreach $inc (@inc) {
+            if ($content !~ m|^[ \t#]*Include conf/\Q$inc\E|m) {
+                $content =~ s|\n?$|\n${c}Include conf/$inc\n|;
+            } else {
+                $content =~ s|^[ \t#]*(Include conf/\Q$inc\E)[^\n]*$|$c$1|m;
             }
         }
         if (@lmd or @amd) {
@@ -616,6 +653,19 @@
             } else {
                 print STDERR "apxs:Error: unable to open configuration file\n";
             }
+            $i = 0;
+            foreach $inc (@inc) {
+                if (open(FP, ">$CFG_SYSCONFDIR/$inc.new")) {
+                    print FP $inc_contents[$i];
+                    close(FP);
+                    system("cp -p $CFG_SYSCONFDIR/$inc $CFG_SYSCONFDIR/$inc.bak && " .
+                           "cat $CFG_SYSCONFDIR/$inc.new >$CFG_SYSCONFDIR/$inc && " .
+                           "rm -f $CFG_SYSCONFDIR/$inc.new");
+                } else {
+                    print STDERR "apxs:Error: unable to open module configuration file\n";
+                }
+                ++$i;
+            }
         }
     }
 
 
design & coding: Vladimir Lettiev aka crux © 2004-2005