| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package File::ShareDir::Tarball; |
|
2
|
|
|
|
|
|
|
BEGIN { |
|
3
|
1
|
|
|
1
|
|
117021
|
$File::ShareDir::Tarball::AUTHORITY = 'cpan:YANICK'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
{ |
|
6
|
|
|
|
|
|
|
$File::ShareDir::Tarball::VERSION = '0.2.2'; |
|
7
|
|
|
|
|
|
|
} |
|
8
|
|
|
|
|
|
|
# ABSTRACT: Deal transparently with shared files distributed as tarballs |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
12
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
12
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
35
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
5
|
use parent qw/ Exporter /; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
8
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
59
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
78
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
1
|
|
|
1
|
|
6
|
use File::ShareDir; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
51
|
|
|
19
|
1
|
|
|
1
|
|
3298
|
use Archive::Tar; |
|
|
1
|
|
|
|
|
131793
|
|
|
|
1
|
|
|
|
|
117
|
|
|
20
|
1
|
|
|
1
|
|
14
|
use File::Temp qw/ tempdir /; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
91
|
|
|
21
|
1
|
|
|
1
|
|
1145
|
use File::chdir; |
|
|
1
|
|
|
|
|
4211
|
|
|
|
1
|
|
|
|
|
586
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our @EXPORT_OK = qw{ |
|
24
|
|
|
|
|
|
|
dist_dir dist_file |
|
25
|
|
|
|
|
|
|
}; |
|
26
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
|
27
|
|
|
|
|
|
|
all => [ @EXPORT_OK ], |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $shared_files_tarball = 'shared-files.tar.gz'; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# we don't want to extract the same dirs again and |
|
33
|
|
|
|
|
|
|
# again within a single program |
|
34
|
|
|
|
|
|
|
my %DIR_CACHE; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub dist_dir { |
|
37
|
3
|
|
|
3
|
1
|
1118
|
my $dist = shift; |
|
38
|
|
|
|
|
|
|
|
|
39
|
3
|
100
|
|
|
|
26
|
return $DIR_CACHE{$dist} if $DIR_CACHE{$dist}; |
|
40
|
|
|
|
|
|
|
|
|
41
|
2
|
|
|
|
|
26
|
my $dir = File::ShareDir::dist_dir($dist); |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# no tarball? Assume regular shared dir |
|
44
|
2
|
100
|
|
|
|
406
|
return $DIR_CACHE{$dist} = $dir |
|
45
|
|
|
|
|
|
|
unless -f "$dir/$shared_files_tarball"; |
|
46
|
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
13
|
my $archive = Archive::Tar->new; |
|
48
|
1
|
|
|
|
|
19
|
$archive->read("$dir/$shared_files_tarball"); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# because that would be a veeery bad idea |
|
51
|
2
|
|
|
|
|
88
|
croak "archive '$shared_files_tarball' contains files with absolute path, aborting" |
|
52
|
1
|
50
|
|
|
|
7007
|
if grep { m#^/# } $archive->list_files; |
|
53
|
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
8
|
my $tmpdir = tempdir( CLEANUP => 1 ); |
|
55
|
1
|
|
|
|
|
592
|
local $CWD = $tmpdir; |
|
56
|
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
64
|
$archive->extract; |
|
58
|
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
17741
|
return $DIR_CACHE{$dist} = $tmpdir; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub dist_file { |
|
63
|
0
|
|
|
0
|
1
|
|
my $dist = File::ShareDir::_DIST(shift); |
|
64
|
0
|
|
|
|
|
|
my $file = File::ShareDir::_FILE(shift); |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my $path = dist_dir($dist).'/'.$file; |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
return undef unless -e $path; |
|
69
|
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
croak("Found dist_file '$path', but not a file") |
|
71
|
|
|
|
|
|
|
unless -f $path; |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
0
|
|
|
|
|
croak("File '$path', no read permissions") |
|
74
|
|
|
|
|
|
|
unless -r $path; |
|
75
|
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return $path; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
1; |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |