| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# -*- perl -*- |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# $Id: Publish.pm,v 1.7 2004/06/10 13:18:02 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; |
|
18
|
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
3536
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
64
|
|
|
20
|
2
|
|
|
2
|
|
10
|
use vars qw($VERSION); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
200
|
|
|
21
|
|
|
|
|
|
|
$VERSION = sprintf("%d.%02d", q$Revision: 1.7 $ =~ /(\d+)\.(\d+)/); |
|
22
|
|
|
|
|
|
|
|
|
23
|
2
|
|
|
2
|
|
12
|
use File::Find; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
133
|
|
|
24
|
2
|
|
|
2
|
|
10
|
use File::Basename; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
128
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
2
|
|
|
2
|
|
602
|
use WE::Util::Functions qw(_save_pwd); |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
1798
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 NAME |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
WE_Frontend::Publish - common used variables |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
use WE_Frontend::Publish; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=over 4 |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=item cvs_exclude |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Return a list of exclude files for publish methods. This is the same as |
|
43
|
|
|
|
|
|
|
CVS is ignoring by default. |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=cut |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub cvs_exclude { |
|
48
|
2
|
|
|
2
|
1
|
44
|
[qw(RCS SCCS CVS CVS.adm RCSLOG .svn cvslog.* tags TAGS |
|
49
|
|
|
|
|
|
|
.make.state .nse_depinfo *~ *.old *.bak |
|
50
|
|
|
|
|
|
|
*.BAK *.orig *.rej .del-* *.a *.o *.obj *.so *.Z |
|
51
|
|
|
|
|
|
|
*.elc *.ln core), '#*', '.#*', ',*']; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# hmmm... I can't get the rdist regex right, so use only a minimal version |
|
55
|
|
|
|
|
|
|
# of cvs_exclude |
|
56
|
|
|
|
|
|
|
sub _min_cvs_exclude { |
|
57
|
0
|
|
|
0
|
|
0
|
[qw(RCS CVS .svn *~ *.old *.bak *.BAK *.orig)]; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item we_exclude |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Return a list of additional exclude files related to the web.editor |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=cut |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub we_exclude { |
|
67
|
2
|
|
|
2
|
1
|
10
|
[qw(.cvsignore cgi-bin/ we/)]; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item get_files_to_publish($frontend_object, %args) |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Return a list of files and directories to publish to the remote side. This |
|
73
|
|
|
|
|
|
|
is a static method. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=cut |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub get_files_to_publish { |
|
78
|
0
|
|
|
0
|
1
|
|
my($self, %args) = @_; |
|
79
|
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
|
my $since = delete $args{-since}; |
|
81
|
0
|
|
|
|
|
|
my $pubhtmldir = $self->Config->paths->pubhtmldir; |
|
82
|
0
|
|
|
|
|
|
my @extracgi = (ref $self->Config->project->stagingextracgi eq 'ARRAY' |
|
83
|
0
|
0
|
|
|
|
|
? @{ $self->Config->project->stagingextracgi } |
|
84
|
|
|
|
|
|
|
: () |
|
85
|
|
|
|
|
|
|
); |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my @cvs_exclude = @{ WE_Frontend::Publish->cvs_exclude }; |
|
|
0
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
my @we_exclude = @{ WE_Frontend::Publish->we_exclude }; |
|
|
0
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
my @directories; |
|
91
|
|
|
|
|
|
|
my @files; |
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
my @cgi_directories; |
|
94
|
0
|
|
|
|
|
|
my @cgi_files; |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $skip_file = sub { |
|
97
|
0
|
0
|
|
0
|
|
|
if (defined $since) { |
|
98
|
0
|
|
|
|
|
|
my(@s) = stat $_; |
|
99
|
0
|
0
|
|
|
|
|
if (!@s) { |
|
100
|
0
|
|
|
|
|
|
warn "Can't stat file $_: $!"; |
|
101
|
0
|
|
|
|
|
|
return 1; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
0
|
0
|
|
|
|
|
if ($s[9] <= $since) { # old file, don't publish |
|
104
|
0
|
|
|
|
|
|
return 1; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
} |
|
107
|
0
|
|
|
|
|
|
0; |
|
108
|
0
|
|
|
|
|
|
}; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
my $wanted = sub { |
|
111
|
0
|
0
|
0
|
0
|
|
|
return if $_ eq '.' || $_ eq '..'; |
|
112
|
0
|
|
|
|
|
|
foreach my $exc_ (@cvs_exclude, @we_exclude) { |
|
113
|
0
|
|
|
|
|
|
my $exc = $exc_; |
|
114
|
0
|
0
|
|
|
|
|
if ($_ eq $exc) { |
|
115
|
0
|
0
|
|
|
|
|
if (-d $_) { |
|
116
|
0
|
|
|
|
|
|
$File::Find::prune = 1; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
0
|
|
|
|
|
|
return; |
|
119
|
|
|
|
|
|
|
} |
|
120
|
0
|
|
|
|
|
|
$exc =~ s/\./\\./g; |
|
121
|
0
|
|
|
|
|
|
$exc =~ s/\*/.*/g; |
|
122
|
0
|
|
|
|
|
|
$exc =~ s|/$||; |
|
123
|
0
|
0
|
|
|
|
|
if ($_ =~ /^$exc$/) { |
|
124
|
0
|
0
|
|
|
|
|
if (-d $_) { |
|
125
|
0
|
|
|
|
|
|
$File::Find::prune = 1; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
0
|
|
|
|
|
|
return; |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
} |
|
130
|
0
|
|
|
|
|
|
(my $name = $File::Find::name) =~ s|^\./||; |
|
131
|
0
|
0
|
|
|
|
|
if (-d $_) { |
|
132
|
0
|
|
|
|
|
|
push @directories, $name; |
|
133
|
|
|
|
|
|
|
} else { |
|
134
|
|
|
|
|
|
|
|
|
135
|
0
|
0
|
|
|
|
|
return if $skip_file->($_); |
|
136
|
|
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
push @files, $name; |
|
138
|
|
|
|
|
|
|
} |
|
139
|
0
|
|
|
|
|
|
}; |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
_save_pwd { |
|
142
|
0
|
0
|
|
0
|
|
|
chdir $pubhtmldir || die $!; |
|
143
|
0
|
|
|
|
|
|
find($wanted, "."); |
|
144
|
|
|
|
|
|
|
|
|
145
|
0
|
0
|
|
|
|
|
push @directories, @{ $args{-adddirectories} } |
|
|
0
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
if $args{-adddirectories}; |
|
147
|
0
|
0
|
|
|
|
|
push @files, @{ $args{-addfiles} } |
|
|
0
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
if $args{-addfiles}; |
|
149
|
|
|
|
|
|
|
|
|
150
|
0
|
0
|
|
|
|
|
if (@extracgi) { |
|
151
|
0
|
|
|
|
|
|
foreach my $cgi (@extracgi) { |
|
152
|
0
|
|
|
|
|
|
my $f = "cgi-bin/$cgi"; |
|
153
|
0
|
|
|
|
|
|
my $dir = dirname($f); |
|
154
|
0
|
0
|
|
|
|
|
if (!$skip_file->($f)) { |
|
155
|
0
|
|
|
|
|
|
push @files, $f |
|
156
|
0
|
0
|
|
|
|
|
if (!grep { $f eq $_ } @files); |
|
157
|
|
|
|
|
|
|
} |
|
158
|
0
|
|
|
|
|
|
push @directories, $dir |
|
159
|
0
|
0
|
|
|
|
|
if (!grep { $dir eq $_ } @directories); |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
# to make sure that parent directories are always created before |
|
164
|
|
|
|
|
|
|
# the children directories |
|
165
|
0
|
|
|
|
|
|
@directories = sort { length($a) <=> length($b) } @directories; |
|
|
0
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
}; |
|
167
|
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
return {Directories => \@directories, |
|
169
|
|
|
|
|
|
|
Files => \@files, |
|
170
|
|
|
|
|
|
|
}; |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
1; |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
__END__ |