|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Alien::Build::Temp;  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
3
 | 
59
 | 
 
 | 
 
 | 
  
59
  
 | 
 
 | 
225445
 | 
 use strict;  | 
| 
 
 | 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
140
 | 
    | 
| 
 
 | 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1836
 | 
    | 
| 
4
 | 
59
 | 
 
 | 
 
 | 
  
59
  
 | 
 
 | 
320
 | 
 use warnings;  | 
| 
 
 | 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
116
 | 
    | 
| 
 
 | 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1401
 | 
    | 
| 
5
 | 
59
 | 
 
 | 
 
 | 
  
59
  
 | 
 
 | 
941
 | 
 use 5.008004;  | 
| 
 
 | 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
216
 | 
    | 
| 
6
 | 
59
 | 
 
 | 
 
 | 
  
59
  
 | 
 
 | 
367
 | 
 use Carp ();  | 
| 
 
 | 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
143
 | 
    | 
| 
 
 | 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1962
 | 
    | 
| 
7
 | 
59
 | 
 
 | 
 
 | 
  
59
  
 | 
 
 | 
3457
 | 
 use Path::Tiny ();  | 
| 
 
 | 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
43446
 | 
    | 
| 
 
 | 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1239
 | 
    | 
| 
8
 | 
59
 | 
 
 | 
 
 | 
  
59
  
 | 
 
 | 
1140
 | 
 use File::Temp ();  | 
| 
 
 | 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
20103
 | 
    | 
| 
 
 | 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1094
 | 
    | 
| 
9
 | 
59
 | 
 
 | 
 
 | 
  
59
  
 | 
 
 | 
307
 | 
 use File::Spec ();  | 
| 
 
 | 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
152
 | 
    | 
| 
 
 | 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
22011
 | 
    | 
| 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # ABSTRACT: Temp Dir support for Alien::Build  | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $VERSION = '2.46'; # 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
  
 | 
 
 | 
1401
 | 
   return File::Spec->tmpdir if $^O eq 'MSWin32';  | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
30
 | 
308
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
5363
 | 
   my $root = Path::Tiny->new(-d "_alien" ? "_alien/tmp" : ".tmp")->absolute;  | 
| 
31
 | 
308
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
37161
 | 
   unless(-d $root)  | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   {  | 
| 
33
 | 
7
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
302
 | 
     mkdir $root or die "unable to create temp root $!";  | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
36
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   # TODO: doesn't account for fork...  | 
| 
37
 | 
308
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9536
 | 
   my $lock = $root->child("l$$");  | 
| 
38
 | 
308
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
11853
 | 
   unless(-f $lock)  | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   {  | 
| 
40
 | 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
2689
 | 
     open my $fh, '>', $lock;  | 
| 
41
 | 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5542
 | 
     close $fh;  | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
43
 | 
308
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5668
 | 
   $root{"$root"} = 1;  | 
| 
44
 | 
308
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4127
 | 
   $root;  | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
46
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 END {  | 
| 
48
 | 
59
 | 
 
 | 
 
 | 
  
59
  
 | 
 
 | 
515107
 | 
   foreach my $root (keys %root)  | 
| 
49
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   {  | 
| 
50
 | 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
475
 | 
     my $lock = Path::Tiny->new($root)->child("l$$");  | 
| 
51
 | 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3755
 | 
     unlink $lock;  | 
| 
52
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     # try to delete if possible.  | 
| 
53
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     # if not possible then punt  | 
| 
54
 | 
47
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
6200
 | 
     rmdir $root if -d $root;  | 
| 
55
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
   }  | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
58
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub newdir  | 
| 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 {  | 
| 
60
 | 
307
 | 
 
 | 
 
 | 
  
307
  
 | 
  
0
  
 | 
856
 | 
   my $class = shift;  | 
| 
61
 | 
307
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
1175
 | 
   Carp::croak "uneven" if @_ % 2;  | 
| 
62
 | 
307
 | 
 
 | 
 
 | 
 
 | 
 
 | 
1115
 | 
   File::Temp->newdir(DIR => _root, @_);  | 
| 
63
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
64
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
65
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub new  | 
| 
66
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 {  | 
| 
67
 | 
1
 | 
 
 | 
 
 | 
  
1
  
 | 
  
0
  
 | 
7004
 | 
   my $class = shift;  | 
| 
68
 | 
1
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
13
 | 
   Carp::croak "uneven" if @_ % 2;  | 
| 
69
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
3
 | 
   File::Temp->new(DIR => _root, @_);  | 
| 
70
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
72
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
73
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
74
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |