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

filter: Statementstmt 60.8% 28 / 46 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 75.0% 9 / 12 Podpod 0.0% 0 / 2 totaltotal 50.0% 37 / 74 CC 6 SCAR 17.0
CC
6
Cov
49%
new
12.0
__ANON__
12.0
deploy
6.0
CRAP 5.5
« lib/Rex/Apache/Deploy/Package/deb.pm ↑ Summary lib/Rex/Apache/Deploy/Package/tgz.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::rpm - Deploy rpm package
10  
11 =head1 DESCRIPTION
12  
13 With this module you can deploy a RedHat 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.rpm";
20  
21 deploy "my-software",
22 type => "rpm",
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::rpm;
51  
52 1 ▶use Rex::Apache::Deploy::Package::Base;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 1 ▶use base qw(Rex::Apache::Deploy::Package::Base);
Subroutine BEGIN: called CC=1 SCAR=0.0
54  
55 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 1 ▶use warnings;
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  
64 0 ▶sub new {
Subroutine new: not called CC=3 SCAR=24.8
Pod undocumented
65 0 my $that = shift;
66 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
67 0 my $self = $proto->SUPER::new(@_);
68  
69 0 bless( $self, $proto );
70  
71 0 ▶ $self->{release} ||= 1;
Condition0%0/2
$self->{"release"} ||= 1
l!l
00
MC/DC0%0/1
$self->{"release"} ||= 1
$self->{"release"}
Truth table0%0/2
A
A= $self->{"release"}
Aresult
11
00
72  
73 0 return $self;
74 }
75  
76 0 ▶sub deploy {
Subroutine deploy: not called CC=2 SCAR=17.9
Pod undocumented
77 0 my ( $self, $package_name, %option ) = @_;
78  
79 0 ▶ LOCAL {
Subroutine __ANON__: not called CC=3 SCAR=24.8
80 0 ▶ if ( !-f $package_name ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not -f $package_name) 0 0 0
81 0 $package_name =
82 $self->name . "-"
83 . $self->version . "-"
84 . $self->release . "."
85 . $self->arch . ".rpm";
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 "rpm -U /tmp/$package_name";
96 0 ▶ if ( $? != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
97 0 die("Error installing $package_name");
98 }
99  
100 0 Rex::Logger::info("Package $package_name installed.");
101  
102 0 unlink "/tmp/$package_name";
103 }
104  
105 1 1;
« lib/Rex/Apache/Deploy/Package/deb.pm ↑ Summary lib/Rex/Apache/Deploy/Package/tgz.pm »