File Coverage

blib/lib/Boxer/CLI/Command/Bootstrap.pm
Criterion Covered Total %
statement 36 53 67.9
branch 0 2 0.0
condition 0 2 0.0
subroutine 13 18 72.2
pod 4 4 100.0
total 53 79 67.0


line stmt bran cond sub pod time code
1             package Boxer::CLI::Command::Bootstrap;
2              
3             =encoding UTF-8
4              
5             =cut
6              
7 3     3   1999 use v5.20;
  3         10  
8 3     3   17 use utf8;
  3         4  
  3         20  
9 3     3   81 use Role::Commons -all;
  3         4  
  3         14  
10 3     3   4115 use feature 'signatures';
  3         6  
  3         240  
11 3     3   20 use namespace::autoclean 0.16;
  3         44  
  3         17  
12              
13 3     3   851 use Path::Tiny;
  3         9189  
  3         185  
14 3     3   995 use List::MoreUtils qw(before after);
  3         14490  
  3         27  
15 3     3   3119 use Module::Runtime qw/use_module/;
  3         8  
  3         21  
16 3     3   144 use Boxer::CLI -command;
  3         6  
  3         18  
17              
18 3     3   860 use strictures 2;
  3         18  
  3         97  
19 3     3   466 no warnings "experimental::signatures";
  3         5  
  3         152  
20              
21             =head1 VERSION
22              
23             Version v1.4.2
24              
25             =cut
26              
27             our $VERSION = "v1.4.2";
28              
29             use constant {
30 3         1434 abstract => q[bootstrap system image from abstract node],
31             usage_desc => q[%c bootstrap %o NODE [NODE...] [-- helper-options]],
32 3     3   17 };
  3         6  
33              
34             sub description
35             {
36 0     0 1 0 <<'DESCRIPTION';
37             Bootstrap a system image.
38              
39             Generate a filesystem image. Input is one or more abstract nodes
40             to resolve using a set of abstract classes, and output is one or more
41             images generated using a bootstrapping tool.
42              
43             DESCRIPTION
44             }
45              
46             sub command_names
47             {
48 5     5 1 254 qw(
49             bootstrap
50             );
51             }
52              
53             sub opt_spec
54             {
55             return (
56 0     0 1   [ "suite=s", "suite of classes to use (buster)" ],
57             [ "nodedir=s", "location of nodes (current dir)" ],
58             [ "classdir=s", "location of classes (XDG datadir + suite/classes)" ],
59             [ "datadir=s", "location containing nodes and classes" ],
60             [ "skeldir=s", "location of skeleton files (use builtin)" ],
61             [ "mode=s", "mode passed to helper, and use sudo in sudo mode" ],
62             [ "helper=s", "bootstrapping tool to use (mmdebstrap)" ],
63             [ "nonfree", "enable use of contrib and non-free code" ],
64             [ "dryrun", "only echo command, without executing it" ],
65             [ "verbose|v", "verbose output" ],
66             );
67             }
68              
69 0           sub execute ( $self, $opt, $args )
  0            
70 0     0 1   {
  0            
  0            
71             Log::Any::Adapter->set( 'Screen', default_level => 'info' )
72 0 0         if ( $opt->{verbose} );
73              
74 0     0     my @args = before { $_ eq '--' } @{$args};
  0            
  0            
75 0     0     my @helper_args = after { $_ eq '--' } @{$args};
  0            
  0            
76              
77             my $world = use_module('Boxer::Task::Classify')->new(
78             suite => $opt->{suite},
79             nodedir => $opt->{nodedir},
80             classdir => $opt->{classdir},
81             datadir => $opt->{datadir},
82 0           )->run;
83 0           for my $node (@args) {
84             use_module('Boxer::Task::Bootstrap')->new(
85             world => $world,
86             helper => $opt->{helper} || 'mmdebstrap',
87             mode => $opt->{mode},
88             helper_args => [@helper_args],
89             nonfree => $opt->{nonfree},
90             dryrun => $opt->{dryrun},
91 0   0       node => $node,
92             )->run;
93             }
94             }
95              
96             =head1 AUTHOR
97              
98             Jonas Smedegaard C<< <dr@jones.dk> >>.
99              
100             =cut
101              
102             our $AUTHORITY = 'cpan:JONASS';
103              
104             =head1 COPYRIGHT AND LICENCE
105              
106             Copyright © 2019 Jonas Smedegaard
107              
108             This is free software; you can redistribute it and/or modify it under
109             the same terms as the Perl 5 programming language system itself.
110              
111             =head1 DISCLAIMER OF WARRANTIES
112              
113             THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
114             WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
115             MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
116              
117             =cut
118              
119             1;