blib/lib/Ixchel/Actions/lilith_install.pm untested

filter: Statementstmt 0.0% 0 / 46 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 64 CC 3 SCAR 15.0
CC
3
Cov
0%
action_extra
12.0
new_extra
2.0
short
2.0
CRAP 4.5
1 package Ixchel::Actions::lilith_install;
2  
3 use 5.006;
4 use strict;
5 use warnings;
6 use File::Slurp;
7 use Ixchel::functions::perl_module_via_pkg;
8 use base 'Ixchel::Actions::base';
9  
10 =head1 NAME
11  
12 Ixchel::Actions::lilith_install - Installs Lilith using packages as much as possible.
13  
14 =head1 VERSION
15  
16 Version 0.1.0
17  
18 =cut
19  
20 our $VERSION = '0.1.0';
21  
22 =head1 CLI SYNOPSIS
23  
24 ixchel -a lilith_install
25  
26 =head1 CODE SYNOPSIS
27  
28 use Data::Dumper;
29  
30 my $results=$ixchel->action(action=>'lilith_install', opts=>{});
31  
32 if ($results->{ok}) {
33 print $results->{status_text};
34 }else{
35 die('Action errored... '.joined("\n", @{$results->{errors}}));
36 }
37  
38 =head1 RESULT HASH REF
39  
40 .errors :: A array of errors encountered.
41 .status_text :: A string description of what was done and the results.
42 .ok :: Set to zero if any of the above errored.
43  
44 =cut
45  
46 sub new_extra { }
47  
48 sub action_extra {
49 my $self = $_[0];
50  
51 $self->status_add( status => 'Installing Lilith depends via packages' );
52  
53 my @depends = (
54 'TOML', 'DBI', 'JSON', 'File::ReadBackwards',
55 'Digest::SHA', 'POE', 'File::Slurp', 'MIME::Base64',
56 'Gzip::Faster', 'DBD::Pg', 'Data::Dumper', 'Text::ANSITable',
57 'Net::Server::Daemonize', 'Sys::Syslog', 'YAML::PP', 'File::Slurp',
58 'TOML', 'Term::ANSIColor', 'MIME::Base64', 'Time::Piece::Guess'
59 );
60  
61 $self->status_add( status => 'Perl Depends: ' . join( ', ', @depends ) );
62  
63 my @installed;
64 my @failed;
65  
66 foreach my $depend (@depends) {
67 my $status;
68 $self->status_add( status => 'Trying to install ' . $depend . ' as a package...' );
69 eval { $status = perl_module_via_pkg( module => $depend ); };
70 if ($@) {
71 push( @failed, $depend );
72 $self->status_add( status => $depend . ' could not be installed as a package' );
73 } else {
74 push( @installed, $depend );
75 $self->status_add( status => $depend . ' could not be installed as a package' );
76 }
77 } ## end foreach my $depend (@depends)
78  
79 $self->status_add( status => 'cpanm Lilith starting ...' );
80 my $output=`cpanm Lilith 2>&1`;
81 $self->status_add( status => "cpanm Lilith finished ... \n".$output );
82 if ( $? != 0 ) {
83 $self->status_add( status => 'Failed to install Lilith via cpanm', error => 1 );
84 } else {
85 $self->status_add( status => 'Lilith installed' );
86 }
87  
88 $self->status_add( status => 'Installed via Packages: ' . join( ', ', @installed ) );
89 $self->status_add( status => 'Needed via cpanm: ' . join( ', ', @failed ) );
90  
91 return undef;
92 } ## end sub action
93  
94 sub short {
95 return 'Installs Lilith using packages as much as possible.';
96 }
97  
98 sub opts_data {
99 return '
100 ';
101 }
102  
103 1;