| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# -*- perl -*- |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# $Id: Tgz.pm,v 1.6 2005/02/18 11:58:26 eserte Exp $ |
|
5
|
|
|
|
|
|
|
# Author: Slaven Rezic |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# Copyright (C) 2004 Slaven Rezic. |
|
8
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under the |
|
9
|
|
|
|
|
|
|
# terms of the GNU General Public License, see the file COPYING. |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# Mail: slaven@rezic.de |
|
13
|
|
|
|
|
|
|
# WWW: http://we-framework.sourceforge.net |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package WE_Frontend::Publish::Tgz; |
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
1758
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
27
|
|
|
19
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
74
|
|
|
20
|
|
|
|
|
|
|
$VERSION = sprintf("%d.%02d", q$Revision: 1.6 $ =~ /(\d+)\.(\d+)/); |
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
5
|
use WE_Frontend::Publish; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
35
|
|
|
23
|
1
|
|
|
1
|
|
5
|
use WE::Util::Functions qw(_save_pwd); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
64
|
|
|
24
|
1
|
|
|
1
|
|
5
|
use WE_Frontend::Info 1.33; # staging->message |
|
|
1
|
|
|
|
|
35
|
|
|
|
1
|
|
|
|
|
41
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
6
|
use File::Basename; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
841
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# for compatibility: |
|
29
|
|
|
|
|
|
|
sub WE_Frontend::Main::publish_tgz { |
|
30
|
0
|
|
|
0
|
|
|
my($self, %args) = @_; |
|
31
|
0
|
|
|
|
|
|
publish_tgz($self, %args); |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Return created $archivefile |
|
35
|
|
|
|
|
|
|
sub publish_tgz { |
|
36
|
0
|
|
|
0
|
0
|
|
my($self, %args) = @_; |
|
37
|
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
require Archive::Tar; |
|
39
|
0
|
|
|
|
|
|
require File::Find; |
|
40
|
0
|
|
|
|
|
|
require File::Spec; |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
my $v = $args{-v}; |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $archivefileformat = $self->Config->staging->archivefile; |
|
45
|
0
|
|
|
|
|
|
my $pubhtmldir = $self->Config->paths->pubhtmldir; |
|
46
|
|
|
|
|
|
|
|
|
47
|
0
|
0
|
|
|
|
|
if (!defined $archivefileformat) { |
|
48
|
0
|
|
|
|
|
|
die "The WEsiteinfo->staging->archivefile config member is not defined"; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
0
|
0
|
0
|
|
|
|
if (!defined $pubhtmldir || $pubhtmldir eq '') { |
|
51
|
0
|
|
|
|
|
|
die "The publish html directory is missing (config member WEsiteinfo->paths->pubhtmldir)"; |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my @l = localtime; |
|
55
|
0
|
|
|
|
|
|
my $date = sprintf "%04d%02d%02d-%02d%02d%02d", $l[5]+1900, $l[4]+1, @l[3,2,1,0]; |
|
56
|
0
|
|
|
|
|
|
(my $archivefile = $archivefileformat) =~ s/\@DATE\@/$date/g; |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
my $tar = Archive::Tar->new(); |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
print "Add to archive...\n"; |
|
61
|
|
|
|
|
|
|
_save_pwd { |
|
62
|
0
|
|
|
0
|
|
|
my @files; |
|
63
|
|
|
|
|
|
|
my %absfiles; |
|
64
|
0
|
|
|
|
|
|
my @symlinks; |
|
65
|
0
|
0
|
|
|
|
|
chdir $pubhtmldir or die "Can't chdir to $pubhtmldir: $!"; |
|
66
|
|
|
|
|
|
|
File::Find::find |
|
67
|
|
|
|
|
|
|
(sub { |
|
68
|
0
|
0
|
|
|
|
|
return if -d; |
|
69
|
|
|
|
|
|
|
# exclude: |
|
70
|
0
|
0
|
|
|
|
|
return if $File::Find::name =~ m{^\./we/}; |
|
71
|
0
|
0
|
|
|
|
|
return if $File::Find::name =~ m{/(CVS|RCS|\.svn)/}; |
|
72
|
0
|
0
|
|
|
|
|
return if m{^( \.cvsignore |
|
73
|
|
|
|
|
|
|
| \.keep_me # yes? no? XXX |
|
74
|
|
|
|
|
|
|
| .*~ |
|
75
|
|
|
|
|
|
|
| \.\#.*\.\d+ # a CVS related file |
|
76
|
|
|
|
|
|
|
| \.DS_Store |
|
77
|
|
|
|
|
|
|
)$}x; |
|
78
|
0
|
0
|
|
|
|
|
if (-l) { |
|
79
|
0
|
|
|
|
|
|
my $readlink = readlink($_); |
|
80
|
0
|
|
|
|
|
|
push @symlinks, [$File::Find::name, $readlink, File::Spec->rel2abs($readlink)]; |
|
81
|
|
|
|
|
|
|
} else { |
|
82
|
0
|
|
|
|
|
|
print $File::Find::name, "\n"; |
|
83
|
0
|
|
|
|
|
|
push @files, $File::Find::name; |
|
84
|
0
|
|
|
|
|
|
$absfiles{ File::Spec->rel2abs($_) } = $File::Find::name; |
|
85
|
|
|
|
|
|
|
} |
|
86
|
0
|
|
|
|
|
|
}, "."); |
|
87
|
|
|
|
|
|
|
#XXX require Data::Dumper; print STDERR "Line " . __LINE__ . ", File: " . __FILE__ . "\n" . Data::Dumper->new([[sort keys %absfiles], \@symlinks],[])->Indent(1)->Useqq(1)->Dump; # XXX |
|
88
|
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
for my $symlinkdef (@symlinks) { |
|
90
|
0
|
|
|
|
|
|
my($file, $relfile, $absfile) = @$symlinkdef; |
|
91
|
|
|
|
|
|
|
# XXX Archive::Tar 1.10 bug: |
|
92
|
|
|
|
|
|
|
# XXX only one symlink of multiple to the same file can be |
|
93
|
|
|
|
|
|
|
# stored, so use no symlinks at all... |
|
94
|
0
|
|
|
|
|
|
if (0 && exists $absfiles{$absfile}) { |
|
95
|
|
|
|
|
|
|
# XXX make sure it's a relative link! |
|
96
|
|
|
|
|
|
|
# push @files, File::Spec->abs2rel($file, |
|
97
|
|
|
|
|
|
|
print "Symlink $file -> $relfile\n"; |
|
98
|
|
|
|
|
|
|
push @files, $file; |
|
99
|
|
|
|
|
|
|
} else { |
|
100
|
0
|
0
|
|
|
|
|
if (!open(FH, $absfile)) { |
|
101
|
0
|
|
|
|
|
|
print "Skipping $absfile, can't open $!\n"; |
|
102
|
|
|
|
|
|
|
} else { |
|
103
|
0
|
|
|
|
|
|
local $/ = undef; |
|
104
|
0
|
|
|
|
|
|
my $buf = ; |
|
105
|
0
|
|
|
|
|
|
print "Symlink not available on target system, store data for $file\n"; |
|
106
|
0
|
|
|
|
|
|
$tar->add_data($file, $buf); |
|
107
|
0
|
|
|
|
|
|
close FH; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
} |
|
111
|
0
|
|
|
|
|
|
$tar->add_files(@files); |
|
112
|
0
|
|
|
|
|
|
}; |
|
113
|
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
$tar->write($archivefile, 1, "htdocs"); |
|
115
|
|
|
|
|
|
|
|
|
116
|
0
|
|
|
|
|
|
my $message = $self->Config->staging->message; |
|
117
|
0
|
0
|
|
|
|
|
if (!$message) { |
|
|
|
0
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
|
print "\nArchive file $archivefile written...\n"; |
|
119
|
|
|
|
|
|
|
} elsif (ref $message eq 'CODE') { |
|
120
|
0
|
|
|
|
|
|
print $message->(archivefile => $archivefile); |
|
121
|
|
|
|
|
|
|
} else { |
|
122
|
0
|
|
|
|
|
|
print $message; |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
0
|
|
|
|
|
|
return $archivefile; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# Apache.pm-friendly system() |
|
129
|
|
|
|
|
|
|
sub _system { |
|
130
|
0
|
|
|
0
|
|
|
my $cmd = shift; |
|
131
|
0
|
|
|
|
|
|
open(SYS, "$cmd|"); |
|
132
|
0
|
|
|
|
|
|
while() { |
|
133
|
0
|
|
|
|
|
|
print $_; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
0
|
|
|
|
|
|
close SYS; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
__END__ |