lib/Rex/Apache/Deploy/Package/deb.pm

filter: Statementstmt 54.3% 31 / 57 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 76.9% 10 / 13 Podpod 0.0% 0 / 2 totaltotal 46.0% 41 / 89 CC 8 SCAR 20.9
CC
8
Cov
43%
deploy
20.0
new
12.0
__ANON__
12.0
CRAP 8.1
« lib/Rex/Apache/Deploy/Package/Base.pm ↑ Summary lib/Rex/Apache/Deploy/Package/rpm.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
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 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
54  
55 1 ▶use Rex::Apache::Deploy::Package::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 1 ▶use base qw(Rex::Apache::Deploy::Package::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
57  
58 1 ▶use Rex::Commands;
Subroutine BEGIN: called CC=1 SCAR=0.0
59 1 ▶use Rex::Commands::Fs;
Subroutine BEGIN: called CC=1 SCAR=0.0
60 1 ▶use Rex::Commands::Run;
Subroutine BEGIN: called CC=1 SCAR=0.0
61 1 ▶use Rex::Commands::Upload;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 1 ▶use Rex::Apache::Build;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
64  
65 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
66 0 my $that = shift;
67 0 ▶ my $proto = ref($that) || $that;
Condition0%0/3
ref $that || $that
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table0%0/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
68 0 my $self = $proto->SUPER::new(@_);
69  
70 0 bless( $self, $proto );
71  
72 0 ▶ if ( $self->{arch} eq "x86_64" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"arch"} eq "x86_64") 0 0 0
73 0 $self->{arch} = "amd64";
74 }
75  
76 0 return $self;
77 }
78  
79 0 ▶sub deploy {
Subroutine deploy: not called CC=4 SCAR=30.0
Pod undocumented
80 0 my ( $self, $package_name, %option ) = @_;
81  
82 0 ▶ LOCAL {
Subroutine __ANON__: not called CC=3 SCAR=24.8
83 0 ▶ if ( !-f $package_name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not -f $package_name) 0 0 0
84 0 $package_name =
85 $self->name . "_" . $self->version . "_" . $self->arch . ".deb";
86  
87 0 ▶ if ( !-f $package_name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not -f $package_name) 0 0 0
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 ▶ if ( $? != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
97  
98 # try to install deps
99 0 run "apt-get -y -f install";
100 0 ▶ if ( $? != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 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 ▶ if ( !$pkg->is_installed( $self->name ) ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pkg->is_installed($self->name)) 0 0 0
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 1;
« lib/Rex/Apache/Deploy/Package/Base.pm ↑ Summary lib/Rex/Apache/Deploy/Package/rpm.pm »