line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- perl -*- |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# $Id: CustomPublish.pm,v 1.3 2004/06/07 06:58:55 eserte Exp $ |
5
|
|
|
|
|
|
|
# Author: Slaven Rezic |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Copyright (C) 2004 Slaven Rezic. All rights reserved. |
8
|
|
|
|
|
|
|
# |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package WebEditor::OldFeatures::CustomPublish; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# This serves as a template for custom rsync-based publishing. |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
1139
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
39
|
|
15
|
1
|
|
|
1
|
|
6
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
85
|
|
16
|
|
|
|
|
|
|
$VERSION = sprintf("%d.%02d", q$Revision: 1.3 $ =~ /(\d+)\.(\d+)/); |
17
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
6
|
use mixin::with 'WebEditor::OldController'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
BEGIN { |
21
|
1
|
50
|
|
1
|
|
277
|
if ($] < 5.006) { |
22
|
0
|
|
|
|
|
0
|
$INC{"warnings.pm"}++; |
23
|
0
|
|
|
|
|
0
|
eval q{ |
24
|
|
|
|
|
|
|
package warnings; |
25
|
|
|
|
|
|
|
sub unimport { } |
26
|
0
|
0
|
|
|
|
0
|
}; die $@ if $@; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub do_publish { |
31
|
0
|
|
|
0
|
0
|
|
my($self, %args) = @_; |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
require File::Basename; |
34
|
0
|
|
|
|
|
|
require File::Spec; |
35
|
0
|
|
|
|
|
|
require File::Find; |
36
|
0
|
|
|
|
|
|
require File::Temp; |
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
1
|
|
5
|
no warnings; # # in qw() |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
695
|
|
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
my $c = $self->C; |
41
|
0
|
|
0
|
|
|
|
my $v = delete $args{-verbose} || 0; |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
my @files; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $rootdir = $c->paths->uprootdir; |
46
|
0
|
|
|
|
|
|
my $projectname = $c->project->name; |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $dbg = 1; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# Can't use "follow => 1", because this will skip files if they |
51
|
|
|
|
|
|
|
# are already listed though their symlink. However, the semantics of |
52
|
|
|
|
|
|
|
# follow_fast is not totally clear. |
53
|
|
|
|
|
|
|
File::Find::find({follow_fast => 1, # needed for common/perl |
54
|
|
|
|
|
|
|
follow_skip => 2, # do not die on duplicates |
55
|
|
|
|
|
|
|
wanted => sub { |
56
|
0
|
0
|
|
0
|
|
|
$File::Find::prune = 1, return if $_ =~ m{^( core\..* |
57
|
|
|
|
|
|
|
| \.core |
58
|
|
|
|
|
|
|
| \#.* |
59
|
|
|
|
|
|
|
| \.\#.* |
60
|
|
|
|
|
|
|
| ,.* |
61
|
|
|
|
|
|
|
| \.cvsignore |
62
|
|
|
|
|
|
|
| \.AppleDouble |
63
|
|
|
|
|
|
|
| .*\.bak |
64
|
|
|
|
|
|
|
| .*~ |
65
|
|
|
|
|
|
|
)$}x; |
66
|
0
|
0
|
|
|
|
|
return if -d $_; |
67
|
0
|
|
|
|
|
|
my $path = substr($File::Find::name, length($rootdir)+1); |
68
|
0
|
0
|
|
|
|
|
print STDERR "$path " if $dbg; |
69
|
0
|
0
|
|
|
|
|
do { |
70
|
0
|
|
|
|
|
|
$File::Find::prune = 1; |
71
|
0
|
|
|
|
|
|
goto CLEANUP; |
72
|
|
|
|
|
|
|
} if $path !~ m{^( cgi-bin/ |
73
|
|
|
|
|
|
|
| etc/ |
74
|
|
|
|
|
|
|
| lib/ |
75
|
|
|
|
|
|
|
| htdocs/ |
76
|
|
|
|
|
|
|
| we_data/ |
77
|
|
|
|
|
|
|
| conf/ |
78
|
|
|
|
|
|
|
| common/ |
79
|
|
|
|
|
|
|
)}x; |
80
|
0
|
0
|
|
|
|
|
print STDERR "1" if $dbg; |
81
|
0
|
0
|
|
|
|
|
goto CLEANUP if $path =~ m{( ^htdocs/index\.html$ |
82
|
|
|
|
|
|
|
| ^cgi-bin/we_redisys\.cgi$ |
83
|
|
|
|
|
|
|
| ^cgi-bin/WEsiteinfo_$projectname\.pm$ |
84
|
|
|
|
|
|
|
| ^cgi-bin/WEsiteinfo\.pm$ |
85
|
|
|
|
|
|
|
)}x; |
86
|
0
|
0
|
|
|
|
|
print STDERR "2" if $dbg; |
87
|
0
|
0
|
0
|
|
|
|
goto CLEANUP if ($path =~ m{^htdocs/we/} && |
88
|
|
|
|
|
|
|
$path !~ m{^htdocs/we/${projectname}_templates/search_result}); |
89
|
0
|
0
|
|
|
|
|
print STDERR "3" if $dbg; |
90
|
0
|
0
|
0
|
|
|
|
goto CLEANUP if ($path =~ m{^we_data/} && |
91
|
|
|
|
|
|
|
$path !~ m{^we_data/[^/]+\.db}); |
92
|
0
|
0
|
|
|
|
|
print STDERR "4" if $dbg; |
93
|
0
|
0
|
0
|
|
|
|
goto CLEANUP if ($path =~ m{^conf/} && |
94
|
|
|
|
|
|
|
$path !~ m{^conf/htdig\.tpl\.conf$}); |
95
|
0
|
0
|
|
|
|
|
print STDERR "5" if $dbg; |
96
|
0
|
0
|
0
|
|
|
|
goto CLEANUP if ($path =~ m{^etc/} && |
97
|
|
|
|
|
|
|
$path !~ m{^etc/run_indexer$}); |
98
|
0
|
0
|
|
|
|
|
print STDERR "6" if $dbg; |
99
|
0
|
|
|
|
|
|
push @files, $path; |
100
|
0
|
0
|
|
|
|
|
CLEANUP: |
101
|
|
|
|
|
|
|
print STDERR "\n" if $dbg; |
102
|
0
|
|
|
|
|
|
}}, $rootdir); |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
my %dir; |
105
|
0
|
|
|
|
|
|
for my $f (@files) { |
106
|
0
|
|
|
|
|
|
my @dirs = File::Spec->splitdir($f); |
107
|
0
|
|
|
|
|
|
pop @dirs; |
108
|
0
|
|
|
|
|
|
for my $d_i (0 .. $#dirs) { |
109
|
0
|
|
|
|
|
|
$dir{ File::Spec->catdir(@dirs[0 .. $d_i]) }++; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
my($fh, $file) = File::Temp::tempfile(SUFFIX => ".rsync.txt", |
114
|
|
|
|
|
|
|
#UNLINK => 1, |
115
|
|
|
|
|
|
|
); |
116
|
0
|
|
|
|
|
|
print $fh join("\n", map { "/$_" } sort (keys(%dir), @files)), "\n"; |
|
0
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
local $ENV{PATH} = "$ENV{PATH}:/usr/bin:/usr/local/bin"; |
119
|
1
|
|
|
1
|
|
5
|
no warnings 'qw'; # no perl 5.00503 compat here |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
305
|
|
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
my @common_rsync_args = |
122
|
|
|
|
|
|
|
(qw(rsync -rptgoD -vz --copy-unsafe-links), |
123
|
|
|
|
|
|
|
"-e", "ssh", |
124
|
|
|
|
|
|
|
); |
125
|
0
|
|
|
|
|
|
my @common_exc = |
126
|
|
|
|
|
|
|
qw(--cvs-exclude |
127
|
|
|
|
|
|
|
--exclude core --exclude #* --exclude .#* |
128
|
|
|
|
|
|
|
--exclude ,* --exclude .cvsignore |
129
|
|
|
|
|
|
|
--exclude .AppleDouble/); |
130
|
0
|
|
|
|
|
|
my @cmds = |
131
|
|
|
|
|
|
|
( |
132
|
|
|
|
|
|
|
{label => "HTML-Seiten, CGI-Skripte, Perl-Libraries, Datenbank, htdig-conf", |
133
|
|
|
|
|
|
|
cmd => [@common_rsync_args, @common_exc, |
134
|
|
|
|
|
|
|
("--include-from=$file", "--exclude=**"), |
135
|
|
|
|
|
|
|
$c->paths->uprootdir . "/", |
136
|
|
|
|
|
|
|
$c->staging->host . ":" . File::Basename::dirname($c->staging->directory) . "/", |
137
|
|
|
|
|
|
|
] |
138
|
|
|
|
|
|
|
}, |
139
|
|
|
|
|
|
|
); |
140
|
0
|
|
|
|
|
|
for my $cmddef (@cmds) { |
141
|
0
|
|
|
|
|
|
my $label = $cmddef->{label}; |
142
|
0
|
|
|
|
|
|
my @cmd = @{ $cmddef->{cmd} }; |
|
0
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
print "--- $label ---\n"; |
144
|
0
|
0
|
|
|
|
|
print "@cmd\n\n" if $v; |
145
|
0
|
|
|
|
|
|
warn "@cmd\n"; |
146
|
0
|
|
|
|
|
|
system(@cmd); |
147
|
0
|
0
|
|
|
|
|
if ($? != 0) { |
148
|
0
|
|
|
|
|
|
warn "\n\nWarnung: es wurden Fehler bei der Übetragung festgestellt!\n"; |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
1; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
__END__ |