| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
############################################################################ |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# Apache::Voodoo::Install - Base package for Apache::Voodoo::Install::* objects. |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# This package provides some basic common methods needed by all the "real work" |
|
6
|
|
|
|
|
|
|
# Apache::Voodoo::Install::* objects. |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
########################################################################### |
|
9
|
|
|
|
|
|
|
package Apache::Voodoo::Install; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$VERSION = "3.0200"; |
|
12
|
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
2051
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
42
|
|
|
14
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
44
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
5
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1222
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
################################################################################ |
|
19
|
|
|
|
|
|
|
# Sets / unsets the 'pretend' run mode |
|
20
|
|
|
|
|
|
|
################################################################################ |
|
21
|
|
|
|
|
|
|
sub pretend { |
|
22
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
23
|
0
|
|
|
|
|
|
$self->{'pretend'} = shift; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _printer { |
|
27
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
28
|
0
|
|
|
|
|
|
my $level = shift; |
|
29
|
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
if ($self->{'verbose'} >= $level) { |
|
31
|
0
|
|
|
|
|
|
foreach (@_) { |
|
32
|
0
|
0
|
|
|
|
|
if (ref($_)) { |
|
33
|
0
|
|
|
|
|
|
print Dumper $_; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
else { |
|
36
|
0
|
|
|
|
|
|
print $_,"\n"; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub mesg { |
|
43
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
44
|
0
|
|
|
|
|
|
$self->_printer(0,@_); |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub info { |
|
48
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
49
|
0
|
|
|
|
|
|
$self->_printer(1,@_); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub debug { |
|
53
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
54
|
0
|
|
|
|
|
|
$self->_printer(2,@_); |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub make_symlink { |
|
59
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
60
|
0
|
|
|
|
|
|
my $source = shift; |
|
61
|
0
|
|
|
|
|
|
my $target = shift; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $pretend = $self->{'pretend'}; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$self->info("- Checking symlink $target"); |
|
66
|
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
lstat($target); |
|
68
|
0
|
0
|
0
|
|
|
|
if (-e _ && -l _ ) { |
|
69
|
|
|
|
|
|
|
# it's there and it's a link, let's make sure it points to the correct place. |
|
70
|
0
|
|
|
|
|
|
my @ss = stat($target); |
|
71
|
0
|
|
|
|
|
|
my @ts = stat($source); |
|
72
|
0
|
0
|
|
|
|
|
if ($ss[1] != $ts[1]) { |
|
73
|
|
|
|
|
|
|
# inode's are different. |
|
74
|
0
|
0
|
0
|
|
|
|
$pretend || unlink($target) || $self->{ignore} || die "Can't remove bogus link: $!"; |
|
|
|
|
0
|
|
|
|
|
|
75
|
0
|
0
|
0
|
|
|
|
$pretend || symlink($source,$target) || $self->{ignore} || die "Can't create symlink: $!"; |
|
|
|
|
0
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
$self->debug(": invalid, fixed"); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
else { |
|
79
|
0
|
|
|
|
|
|
$self->debug(": ok"); |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
else { |
|
83
|
|
|
|
|
|
|
# not there, or not a link. |
|
84
|
|
|
|
|
|
|
# make sure the path is valid |
|
85
|
0
|
|
|
|
|
|
my $p; |
|
86
|
0
|
|
|
|
|
|
my @p = split('/',$target); |
|
87
|
0
|
|
|
|
|
|
pop @p; # throw away filename |
|
88
|
0
|
|
|
|
|
|
foreach my $d (@p) { |
|
89
|
0
|
|
|
|
|
|
$p .= '/'.$d; |
|
90
|
0
|
0
|
0
|
|
|
|
unless (-e $p && -d $p) { |
|
91
|
0
|
0
|
0
|
|
|
|
$pretend || mkdir ($p,0755) || $self->{ignore} || die "Can't create directory: $!"; |
|
|
|
|
0
|
|
|
|
|
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
0
|
0
|
|
|
|
|
$pretend || unlink($target); # in case it was there. |
|
96
|
|
|
|
|
|
|
|
|
97
|
0
|
0
|
0
|
|
|
|
$pretend || symlink($source,$target) || $self->{ignore} || die "Can't create symlink: $!"; |
|
|
|
|
0
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
$self->debug(": missing, created"); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub make_writeable_dirs { |
|
103
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
104
|
0
|
|
|
|
|
|
my @dirs = shift; |
|
105
|
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
my $pretend = $self->{'pretend'}; |
|
107
|
0
|
|
|
|
|
|
my $uid = $self->{'apache_uid'}; |
|
108
|
0
|
|
|
|
|
|
my $gid = $self->{'apache_gid'}; |
|
109
|
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
foreach my $dir (@dirs) { |
|
111
|
0
|
|
|
|
|
|
$self->info("- Checking directory $dir"); |
|
112
|
0
|
|
|
|
|
|
stat($dir); |
|
113
|
0
|
0
|
0
|
|
|
|
if (-e _ && -d _ ) { |
|
114
|
0
|
|
|
|
|
|
$self->debug(": ok"); |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
else { |
|
117
|
0
|
0
|
0
|
|
|
|
$pretend || mkdir($dir,770) || $self->{ignore} || die "Can't create directory $dir: $!"; |
|
|
|
|
0
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
$self->debug(": created"); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
0
|
|
|
|
|
|
$self->info("- Making sure the $dir directory is writable by apache"); |
|
121
|
0
|
0
|
0
|
|
|
|
$pretend || chown($uid,$gid,$dir) || $self->{ignore} || die "Can't chown directory: $!"; |
|
|
|
|
0
|
|
|
|
|
|
122
|
0
|
0
|
0
|
|
|
|
$pretend || chmod(0770,$dir) || $self->{ignore} || die "Can't chmod directory: $!"; |
|
|
|
|
0
|
|
|
|
|
|
123
|
0
|
|
|
|
|
|
$self->debug(": ok"); |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub make_writeable_files { |
|
128
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
129
|
0
|
|
|
|
|
|
my @files = shift; |
|
130
|
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
my $pretend = $self->{'pretend'}; |
|
132
|
0
|
|
|
|
|
|
my $uid = $self->{'apache_uid'}; |
|
133
|
0
|
|
|
|
|
|
my $gid = $self->{'apache_gid'}; |
|
134
|
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
foreach my $file (@files) { |
|
136
|
0
|
|
|
|
|
|
$self->info("- Checking file $file"); |
|
137
|
0
|
0
|
|
|
|
|
if (-e $file) { |
|
138
|
0
|
|
|
|
|
|
$self->debug(": ok"); |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
else { |
|
141
|
0
|
0
|
0
|
|
|
|
$pretend || (system("touch $file") && ($self->{ignore} || die "Can't create file: $!")); |
|
|
|
|
0
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
$self->debug(": created"); |
|
143
|
|
|
|
|
|
|
} |
|
144
|
0
|
|
|
|
|
|
$self->info("- Making sure the $file directory is writable by apache"); |
|
145
|
0
|
0
|
0
|
|
|
|
$pretend || chown($uid,$gid,$file) || $self->{ignore} || die "Can't chown file: $!"; |
|
|
|
|
0
|
|
|
|
|
|
146
|
0
|
0
|
0
|
|
|
|
$pretend || chmod(0600,$file) || $self->{ignore} || die "Can't chmod file: $!"; |
|
|
|
|
0
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
$self->debug(": ok"); |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# In a pine box somewhere De Morgan is either spinning violently, or applauding. We're not |
|
152
|
|
|
|
|
|
|
# sure which. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
1; |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
################################################################################ |
|
157
|
|
|
|
|
|
|
# Copyright (c) 2005-2010 Steven Edwards (maverick@smurfbane.org). |
|
158
|
|
|
|
|
|
|
# All rights reserved. |
|
159
|
|
|
|
|
|
|
# |
|
160
|
|
|
|
|
|
|
# You may use and distribute Apache::Voodoo under the terms described in the |
|
161
|
|
|
|
|
|
|
# LICENSE file include in this package. The summary is it's a legalese version |
|
162
|
|
|
|
|
|
|
# of the Artistic License :) |
|
163
|
|
|
|
|
|
|
# |
|
164
|
|
|
|
|
|
|
################################################################################ |