line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Temp; |
2
|
|
|
|
|
|
|
|
3
|
59
|
|
|
59
|
|
196630
|
use strict; |
|
59
|
|
|
|
|
117
|
|
|
59
|
|
|
|
|
1562
|
|
4
|
59
|
|
|
59
|
|
253
|
use warnings; |
|
59
|
|
|
|
|
106
|
|
|
59
|
|
|
|
|
1143
|
|
5
|
59
|
|
|
59
|
|
828
|
use 5.008004; |
|
59
|
|
|
|
|
177
|
|
6
|
59
|
|
|
59
|
|
344
|
use Carp (); |
|
59
|
|
|
|
|
171
|
|
|
59
|
|
|
|
|
1621
|
|
7
|
59
|
|
|
59
|
|
3213
|
use Path::Tiny (); |
|
59
|
|
|
|
|
40811
|
|
|
59
|
|
|
|
|
980
|
|
8
|
59
|
|
|
59
|
|
1000
|
use File::Temp (); |
|
59
|
|
|
|
|
16277
|
|
|
59
|
|
|
|
|
934
|
|
9
|
59
|
|
|
59
|
|
288
|
use File::Spec (); |
|
59
|
|
|
|
|
122
|
|
|
59
|
|
|
|
|
18533
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Temp Dir support for Alien::Build |
12
|
|
|
|
|
|
|
our $VERSION = '2.47'; # VERSION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# problem with vanilla File::Temp is that is often uses |
16
|
|
|
|
|
|
|
# as /tmp that has noexec turned on. Workaround is to |
17
|
|
|
|
|
|
|
# create a temp directory in the build directory, but |
18
|
|
|
|
|
|
|
# we have to be careful about cleanup. This puts all that |
19
|
|
|
|
|
|
|
# (attempted) carefulness in one place so that when we |
20
|
|
|
|
|
|
|
# later discover it isn't so careful we can fix it in |
21
|
|
|
|
|
|
|
# one place rather thabn alllll the places that we need |
22
|
|
|
|
|
|
|
# temp directories. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my %root; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub _root |
27
|
|
|
|
|
|
|
{ |
28
|
308
|
50
|
|
308
|
|
1257
|
return File::Spec->tmpdir if $^O eq 'MSWin32'; |
29
|
|
|
|
|
|
|
|
30
|
308
|
50
|
|
|
|
5191
|
my $root = Path::Tiny->new(-d "_alien" ? "_alien/tmp" : ".tmp")->absolute; |
31
|
308
|
100
|
|
|
|
33847
|
unless(-d $root) |
32
|
|
|
|
|
|
|
{ |
33
|
7
|
50
|
|
|
|
298
|
mkdir $root or die "unable to create temp root $!"; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# TODO: doesn't account for fork... |
37
|
308
|
|
|
|
|
8815
|
my $lock = $root->child("l$$"); |
38
|
308
|
100
|
|
|
|
10551
|
unless(-f $lock) |
39
|
|
|
|
|
|
|
{ |
40
|
47
|
|
|
|
|
2481
|
open my $fh, '>', $lock; |
41
|
47
|
|
|
|
|
5258
|
close $fh; |
42
|
|
|
|
|
|
|
} |
43
|
308
|
|
|
|
|
4848
|
$root{"$root"} = 1; |
44
|
308
|
|
|
|
|
3980
|
$root; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
END { |
48
|
59
|
|
|
59
|
|
440425
|
foreach my $root (keys %root) |
49
|
|
|
|
|
|
|
{ |
50
|
47
|
|
|
|
|
396
|
my $lock = Path::Tiny->new($root)->child("l$$"); |
51
|
47
|
|
|
|
|
3210
|
unlink $lock; |
52
|
|
|
|
|
|
|
# try to delete if possible. |
53
|
|
|
|
|
|
|
# if not possible then punt |
54
|
47
|
50
|
|
|
|
5372
|
rmdir $root if -d $root; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub newdir |
59
|
|
|
|
|
|
|
{ |
60
|
307
|
|
|
307
|
0
|
882
|
my $class = shift; |
61
|
307
|
50
|
|
|
|
1127
|
Carp::croak "uneven" if @_ % 2; |
62
|
307
|
|
|
|
|
1035
|
File::Temp->newdir(DIR => _root, @_); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub new |
66
|
|
|
|
|
|
|
{ |
67
|
1
|
|
|
1
|
0
|
6914
|
my $class = shift; |
68
|
1
|
50
|
|
|
|
11
|
Carp::croak "uneven" if @_ % 2; |
69
|
1
|
|
|
|
|
6
|
File::Temp->new(DIR => _root, @_); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |