line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# vim: set ts=2 sw=2 tw=0: |
5
|
|
|
|
|
|
|
# vim: set expandtab: |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Rex::Apache::Build::tgz - Build tgz packages |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
With this module you can build TGZ packages to distribute your application. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
build "my-software", |
18
|
|
|
|
|
|
|
type => "tgz", |
19
|
|
|
|
|
|
|
version => "1.0", |
20
|
|
|
|
|
|
|
source => "/path/to/your/software", |
21
|
|
|
|
|
|
|
# below this, it is all optional |
22
|
|
|
|
|
|
|
exclude => [qw/file1 file2/]; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
package Rex::Apache::Build::tgz; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
1
|
|
1494
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
26
|
|
31
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
1
|
|
5
|
use Cwd qw(getcwd); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
60
|
|
34
|
1
|
|
|
1
|
|
5
|
use Rex -base; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
10
|
|
35
|
1
|
|
|
1
|
|
2742
|
use Data::Dumper; |
|
1
|
|
|
|
|
2819
|
|
|
1
|
|
|
|
|
60
|
|
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
|
7
|
use Rex::Apache::Build::Base; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
38
|
1
|
|
|
1
|
|
27
|
use base qw(Rex::Apache::Build::Base); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
491
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub new { |
41
|
0
|
|
|
0
|
0
|
|
my $that = shift; |
42
|
0
|
|
0
|
|
|
|
my $proto = ref($that) || $that; |
43
|
0
|
|
|
|
|
|
my $self = $proto->SUPER::new(@_); |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
bless($self, $proto); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# compatibility for < 0.11 |
48
|
0
|
0
|
|
|
|
|
if($self->{source} eq ".") { |
49
|
0
|
|
|
|
|
|
$self->{source} = undef; |
50
|
0
|
|
|
|
|
|
delete $self->{source}; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$self->{exclude} = [".git", ".svn", ".*.sw*", "*~", "yuicompressor.jar", "._yuicompressor.jar"]; |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
return $self; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub build { |
59
|
0
|
|
|
0
|
0
|
|
my ($self, $name) = @_; |
60
|
|
|
|
|
|
|
|
61
|
0
|
|
0
|
|
|
|
$name ||= $self->{name}; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
my $old_dir = getcwd(); |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $excludes = ""; |
66
|
0
|
0
|
|
|
|
|
if(exists $self->{exclude}) { |
67
|
0
|
0
|
|
|
|
|
if($^O =~ m/^MSWin/) { |
68
|
0
|
|
|
|
|
|
$excludes = " --exclude \"" . join("\" --exclude \"", @{$self->{exclude}}) . "\""; |
|
0
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else { |
71
|
0
|
|
|
|
|
|
$excludes = " --exclude '" . join("' --exclude '", @{$self->{exclude}}) . "'"; |
|
0
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
0
|
|
|
|
|
|
my $version = $self->version; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $dir = getcwd(); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# compatibility for < 0.11 versions |
80
|
0
|
0
|
|
|
|
|
if(exists $self->{path}) { |
81
|
0
|
|
|
|
|
|
$dir = $self->{path}; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# if source is present, this will overwrite path parameter |
85
|
|
|
|
|
|
|
# because path can also be used in deploy() with an other meaning (prefix) |
86
|
0
|
0
|
|
|
|
|
if(exists $self->{source}) { |
87
|
0
|
|
|
|
|
|
$dir = $self->{source}; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
chdir($dir); |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
my $package_name = "$name-$version.tar.gz"; |
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
Rex::Logger::info("Building: $package_name"); |
95
|
0
|
0
|
|
|
|
|
if($^O =~ m/^MSWin/i) { |
96
|
0
|
|
|
|
|
|
run "tar -c $excludes --exclude \"$name-*.tar.gz\" --exclude \".*.sw*\" --exclude \"*~\" --exclude Rexfile.lock --exclude Rexfile --exclude $package_name -z -f $old_dir/$package_name ."; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
else { |
99
|
0
|
|
|
|
|
|
run "tar -c $excludes --exclude '$name-*.tar.gz' --exclude '.*.sw*' --exclude '*~' --exclude Rexfile.lock --exclude Rexfile --exclude $package_name -z -f $old_dir/$package_name ."; |
100
|
|
|
|
|
|
|
} |
101
|
0
|
|
|
|
|
|
Rex::Logger::info("Your build is now available: $name-$version.tar.gz"); |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
chdir($old_dir); |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
return $package_name; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |