| 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::tgz - Deploy tgz package | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | =head1 DESCRIPTION | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | With this module you can deploy a TGZ packages. | ||||||||||||||||||||
| 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.tgz"; | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | deploy "my-software", | ||||||||||||||||||||
| 22 | type => "rpm", | ||||||||||||||||||||
| 23 | version => "1.0", | ||||||||||||||||||||
| 24 | # below this, it is all optional | ||||||||||||||||||||
| 25 | source => "html", | ||||||||||||||||||||
| 26 | path => "/var/www/html"; | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | =cut | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | package Rex::Apache::Deploy::Package::tgz; | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 33 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 1 | ▶ | use Rex::Apache::Build; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 36 | 1 | ▶ | use Rex::Commands; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 37 | 1 | ▶ | use Rex::Commands::Upload; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 38 | 1 | ▶ | use Rex::Commands::Run; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 39 | 1 | ▶ | use Rex::Commands::Fs; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 40 | 1 | ▶ | use Rex::Apache::Deploy::Package::Base; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 41 | 1 | ▶ | use base qw(Rex::Apache::Deploy::Package::Base); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 44 | 0 | my $that = shift; | |||||||||||||||||||
| 45 | 0 | ▶ | my $proto = ref($that) || $that; | ||||||||||||||||||
|
Condition0%0/3
ref $that || $that
MC/DC0%0/2
ref $that || $that
ref $that
$that
Truth table0%0/3
A || B
A= ref $thatB= $that
| |||||||||||||||||||||
| 46 | 0 | my $self = $proto->SUPER::new(@_); | |||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | 0 | bless( $self, $proto ); | |||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | 0 | return $self; | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 0 | ▶ | sub deploy { | ||||||||||||||||||
|
Subroutine
deploy: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 54 | 0 | my ( $self, $package_name, %option ) = @_; | |||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 0 | ▶ | LOCAL { | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||
| 57 | 0 | ▶ | if ( !-f $package_name ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 58 | 0 | $package_name = $self->name . "-" . $self->version . ".tar.gz"; | |||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 0 | ▶ | if ( !-f $package_name ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 61 | 0 | build( $self->name, %option ); | |||||||||||||||||||
| 62 | } | ||||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | 0 | }; | |||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 0 | upload $package_name, "/tmp"; | |||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | 0 | my $to = $self->prefix; | |||||||||||||||||||
| 69 | 0 | run "tar -C $to -xzf /tmp/$package_name"; | |||||||||||||||||||
| 70 | 0 | ▶ | if ( $? != 0 ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 71 | 0 | die("Error installing $package_name"); | |||||||||||||||||||
| 72 | } | ||||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 0 | Rex::Logger::info("Package $package_name installed."); | |||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | 0 | unlink "/tmp/$package_name"; | |||||||||||||||||||
| 77 | } | ||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 1 | 1; | |||||||||||||||||||