| 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::Deploy::deb - Deploy deb package |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
With this module you can deploy a Debian package. |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
If the package is not build yet, it will pass all the arguments to the build() function and executes the build on the local machine. |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
deploy "my-software.deb"; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
deploy "my-software", |
|
22
|
|
|
|
|
|
|
type => "deb", |
|
23
|
|
|
|
|
|
|
version => "1.0", |
|
24
|
|
|
|
|
|
|
# below this, it is all optional |
|
25
|
|
|
|
|
|
|
source => "/path/to/your/software", |
|
26
|
|
|
|
|
|
|
path => "/path/to/deploy/target", |
|
27
|
|
|
|
|
|
|
description => "some description of your package", |
|
28
|
|
|
|
|
|
|
url => "website of the package", |
|
29
|
|
|
|
|
|
|
depends => [qw/httpd perl/], |
|
30
|
|
|
|
|
|
|
release => 1, |
|
31
|
|
|
|
|
|
|
epoch => 1, |
|
32
|
|
|
|
|
|
|
vendor => "some vendor", |
|
33
|
|
|
|
|
|
|
license => "your license for ex. GPL2", |
|
34
|
|
|
|
|
|
|
section => "some/section", |
|
35
|
|
|
|
|
|
|
conflicts => [qw/somepkg/], |
|
36
|
|
|
|
|
|
|
provides => "some-package-name", |
|
37
|
|
|
|
|
|
|
arch => "x86_64", |
|
38
|
|
|
|
|
|
|
target => "linux / the platform", |
|
39
|
|
|
|
|
|
|
post_install => "filename or script to run after installation", |
|
40
|
|
|
|
|
|
|
pre_install => "filename or script to run before installation", |
|
41
|
|
|
|
|
|
|
post_uninstall => "filename or script to run after uninstall", |
|
42
|
|
|
|
|
|
|
pre_uninstall => "filename or script to run before uninstall", |
|
43
|
|
|
|
|
|
|
exclude => [qw/file1 file2/], |
|
44
|
|
|
|
|
|
|
maintainer => "your name", |
|
45
|
|
|
|
|
|
|
config_files => [qw/special files for configuration mostly for etc directory/]; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
package Rex::Apache::Deploy::Package::deb; |
|
51
|
|
|
|
|
|
|
|
|
52
|
1
|
|
|
1
|
|
1531
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
108
|
|
|
53
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
26
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
1
|
|
|
1
|
|
6
|
use Rex::Apache::Deploy::Package::Base; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
8
|
|
|
56
|
1
|
|
|
1
|
|
24
|
use base qw(Rex::Apache::Deploy::Package::Base); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
75
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
1
|
|
|
1
|
|
4
|
use Rex::Commands; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
59
|
1
|
|
|
1
|
|
825
|
use Rex::Commands::Fs; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
6
|
|
|
60
|
1
|
|
|
1
|
|
430
|
use Rex::Commands::Run; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
6
|
|
|
61
|
1
|
|
|
1
|
|
88
|
use Rex::Commands::Upload; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
7
|
|
|
62
|
1
|
|
|
1
|
|
49
|
use Rex::Apache::Build; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
115
|
|
|
63
|
1
|
|
|
1
|
|
5
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
395
|
|
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub new { |
|
66
|
0
|
|
|
0
|
0
|
|
my $that = shift; |
|
67
|
0
|
|
0
|
|
|
|
my $proto = ref($that) || $that; |
|
68
|
0
|
|
|
|
|
|
my $self = $proto->SUPER::new(@_); |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
bless( $self, $proto ); |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
if ( $self->{arch} eq "x86_64" ) { |
|
73
|
0
|
|
|
|
|
|
$self->{arch} = "amd64"; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return $self; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub deploy { |
|
80
|
0
|
|
|
0
|
0
|
|
my ( $self, $package_name, %option ) = @_; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
LOCAL { |
|
83
|
0
|
0
|
|
0
|
|
|
if ( !-f $package_name ) { |
|
84
|
0
|
|
|
|
|
|
$package_name = |
|
85
|
|
|
|
|
|
|
$self->name . "_" . $self->version . "_" . $self->arch . ".deb"; |
|
86
|
|
|
|
|
|
|
|
|
87
|
0
|
0
|
|
|
|
|
if ( !-f $package_name ) { |
|
88
|
0
|
|
|
|
|
|
build( $self->name, %option ); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
} |
|
91
|
0
|
|
|
|
|
|
}; |
|
92
|
|
|
|
|
|
|
|
|
93
|
0
|
|
|
|
|
|
upload $package_name, "/tmp"; |
|
94
|
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
run "dpkg -i /tmp/$package_name"; |
|
96
|
0
|
0
|
|
|
|
|
if ( $? != 0 ) { |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# try to install deps |
|
99
|
0
|
|
|
|
|
|
run "apt-get -y -f install"; |
|
100
|
0
|
0
|
|
|
|
|
if ( $? != 0 ) { |
|
101
|
0
|
|
|
|
|
|
unlink "/tmp/$package_name"; |
|
102
|
0
|
|
|
|
|
|
die("Error installing $package_name"); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
my $pkg = Rex::Pkg->get; |
|
106
|
0
|
0
|
|
|
|
|
if ( !$pkg->is_installed( $self->name ) ) { |
|
107
|
0
|
|
|
|
|
|
unlink "/tmp/$package_name"; |
|
108
|
0
|
|
|
|
|
|
die("Error installing $package_name"); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
Rex::Logger::info("Package $package_name installed."); |
|
113
|
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
|
unlink "/tmp/$package_name"; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |