| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# -*- perl -*- |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# $Id: Rdist.pm,v 1.8 2004/03/08 10:44:59 eserte Exp $ |
|
5
|
|
|
|
|
|
|
# Author: Slaven Rezic |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# Copyright (C) 2002 Online Office Berlin. All rights reserved. |
|
8
|
|
|
|
|
|
|
# Copyright (C) 2002 Slaven Rezic. |
|
9
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under the |
|
10
|
|
|
|
|
|
|
# terms of the GNU General Public License, see the file COPYING. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# |
|
13
|
|
|
|
|
|
|
# Mail: slaven@rezic.de |
|
14
|
|
|
|
|
|
|
# WWW: http://we-framework.sourceforge.net |
|
15
|
|
|
|
|
|
|
# |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
package WE_Frontend::Publish::Rdist; |
|
18
|
|
|
|
|
|
|
|
|
19
|
1
|
|
|
1
|
|
855
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
77
|
|
|
20
|
|
|
|
|
|
|
$VERSION = sprintf("%d.%02d", q$Revision: 1.8 $ =~ /(\d+)\.(\d+)/); |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
package WE_Frontend::Main; |
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
23
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
4
|
use WE_Frontend::Publish; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
21
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
4
|
use File::Basename; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
2245
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub publish_rdist { |
|
31
|
0
|
|
|
0
|
|
|
my($self, %args) = @_; |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $do_exec = !delete $args{-n}; |
|
34
|
0
|
|
|
|
|
|
my $v = delete $args{-verbose}; |
|
35
|
0
|
|
|
|
|
|
my $since = delete $args{-since}; |
|
36
|
0
|
0
|
|
|
|
|
if (defined $since) { |
|
37
|
0
|
|
|
|
|
|
warn "The -since option is ignored with publish_rdist!"; |
|
38
|
|
|
|
|
|
|
} |
|
39
|
0
|
|
|
|
|
|
my $liveuser = $self->Config->staging->user; |
|
40
|
0
|
0
|
|
|
|
|
if ($liveuser eq '') { |
|
41
|
0
|
|
|
|
|
|
undef $liveuser; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
0
|
|
|
|
|
|
my $livedirectory = $self->Config->staging->directory; |
|
44
|
0
|
|
|
|
|
|
my $livecgidirectory = $self->Config->staging->cgidirectory; |
|
45
|
0
|
|
|
|
|
|
my $livehost = $self->Config->staging->host; |
|
46
|
0
|
0
|
0
|
|
|
|
if (!defined $livehost || $livehost eq '') { |
|
47
|
0
|
|
|
|
|
|
$livehost = "localhost"; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
0
|
|
|
|
|
|
my $pubhtmldir = $self->Config->paths->pubhtmldir; |
|
50
|
0
|
|
|
|
|
|
my $cgidir = $self->Config->paths->cgidir; |
|
51
|
0
|
|
|
|
|
|
my @extracgi = (ref $self->Config->project->stagingextracgi eq 'ARRAY' |
|
52
|
0
|
0
|
|
|
|
|
? @{ $self->Config->project->stagingextracgi } |
|
53
|
|
|
|
|
|
|
: () |
|
54
|
|
|
|
|
|
|
); |
|
55
|
0
|
0
|
0
|
|
|
|
my $distfile = ($self->Config->staging->stagingext && |
|
56
|
|
|
|
|
|
|
$self->Config->staging->stagingext->{'distfile'} |
|
57
|
|
|
|
|
|
|
? $self->Config->staging->stagingext->{'distfile'} |
|
58
|
|
|
|
|
|
|
: undef); |
|
59
|
0
|
|
|
|
|
|
my @extra_args; |
|
60
|
0
|
0
|
|
|
|
|
if (exists $args{-transport}) { |
|
61
|
0
|
|
|
|
|
|
my $exec = is_in_path($args{-transport}); |
|
62
|
0
|
0
|
|
|
|
|
if (!defined $exec) { |
|
63
|
0
|
|
|
|
|
|
die "Cannot find executable for $args{-transport} in $ENV{PATH}"; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
0
|
|
|
|
|
|
push @extra_args, "-P", $exec; |
|
66
|
0
|
|
|
|
|
|
delete $args{-transport}; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
0
|
0
|
0
|
|
|
|
my $deleteold = ($self->Config->staging->stagingext && |
|
69
|
|
|
|
|
|
|
$self->Config->staging->stagingext->{'deleteold'} |
|
70
|
|
|
|
|
|
|
? $self->Config->staging->stagingext->{'deleteold'} |
|
71
|
|
|
|
|
|
|
: 0); |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
if (!defined $distfile) { |
|
74
|
0
|
0
|
|
|
|
|
if (!defined $livedirectory) { |
|
75
|
0
|
|
|
|
|
|
die "\$livedirectory is not defined"; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
0
|
0
|
0
|
|
|
|
if (!defined $pubhtmldir || $pubhtmldir eq '') { |
|
78
|
0
|
|
|
|
|
|
die "The publish html directory is missing (config member WEsiteinfo->paths->pubhtmldir)"; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
0
|
0
|
0
|
|
|
|
if (@extracgi && (!defined $livecgidirectory || $livecgidirectory eq '')) { |
|
|
|
|
0
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
die "Extra CGI scripts are defined (@extracgi), |
|
82
|
|
|
|
|
|
|
but the WEsiteinfo->staging->cgidirectory config is missing"; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# XXX same as in Rsync.pm |
|
87
|
0
|
|
|
|
|
|
my @cvs_exclude_pat = @{ WE_Frontend::Publish->_min_cvs_exclude }; # XXX! |
|
|
0
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
my @we_exclude_pat = @{ WE_Frontend::Publish->we_exclude }; |
|
|
0
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
my @exclude_pat = (@cvs_exclude_pat, @we_exclude_pat); |
|
90
|
0
|
|
|
|
|
|
my @exclude; |
|
91
|
|
|
|
|
|
|
my %additional; |
|
92
|
0
|
0
|
|
|
|
|
if ($self->Config->project->stagingexceptpat) { |
|
93
|
0
|
|
|
|
|
|
push @exclude_pat, @{ $self->Config->project->stagingexceptpat }; |
|
|
0
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} |
|
95
|
0
|
0
|
|
|
|
|
if ($self->Config->project->stagingexcept) { |
|
96
|
0
|
|
|
|
|
|
push @exclude, @{ $self->Config->project->stagingexcept }; |
|
|
0
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
} |
|
98
|
0
|
0
|
|
|
|
|
if ($self->Config->project->stagingadditional) { |
|
99
|
0
|
|
|
|
|
|
%additional = %{ $self->Config->project->stagingadditional }; |
|
|
0
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
0
|
0
|
|
|
|
|
if ($v) { |
|
103
|
0
|
|
|
|
|
|
print <
|
|
104
|
|
|
|
|
|
|
Using rdist. |
|
105
|
0
|
0
|
|
|
|
|
Rdist remote host: $livehost |
|
106
|
|
|
|
|
|
|
Rdist remote user: @{[ defined $liveuser ? $liveuser : "current" ]} |
|
107
|
|
|
|
|
|
|
Rdist remote directory: $livedirectory |
|
108
|
|
|
|
|
|
|
EOF |
|
109
|
0
|
0
|
|
|
|
|
if (@extracgi) { |
|
110
|
0
|
|
|
|
|
|
print "Rdist remote CGI directory: $livecgidirectory\n"; |
|
111
|
|
|
|
|
|
|
} |
|
112
|
0
|
0
|
|
|
|
|
print ($deleteold ? "Delete unused remote files\n" : "Leave unused remote files\n"); |
|
113
|
0
|
0
|
|
|
|
|
if (@exclude) { |
|
114
|
0
|
|
|
|
|
|
print "Exclude files: @exclude\n"; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
0
|
0
|
|
|
|
|
if (@exclude_pat) { |
|
117
|
0
|
|
|
|
|
|
print "Exclude patterns: @exclude_pat\n"; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
0
|
0
|
|
|
|
|
if (%additional) { |
|
120
|
0
|
|
|
|
|
|
print "Additional files: ", |
|
121
|
0
|
|
|
|
|
|
join(", ", map { "$_ => $additional{$_}" } keys %additional), |
|
122
|
|
|
|
|
|
|
"\n"; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
0
|
|
|
|
|
|
print "\n"; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
0
|
0
|
|
|
|
|
my $dest = (defined $liveuser ? "$liveuser\@" : "") . $livehost; |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
my @directories; |
|
130
|
|
|
|
|
|
|
my @files; |
|
131
|
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
my $diststring; |
|
133
|
0
|
|
|
|
|
|
my @additional_cmd; |
|
134
|
0
|
0
|
|
|
|
|
if (!$distfile) { |
|
135
|
0
|
|
|
|
|
|
$distfile = "-"; |
|
136
|
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
my $exclude_pat_string = ""; |
|
138
|
0
|
|
|
|
|
|
my $exclude_string = ""; |
|
139
|
0
|
|
|
|
|
|
my @additional_install_string = (); |
|
140
|
|
|
|
|
|
|
|
|
141
|
0
|
0
|
|
|
|
|
if (@exclude_pat) { |
|
142
|
0
|
|
|
|
|
|
$exclude_pat_string = "\texcept_pat (" . |
|
143
|
0
|
|
|
|
|
|
join("\n", map { "\t\t " . glob2rx($_) } @exclude_pat) . |
|
144
|
|
|
|
|
|
|
"\n\t\t );\n"; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
0
|
0
|
|
|
|
|
if (@exclude) { |
|
147
|
0
|
|
|
|
|
|
$exclude_string = "\texcept (" . |
|
148
|
0
|
|
|
|
|
|
join("\n", map { "\t\t " . "$pubhtmldir/$_" } @exclude) . |
|
149
|
|
|
|
|
|
|
"\n\t\t );\n"; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
0
|
0
|
|
|
|
|
if (%additional) { |
|
152
|
0
|
|
|
|
|
|
my $i = 1; |
|
153
|
0
|
|
|
|
|
|
while(my($k, $v) = each %additional) { |
|
154
|
0
|
|
|
|
|
|
my $label = "additional$i"; |
|
155
|
0
|
|
|
|
|
|
push @additional_cmd, $label; |
|
156
|
0
|
|
|
|
|
|
push @additional_install_string, <
|
|
157
|
|
|
|
|
|
|
$label: |
|
158
|
|
|
|
|
|
|
$pubhtmldir/$k -> $dest |
|
159
|
|
|
|
|
|
|
install ${livedirectory}/$v ; |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
EOF |
|
162
|
0
|
|
|
|
|
|
$i++; |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
# dump rdist bug? There have to be more than one file! |
|
167
|
0
|
0
|
|
|
|
|
if (@extracgi == 1) { |
|
168
|
0
|
|
|
|
|
|
push @extracgi, @extracgi; |
|
169
|
|
|
|
|
|
|
} |
|
170
|
|
|
|
|
|
|
|
|
171
|
0
|
|
|
|
|
|
my $cgi_files = join(" ", map { "$cgidir/$_" } @extracgi); |
|
|
0
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
|
$diststring = <
|
|
174
|
|
|
|
|
|
|
# distfile for publishing edit to www |
|
175
|
|
|
|
|
|
|
|
|
176
|
0
|
|
|
|
|
|
HTDOCS = ( $pubhtmldir ) |
|
177
|
|
|
|
|
|
|
CGIFILES = ( $cgi_files ) |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# |
|
180
|
|
|
|
|
|
|
# htdocs |
|
181
|
|
|
|
|
|
|
# |
|
182
|
|
|
|
|
|
|
htdocs: |
|
183
|
|
|
|
|
|
|
\${HTDOCS} -> $dest |
|
184
|
|
|
|
|
|
|
install ${livedirectory} ; |
|
185
|
|
|
|
|
|
|
$exclude_pat_string |
|
186
|
|
|
|
|
|
|
$exclude_string |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
@{[ join("\n", @additional_install_string) ]} |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# |
|
191
|
|
|
|
|
|
|
# cgi-bin |
|
192
|
|
|
|
|
|
|
# |
|
193
|
|
|
|
|
|
|
cgi: |
|
194
|
|
|
|
|
|
|
\${CGIFILES} -> $dest |
|
195
|
|
|
|
|
|
|
install ${livecgidirectory} ; |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
EOF |
|
198
|
|
|
|
|
|
|
|
|
199
|
0
|
0
|
|
|
|
|
if ($v) { |
|
200
|
0
|
|
|
|
|
|
my $line = 1; |
|
201
|
0
|
|
|
|
|
|
warn join("\n", map { $line++." ".$_} split /\n/, $diststring); |
|
|
0
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
} |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
|
|
205
|
0
|
|
|
|
|
|
my $cmd = "rdist -f $distfile"; |
|
206
|
0
|
0
|
|
|
|
|
if (!$do_exec) { |
|
207
|
0
|
|
|
|
|
|
$cmd .= " -n"; |
|
208
|
|
|
|
|
|
|
} |
|
209
|
0
|
0
|
|
|
|
|
if ($deleteold) { |
|
210
|
0
|
|
|
|
|
|
$cmd .= " -oremove"; |
|
211
|
|
|
|
|
|
|
} |
|
212
|
|
|
|
|
|
|
|
|
213
|
0
|
|
|
|
|
|
$cmd .= " " . join(" ", qw(htdocs cgi), @additional_cmd); |
|
214
|
|
|
|
|
|
|
|
|
215
|
0
|
0
|
|
|
|
|
if ($distfile eq '-') { |
|
216
|
0
|
0
|
|
|
|
|
warn $cmd if $v; |
|
217
|
0
|
0
|
|
|
|
|
open(RDIST, "| $cmd") or die $!; |
|
218
|
0
|
|
|
|
|
|
print RDIST $diststring; |
|
219
|
0
|
|
|
|
|
|
close RDIST; |
|
220
|
|
|
|
|
|
|
} else { |
|
221
|
0
|
|
|
|
|
|
system($cmd); |
|
222
|
0
|
0
|
|
|
|
|
die "Error while executing $cmd" if $?/256!=0; |
|
223
|
|
|
|
|
|
|
} |
|
224
|
|
|
|
|
|
|
|
|
225
|
0
|
|
|
|
|
|
return; |
|
226
|
|
|
|
|
|
|
} |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
sub glob2rx { |
|
229
|
0
|
|
|
0
|
|
|
my $glob = shift; |
|
230
|
0
|
|
|
|
|
|
my %glob2rx = ("*" => ".*", |
|
231
|
|
|
|
|
|
|
"." => "\\.", |
|
232
|
|
|
|
|
|
|
"#" => "\\#", |
|
233
|
|
|
|
|
|
|
); # XXX more to follow |
|
234
|
0
|
|
|
|
|
|
$glob =~ s/([\.\*\#])/$glob2rx{$1}/g; |
|
235
|
0
|
|
|
|
|
|
$glob = ".*/" . $glob . ".*"; |
|
236
|
0
|
|
|
|
|
|
$glob =~ s/\Q.*.*/.*/g; |
|
237
|
0
|
|
|
|
|
|
$glob; |
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
# REPO BEGIN |
|
241
|
|
|
|
|
|
|
# REPO NAME is_in_path /home/e/eserte/src/repository |
|
242
|
|
|
|
|
|
|
# REPO MD5 1aa226739da7a8178372aa9520d85589 |
|
243
|
|
|
|
|
|
|
sub is_in_path { |
|
244
|
0
|
|
|
0
|
|
|
my($prog) = @_; |
|
245
|
0
|
0
|
0
|
|
|
|
return $prog if (file_name_is_absolute($prog) and -x $prog); |
|
246
|
0
|
|
|
|
|
|
require Config; |
|
247
|
0
|
|
0
|
|
|
|
my $sep = $Config::Config{'path_sep'} || ':'; |
|
248
|
0
|
|
|
|
|
|
foreach (split(/$sep/o, $ENV{PATH})) { |
|
249
|
0
|
0
|
|
|
|
|
return "$_/$prog" if -x "$_/$prog"; |
|
250
|
|
|
|
|
|
|
} |
|
251
|
0
|
|
|
|
|
|
undef; |
|
252
|
|
|
|
|
|
|
} |
|
253
|
|
|
|
|
|
|
# REPO END |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
# REPO BEGIN |
|
256
|
|
|
|
|
|
|
# REPO NAME file_name_is_absolute /home/e/eserte/src/repository |
|
257
|
|
|
|
|
|
|
# REPO MD5 a77759517bc00f13c52bb91d861d07d0 |
|
258
|
|
|
|
|
|
|
sub file_name_is_absolute { |
|
259
|
0
|
|
|
0
|
|
|
my $file = shift; |
|
260
|
0
|
|
|
|
|
|
my $r; |
|
261
|
0
|
|
|
|
|
|
eval { |
|
262
|
0
|
|
|
|
|
|
require File::Spec; |
|
263
|
0
|
|
|
|
|
|
$r = File::Spec->file_name_is_absolute($file); |
|
264
|
|
|
|
|
|
|
}; |
|
265
|
0
|
0
|
|
|
|
|
if ($@) { |
|
266
|
0
|
0
|
|
|
|
|
if ($^O eq 'MSWin32') { |
|
267
|
0
|
|
|
|
|
|
$r = ($file =~ m;^([a-z]:(/|\\)|\\\\|//);i); |
|
268
|
|
|
|
|
|
|
} else { |
|
269
|
0
|
|
|
|
|
|
$r = ($file =~ m|^/|); |
|
270
|
|
|
|
|
|
|
} |
|
271
|
|
|
|
|
|
|
} |
|
272
|
0
|
|
|
|
|
|
$r; |
|
273
|
|
|
|
|
|
|
} |
|
274
|
|
|
|
|
|
|
# REPO END |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
1; |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
__END__ |