1 |
joko |
1.1 |
package ConfigPatcher::Main; |
2 |
|
|
|
3 |
|
|
require Exporter; |
4 |
|
|
@ISA = qw(Exporter); |
5 |
|
|
|
6 |
|
|
@EXPORT = qw(preparePatches); |
7 |
|
|
|
8 |
|
|
use strict; |
9 |
|
|
use warnings; |
10 |
|
|
|
11 |
|
|
my %vhost; |
12 |
|
|
|
13 |
|
|
use ConfigPatcher::Config; |
14 |
|
|
use ConfigPatcher::Handlers; |
15 |
|
|
|
16 |
|
|
sub preparePatches { |
17 |
|
|
my $patchfile = shift; |
18 |
|
|
my $patchTarget = shift; |
19 |
|
|
ConfigPatcher::Config::readConfig($patchfile); |
20 |
|
|
my %cfg_patcher = %ConfigPatcher::Config::cfg_patcher; |
21 |
|
|
|
22 |
|
|
my @files = keys %cfg_patcher; |
23 |
|
|
foreach my $file (@files) { |
24 |
|
|
my $handler = $cfg_patcher{$file}; |
25 |
|
|
my $pt = $patchTarget . $file; |
26 |
|
|
print "\n", "patching file \"$pt\" ..."; |
27 |
|
|
#print "patching file by "; |
28 |
|
|
my $eval = "ConfigPatcher::Handlers::$handler('$pt');"; |
29 |
|
|
#print "executing handler $eval ..."; |
30 |
|
|
my $res = eval($eval); |
31 |
|
|
# error in eval? |
32 |
|
|
if ($@ || !$res) { |
33 |
|
|
print "failed: $@"; |
34 |
|
|
} else { |
35 |
|
|
print "ok"; |
36 |
|
|
} |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
} |
40 |
|
|
|
41 |
|
|
1; |
42 |
|
|
|