line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
2679
|
use v5.14.0; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
34
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
46
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package OS::Package::Role::Prune; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: Provides prune method for OS::Package object. |
7
|
|
|
|
|
|
|
our $VERSION = '0.2.6'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
32
|
use OS::Package::Log; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Path::Tiny; |
11
|
|
|
|
|
|
|
use Try::Tiny; |
12
|
|
|
|
|
|
|
use Role::Tiny; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub prune { |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $self = shift; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
if ( !defined $self->fakeroot ) { |
19
|
|
|
|
|
|
|
$LOGGER->warn('fakeroot is not defined'); |
20
|
|
|
|
|
|
|
return; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
if ( !-d $self->fakeroot ) { |
24
|
|
|
|
|
|
|
$LOGGER->warn('fakeroot does not exist'); |
25
|
|
|
|
|
|
|
return 1; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
if ( defined $self->prune_files ) { |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
$LOGGER->info( sprintf 'prune files: %s', $self->name ); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
foreach my $file ( @{ $self->prune_files } ) { |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $pfile = |
35
|
|
|
|
|
|
|
sprintf( '%s/%s/%s', $self->fakeroot, $self->prefix, $file ); |
36
|
|
|
|
|
|
|
$LOGGER->debug( sprintf 'removing file: %s', $pfile ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
unlink path($pfile)->stringify; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
if ( defined $self->prune_dirs ) { |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$LOGGER->info( sprintf 'prune directories: %s', $self->name ); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
foreach my $dir ( @{ $self->prune_dirs } ) { |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $pdir = |
49
|
|
|
|
|
|
|
sprintf( '%s/%s/%s', $self->fakeroot, $self->prefix, $dir ); |
50
|
|
|
|
|
|
|
$LOGGER->debug( sprintf 'removing directory: %s', $pdir ); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
path($pdir)->remove_tree( { safe => 0 } ); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
return 1; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |