Boxer/Task/Bootstrap.pm

filter: Statementstmt 60.2% 47 / 78 Branchbran 0.0% 0 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 12 / 16 Podpod 0.0% 0 / 1 totaltotal 51.7% 59 / 114 CC 10 SCAR 32.2
CC
10
Cov
49%
run
72.0
_build_apt
12.0
__ANON__
2.0
CRAP 25.1
↑ Summary Boxer/World/Reclass.pm »
1 package Boxer::Task::Bootstrap;
2  
3 =encoding UTF-8
4  
5 =cut
6  
7 1 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Role::Commons -all;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use feature 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use namespace::autoclean 0.16;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use autodie qw(:all);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use IPC::System::Simple qw(runx);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use MooX::StrictConstructor;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 extends qw(Boxer::Task);
18  
19 1 ▶use Types::Standard qw( Bool Str InstanceOf ArrayRef Maybe );
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use strictures 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶no warnings "experimental::signatures";
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 =head1 VERSION
25  
26 Version v1.4.3
27  
28 =cut
29  
30 1 our $VERSION = "v1.4.3";
31  
32 1 has world => (
33 is => 'ro',
34 isa => InstanceOf ['Boxer::World'],
35 required => 1,
36 );
37  
38 1 has node => (
39 is => 'ro',
40 isa => Str,
41 required => 1,
42 );
43  
44 1 has helper => (
45 is => 'ro',
46 isa => Str,
47 required => 1,
48 );
49  
50 1 has mode => (
51 is => 'ro',
52 isa => Maybe [Str],
53 );
54  
55 1 has helper_args => (
56 is => 'ro',
57 isa => ArrayRef,
58 );
59  
60 has nonfree => (
61 is => 'ro',
62 isa => Bool,
63 required => 1,
64 0 ▶ default => sub {0},
Subroutine __ANON__: not called CC=1 SCAR=6.9
65 1 );
66  
67 1 has apt => (
68 is => 'lazy',
69 isa => Bool,
70 );
71  
72 0 ▶sub _build_apt ($self)
Subroutine _build_apt: not called CC=3 SCAR=24.8
73 {
74 0 my $flag;
75 0 foreach my $helper (qw(mmdebstrap)) {
76 0 ▶ if ( $self->{helper} eq $helper ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"helper"} eq $helper) 0 0 0
77 0 $self->_logger->tracef(
78 'Enabling apt mode needed by bootstrap helper %s',
79 $helper,
80 );
81 0 return 1;
82 }
83 }
84 0 return 0;
85 }
86  
87 has dryrun => (
88 is => 'ro',
89 isa => Bool,
90 required => 1,
91 0 ▶ default => sub {0},
Subroutine __ANON__: not called CC=1 SCAR=6.9
92 1 );
93  
94 0 ▶sub run ($self)
Subroutine run: not called CC=8 SCAR=42.8
Pod undocumented
95  
96 {
97 0 my $world = $self->world->map( $self->node, $self->nonfree, );
98 0 my @opts;
99  
100 0 my @pkgs = sort @{ $world->pkgs };
101 0 my @pkgs_avoid = sort @{ $world->pkgs_avoid };
102  
103 0 ▶ if ( $self->apt ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->apt) 0 0 0
104 0 push @pkgs, sort map { $_ . '-' } @pkgs_avoid;
105 0 @pkgs_avoid = ();
106 }
107  
108 0 ▶ push @opts, '--include', join( ',', @pkgs )
Branch: 1 branch
BranchTrueFalseTotal
if @pkgs 0 0 0
109 if (@pkgs);
110 0 ▶ push @opts, '--exclude', join( ',', @pkgs_avoid )
Branch: 1 branch
BranchTrueFalseTotal
if @pkgs_avoid 0 0 0
111 if (@pkgs_avoid);
112 0 push @opts, $world->epoch, @{ $self->mode, $self->helper_args };
113  
114 0 my @command;
115 0 ▶ if ( $self->mode and $self->mode eq 'sudo' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->mode and $self->mode eq 'sudo') { } 0 0 0
Condition0%0/3
$self->mode and $self->mode eq "sudo"
!ll&&!rl&&r
000
MC/DC0%0/2
$self->mode and $self->mode eq "sudo"
$self->mode $self->mode eq "sudo"
Truth table0%0/3
A and B
A= $self->modeB= $self->mode eq "sudo"
ABresult
0X0
100
111
116 0 @command = ( 'sudo', '--', $self->helper, @opts );
117 }
118 else {
119 0 @command = ( $self->helper, @opts );
120 }
121  
122 0 ▶ $self->_logger->info(
Branch: 1 branch
BranchTrueFalseTotal
$self->_logger->is_debug ? : 0 0 0
123 "Bootstrap with " . $self->helper,
124 $self->_logger->is_debug() ? { commandline => [@command] } : (),
125 );
126 0 ▶ if ( $self->dryrun ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->dryrun) { } 0 0 0
127 0 $self->_logger->debug('Skip execute command in dry-run mode');
128 }
129 else {
130 0 runx @command;
131 }
132  
133 0 1;
134 }
135  
136 =head1 AUTHOR
137  
138 Jonas Smedegaard C<< <dr@jones.dk> >>.
139  
140 =cut
141  
142 1 our $AUTHORITY = 'cpan:JONASS';
143  
144 =head1 COPYRIGHT AND LICENCE
145  
146 Copyright © 2019 Jonas Smedegaard
147  
148 This is free software; you can redistribute it and/or modify it under
149 the same terms as the Perl 5 programming language system itself.
150  
151 =head1 DISCLAIMER OF WARRANTIES
152  
153 THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
154 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
155 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
156  
157 =cut
158  
159 1 1;
↑ Summary Boxer/World/Reclass.pm »