| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package PITA::Scheme::Perl; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Base class for all schemes working with Perl-like distributions. |
|
4
|
|
|
|
|
|
|
# Provides bits of common functionality. |
|
5
|
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
154
|
use 5.005; |
|
|
4
|
|
|
|
|
13
|
|
|
|
4
|
|
|
|
|
167
|
|
|
7
|
4
|
|
|
4
|
|
24
|
use strict; |
|
|
4
|
|
|
|
|
16
|
|
|
|
4
|
|
|
|
|
107
|
|
|
8
|
4
|
|
|
4
|
|
22
|
use Carp (); |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
76
|
|
|
9
|
4
|
|
|
4
|
|
20
|
use File::Spec (); |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
116
|
|
|
10
|
4
|
|
|
4
|
|
3680
|
use File::pushd (); |
|
|
4
|
|
|
|
|
118959
|
|
|
|
4
|
|
|
|
|
113
|
|
|
11
|
4
|
|
|
4
|
|
2293
|
use Params::Util ('_INSTANCE'); |
|
|
4
|
|
|
|
|
6167
|
|
|
|
4
|
|
|
|
|
527
|
|
|
12
|
4
|
|
|
4
|
|
6097
|
use Archive::Extract (); |
|
|
4
|
|
|
|
|
767783
|
|
|
|
4
|
|
|
|
|
132
|
|
|
13
|
4
|
|
|
4
|
|
1862
|
use PITA::Scheme (); |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use vars qw{$VERSION @ISA}; |
|
16
|
|
|
|
|
|
|
BEGIN { |
|
17
|
|
|
|
|
|
|
$VERSION = '0.43'; |
|
18
|
|
|
|
|
|
|
@ISA = 'PITA::Scheme'; |
|
19
|
|
|
|
|
|
|
} |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
##################################################################### |
|
26
|
|
|
|
|
|
|
# Generic Constructor |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Do the extra common checks we couldn't do in the main class |
|
29
|
|
|
|
|
|
|
sub new { |
|
30
|
|
|
|
|
|
|
my $class = shift; |
|
31
|
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Can we locate the package? |
|
34
|
|
|
|
|
|
|
my $filename = $self->request->file->filename; |
|
35
|
|
|
|
|
|
|
$self->{archive} = File::Spec->catfile( $self->injector, $filename ); |
|
36
|
|
|
|
|
|
|
unless ( -f $self->{archive} ) { |
|
37
|
|
|
|
|
|
|
Carp::croak('Failed to find package $filename in injector'); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$self; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub archive { |
|
44
|
|
|
|
|
|
|
$_[0]->{archive}; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub extract_path { |
|
48
|
|
|
|
|
|
|
$_[0]->{extract_path}; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub extract_files { |
|
52
|
|
|
|
|
|
|
my $files = $_[0]->{extract_files}; |
|
53
|
|
|
|
|
|
|
$files ? @$files : (); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
##################################################################### |
|
61
|
|
|
|
|
|
|
# PITA::Scheme Methods |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub prepare_package { |
|
64
|
|
|
|
|
|
|
my $self = shift; |
|
65
|
|
|
|
|
|
|
$self->SUPER::prepare_package(@_); |
|
66
|
|
|
|
|
|
|
return 1 if $self->{extract_files}; |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Extract the package to the working directory |
|
69
|
|
|
|
|
|
|
my $archive = Archive::Extract->new( |
|
70
|
|
|
|
|
|
|
archive => $self->archive |
|
71
|
|
|
|
|
|
|
) or Carp::croak("Package is not an archive, or not extractable"); |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# Extract the archive to the working directory |
|
74
|
|
|
|
|
|
|
local $Archive::Extract::WARN = 0; |
|
75
|
|
|
|
|
|
|
my $ok = $archive->extract( |
|
76
|
|
|
|
|
|
|
to => $self->workarea |
|
77
|
|
|
|
|
|
|
) or Carp::croak("Error extracting package: " . $archive->error); |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# Save the list of files |
|
80
|
|
|
|
|
|
|
$self->{extract_path} = $archive->extract_path; |
|
81
|
|
|
|
|
|
|
$self->{extract_files} = $archive->files; |
|
82
|
|
|
|
|
|
|
### For now this list is unreliable and inconsistent. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Look for a single subdirectory and descend if needed |
|
85
|
|
|
|
|
|
|
$self; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub prepare_environment { |
|
89
|
|
|
|
|
|
|
my $self = shift; |
|
90
|
|
|
|
|
|
|
unless ( $self->extract_path ) { |
|
91
|
|
|
|
|
|
|
Carp::croak("Cannot call prepare_environment without extracting pachage"); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# Change to the extraction directory |
|
95
|
|
|
|
|
|
|
unless ( $self->{_chdir} ) { |
|
96
|
|
|
|
|
|
|
unless ( $self->{_chdir} = File::pushd::pushd( $self->extract_path ) ) { |
|
97
|
|
|
|
|
|
|
Carp::croak("Failed to change to extract_path for execution"); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
# Set any general environment variables |
|
102
|
|
|
|
|
|
|
$ENV{PERL_AUTOINSTALL} = '--defaultdeps'; |
|
103
|
|
|
|
|
|
|
$ENV{AUTOMATED_TESTING} = ref $self; |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# Set any environment variables from the Request |
|
106
|
|
|
|
|
|
|
### Not supported by PITA::XML::Request yet |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# Save the platform configuration |
|
109
|
|
|
|
|
|
|
$self->{platform} = PITA::XML::Platform->autodetect_perl5; |
|
110
|
|
|
|
|
|
|
unless ( _INSTANCE($self->{platform}, 'PITA::XML::Platform') ) { |
|
111
|
|
|
|
|
|
|
Carp::croak("Failed to capture platform information"); |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
1; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
##################################################################### |
|
122
|
|
|
|
|
|
|
# PITA::Scheme::Perl Methods |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# Mainly a convenience for now. |
|
125
|
|
|
|
|
|
|
sub workarea_file { |
|
126
|
|
|
|
|
|
|
my $self = shift; |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# If the package has been extracted, prefer its |
|
129
|
|
|
|
|
|
|
# interpretation of being where the workarea is. |
|
130
|
|
|
|
|
|
|
my $workarea = defined $self->extract_path |
|
131
|
|
|
|
|
|
|
? $self->extract_path |
|
132
|
|
|
|
|
|
|
: $self->workarea; |
|
133
|
|
|
|
|
|
|
File::Spec->catfile( $workarea, shift ); |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
##################################################################### |
|
141
|
|
|
|
|
|
|
# Support Methods |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub DESTROY { |
|
144
|
|
|
|
|
|
|
# Remove the _chdir explicitly early |
|
145
|
|
|
|
|
|
|
if ( defined $_[0]->{_chdir} ) { |
|
146
|
|
|
|
|
|
|
undef $_[0]->{_chdir}; |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
1; |