line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
2635
|
use v5.14.0; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
130
|
|
2
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
198
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package OS::Package::CLI; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: OS::Package application initialization. |
7
|
|
|
|
|
|
|
our $VERSION = '0.2.7'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
1754
|
use English qw(-no_match_vars); |
|
3
|
|
|
|
|
4843
|
|
|
3
|
|
|
|
|
17
|
|
10
|
3
|
|
|
3
|
|
2520
|
use Env qw( $HOME ); |
|
3
|
|
|
|
|
4001
|
|
|
3
|
|
|
|
|
17
|
|
11
|
3
|
|
|
3
|
|
414
|
use File::Basename; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
172
|
|
12
|
3
|
|
|
3
|
|
2226
|
use Getopt::Long; |
|
3
|
|
|
|
|
26767
|
|
|
3
|
|
|
|
|
29
|
|
13
|
3
|
|
|
3
|
|
1081
|
use OS::Package::Application; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
97
|
|
14
|
3
|
|
|
3
|
|
813
|
use OS::Package::Config qw($OSPKG_CONFIG); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
351
|
|
15
|
3
|
|
|
3
|
|
1380
|
use OS::Package::Factory; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
186
|
|
16
|
3
|
|
|
3
|
|
1606
|
use OS::Package::Init; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
162
|
|
17
|
3
|
|
|
3
|
|
18
|
use OS::Package::Log; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
247
|
|
18
|
3
|
|
|
3
|
|
18
|
use Path::Tiny; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
132
|
|
19
|
3
|
|
|
3
|
|
2078
|
use Pod::Usage; |
|
3
|
|
|
|
|
116181
|
|
|
3
|
|
|
|
|
410
|
|
20
|
3
|
|
|
3
|
|
31
|
use Try::Tiny; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
1512
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub run { |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
0
|
1
|
|
my ( $COMMAND, $APP, %OPT ); |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
GetOptions( \%OPT, 'build_id|b=s', 'config_dir|c=s', 'pkg_dir|p=s', 'repo_dir|r=s' ); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$COMMAND = shift @ARGV; |
29
|
0
|
|
|
|
|
|
$APP = shift @ARGV; |
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
if ( !defined $COMMAND ) { |
32
|
0
|
|
|
|
|
|
$LOGGER->warn('please tell me what to do'); |
33
|
0
|
|
|
|
|
|
exit; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
0
|
|
|
|
|
if ( $COMMAND =~ m{^(help|--help|-h)$} ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
pod2usage( |
38
|
|
|
|
|
|
|
-exitstatus => '1', |
39
|
|
|
|
|
|
|
-message => 'See --man for full documentation' |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
elsif ( $COMMAND =~ m{^(man|--man|-m)$} ) { |
43
|
0
|
|
|
|
|
|
pod2usage( -exitstatus => '0', -verbose => 2 ); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
elsif ( $COMMAND =~ m{^(version|--version|-v)$} ) { |
46
|
0
|
|
|
|
|
|
printf "%s %s\n", basename($PROGRAM_NAME), $VERSION; |
47
|
0
|
|
|
|
|
|
exit; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
if ( defined $OPT{config_dir} ) { |
51
|
0
|
|
|
|
|
|
$OSPKG_CONFIG->dir->configs( $OPT{config_dir} ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
if ( defined $OPT{pkg_dir} ) { |
55
|
0
|
|
|
|
|
|
$OSPKG_CONFIG->dir->packages( $OPT{pkg_dir} ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
|
if ( defined $OPT{repo_dir} ) { |
59
|
0
|
|
|
|
|
|
$OSPKG_CONFIG->dir->repository( $OPT{repo_dir} ); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
0
|
|
|
|
|
if ( $COMMAND eq 'init' ) { |
63
|
0
|
|
|
|
|
|
init_ospkg; |
64
|
0
|
|
|
|
|
|
$LOGGER->info( sprintf 'put configs in %s', |
65
|
|
|
|
|
|
|
$OSPKG_CONFIG->dir->configs ); |
66
|
0
|
|
|
|
|
|
exit; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
if ( !path( $OSPKG_CONFIG->dir->base )->exists ) { |
70
|
0
|
|
|
|
|
|
$LOGGER->info('initializing'); |
71
|
0
|
|
|
|
|
|
init_ospkg; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
0
|
0
|
|
|
|
|
if ( !defined $APP ) { |
75
|
0
|
|
|
|
|
|
$LOGGER->warn('missing app'); |
76
|
0
|
|
|
|
|
|
exit; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $app = { name => $APP }; |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$LOGGER = Log::Log4perl->get_logger( $app->{name} ); |
82
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
if ( defined $OPT{build_id} ) { |
84
|
0
|
|
|
|
|
|
$app->{build_id} = $OPT{build_id}; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
my $pkg = vivify($app); |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
$LOGGER->info( sprintf 'processing: %s %s', $pkg->name, $pkg->application->version ); |
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
|
if ( $COMMAND eq 'download' ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
$pkg->artifact->download; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
elsif ( $COMMAND eq 'extract' ) { |
96
|
0
|
|
|
|
|
|
$pkg->artifact->extract; |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
elsif ( $COMMAND eq 'build' ) { |
99
|
|
|
|
|
|
|
|
100
|
0
|
0
|
|
|
|
|
if ( defined $pkg->artifact ) { |
101
|
|
|
|
|
|
|
|
102
|
0
|
0
|
0
|
|
|
|
$pkg->artifact->download |
103
|
|
|
|
|
|
|
|| ( $LOGGER->fatal('download failed') && die ); |
104
|
|
|
|
|
|
|
|
105
|
0
|
0
|
0
|
|
|
|
$pkg->artifact->extract |
106
|
|
|
|
|
|
|
|| ( $LOGGER->fatal('extract failed') && die ); |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
0
|
0
|
0
|
|
|
|
$pkg->build || ( $LOGGER->fatal('build failed') && die ); |
110
|
|
|
|
|
|
|
|
111
|
0
|
0
|
0
|
|
|
|
$pkg->prune || ( $LOGGER->fatal('prune failed') && die ); |
112
|
|
|
|
|
|
|
|
113
|
0
|
0
|
0
|
|
|
|
$pkg->create || ( $LOGGER->fatal('create failed') && die ); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
elsif ( $COMMAND eq 'prune' ) { |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
$pkg->application->prune; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
elsif ( $COMMAND eq 'clean' ) { |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
$pkg->clean; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
__END__ |