| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Alien::Base::ModuleBuild::File; |
|
2
|
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
442880
|
use strict; |
|
|
7
|
|
|
|
|
34
|
|
|
|
7
|
|
|
|
|
241
|
|
|
4
|
7
|
|
|
7
|
|
42
|
use warnings; |
|
|
7
|
|
|
|
|
23
|
|
|
|
7
|
|
|
|
|
149
|
|
|
5
|
7
|
|
|
7
|
|
43
|
use Carp; |
|
|
7
|
|
|
|
|
13
|
|
|
|
7
|
|
|
|
|
3481
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: Private class |
|
8
|
|
|
|
|
|
|
our $VERSION = '1.17'; # VERSION |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub new { |
|
11
|
442
|
|
|
442
|
0
|
659
|
my $class = shift; |
|
12
|
442
|
100
|
|
|
|
748
|
my $self = ref $_[0] ? shift : { @_ }; |
|
13
|
|
|
|
|
|
|
|
|
14
|
442
|
|
|
|
|
592
|
bless $self, $class; |
|
15
|
|
|
|
|
|
|
|
|
16
|
442
|
|
|
|
|
715
|
return $self; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub has_version { |
|
20
|
19
|
|
|
19
|
0
|
23
|
my $self = shift; |
|
21
|
19
|
|
|
|
|
28
|
return defined $self->version; |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub get { |
|
25
|
9
|
|
|
9
|
0
|
24
|
my $self = shift; |
|
26
|
9
|
|
|
|
|
28
|
my $repo = $self->repository; |
|
27
|
|
|
|
|
|
|
|
|
28
|
9
|
|
|
|
|
28
|
my $filename = $repo->get_file($self->filename); |
|
29
|
9
|
100
|
|
|
|
38
|
if ( my $new_filename = $repo->{new_filename} ) { |
|
30
|
4
|
|
|
|
|
8
|
$filename = $new_filename; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
## whatever happened, record the new filename |
|
34
|
9
|
|
|
|
|
17
|
$self->{filename} = $filename; |
|
35
|
|
|
|
|
|
|
|
|
36
|
9
|
50
|
33
|
|
|
72
|
if (defined $self->{sha1} || defined $self->{sha256}) { |
|
37
|
0
|
0
|
|
|
|
0
|
unless (eval { require Digest::SHA }) { |
|
|
0
|
|
|
|
|
0
|
|
|
38
|
0
|
|
|
|
|
0
|
warn "sha1 or sha256 sums are specified but cannot be checked since Digest::SHA is not installed"; |
|
39
|
0
|
|
|
|
|
0
|
require Alien::Base::ModuleBuild; |
|
40
|
0
|
0
|
|
|
|
0
|
return undef if Alien::Base::ModuleBuild->alien_download_rule =~ /digest/; |
|
41
|
0
|
|
|
|
|
0
|
return $filename; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
0
|
|
|
|
0
|
eval { require Digest::SHA } or return $filename; |
|
|
0
|
|
|
|
|
0
|
|
|
45
|
|
|
|
|
|
|
## verify that the SHA-1 and/or SHA-256 sums match if provided |
|
46
|
0
|
0
|
|
|
|
0
|
if (defined $self->{sha1}) { |
|
47
|
0
|
|
|
|
|
0
|
my $sha = Digest::SHA->new(1); |
|
48
|
0
|
|
|
|
|
0
|
$sha->addfile($filename); |
|
49
|
0
|
0
|
|
|
|
0
|
unless ($sha->hexdigest eq $self->{sha1}) { |
|
50
|
|
|
|
|
|
|
carp "SHA-1 of downloaded $filename is ", $sha->hexdigest, |
|
51
|
0
|
|
|
|
|
0
|
" Expected: ", $self->{sha1}; |
|
52
|
0
|
|
|
|
|
0
|
return undef; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
} |
|
55
|
0
|
0
|
|
|
|
0
|
if (defined $self->{sha256}) { |
|
56
|
0
|
|
|
|
|
0
|
my $sha = Digest::SHA->new(256); |
|
57
|
0
|
|
|
|
|
0
|
$sha->addfile($filename); |
|
58
|
0
|
0
|
|
|
|
0
|
unless ($sha->hexdigest eq $self->{sha256}) { |
|
59
|
|
|
|
|
|
|
carp "SHA-256 of downloaded $filename is ", $sha->hexdigest, |
|
60
|
0
|
|
|
|
|
0
|
" Expected: ", $self->{sha256}; |
|
61
|
0
|
|
|
|
|
0
|
return undef; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
9
|
|
|
|
|
47
|
return $filename; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
3
|
|
|
3
|
0
|
41
|
sub platform { shift->{platform} } |
|
70
|
9
|
|
|
9
|
0
|
31
|
sub repository { shift->{repository} } |
|
71
|
32
|
|
|
32
|
0
|
4240
|
sub version { shift->{version} } |
|
72
|
16
|
|
|
16
|
0
|
206
|
sub filename { shift->{filename} } |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__END__ |