line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
38
|
use v5.14.0; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
132
|
|
2
|
3
|
|
|
3
|
|
20
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
167
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package OS::Package::Init; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Initializes ospkg |
7
|
|
|
|
|
|
|
our $VERSION = '0.2.7'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
20
|
use base qw(Exporter); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
224
|
|
10
|
3
|
|
|
3
|
|
20
|
use Path::Tiny; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
165
|
|
11
|
3
|
|
|
3
|
|
42
|
use OS::Package::Config qw($OSPKG_CONFIG); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
328
|
|
12
|
3
|
|
|
3
|
|
18
|
use OS::Package::Log qw($LOGGER); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
259
|
|
13
|
3
|
|
|
3
|
|
18
|
use YAML::Any qw( DumpFile ); |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
24
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @EXPORT = qw( init_ospkg ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub init_ospkg { |
18
|
0
|
|
|
0
|
1
|
|
my ($opts) = @_; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my @dirs = ( |
21
|
|
|
|
|
|
|
$OSPKG_CONFIG->dir->base, $OSPKG_CONFIG->dir->repository, |
22
|
|
|
|
|
|
|
$OSPKG_CONFIG->dir->configs, $OSPKG_CONFIG->dir->packages |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
foreach my $dir (@dirs) { |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
if ( !path($dir)->exists ) { |
28
|
0
|
|
|
|
|
|
$LOGGER->info( sprintf 'creating directory: %s', $dir ); |
29
|
0
|
|
|
|
|
|
path($dir)->mkpath; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
my $user_config = { |
34
|
|
|
|
|
|
|
config_dir => path($OSPKG_CONFIG->dir->configs)->stringify, |
35
|
|
|
|
|
|
|
pkg_dir => path($OSPKG_CONFIG->dir->packages)->stringify, |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
DumpFile( path( $OSPKG_CONFIG->user_config ), $user_config ); |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
return 1; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
__END__ |