« blib/lib/Alien/Build/Plugin/PkgConfig/MakeStatic.pm
↑ Summary
blib/lib/Alien/Build/Interpolate.pm »
| 1 | package Alien::Build::Plugin::Digest::SHA; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 6 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 6 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 6 | ▶ | use Alien::Build::Plugin; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | # ABSTRACT: Plugin to check SHA digest with Digest::SHA | ||||||||||||||
| 8 | 6 | our $VERSION = '2.88'; # VERSION | |||||||||||||
| 9 | |||||||||||||||
| 10 | |||||||||||||||
| 11 | sub init | ||||||||||||||
| 12 | 18 | ▶ | { | ||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 13 | 18 | my($self, $meta) = @_; | |||||||||||||
| 14 | |||||||||||||||
| 15 | 18 | $meta->add_requires('configure' => 'Alien::Build' => "2.57" ); | |||||||||||||
| 16 | |||||||||||||||
| 17 | 65 | ▶ | $meta->register_hook( check_digest => sub { | ||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=18.0
| |||||||||||||||
| 18 | 65 | my($build, $file, $algo, $expected_digest) = @_; | |||||||||||||
| 19 | |||||||||||||||
| 20 | 65 | ▶ | return 0 unless $algo =~ /^SHA[0-9]+$/; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 21 | |||||||||||||||
| 22 | 59 | my $sha = Digest::SHA->new($algo); | |||||||||||||
| 23 | 59 | ▶ | return 0 unless defined $sha; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 24 | |||||||||||||||
| 25 | 57 | ▶ | if(defined $file->{content}) | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 26 | { | ||||||||||||||
| 27 | 12 | $sha->add($file->{content}); | |||||||||||||
| 28 | } | ||||||||||||||
| 29 | elsif(defined $file->{path}) | ||||||||||||||
| 30 | { | ||||||||||||||
| 31 | 45 | $sha->addfile($file->{path}, "b"); | |||||||||||||
| 32 | } | ||||||||||||||
| 33 | else | ||||||||||||||
| 34 | { | ||||||||||||||
| 35 | 0 | die "unknown file type"; | |||||||||||||
| 36 | } | ||||||||||||||
| 37 | |||||||||||||||
| 38 | 57 | my $actual_digest = $sha->hexdigest; | |||||||||||||
| 39 | |||||||||||||||
| 40 | 57 | ▶ | return 1 if $expected_digest eq $actual_digest; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 41 | 13 | die "@{[ $file->{filename} ]} SHA@{[ $sha->algorithm ]} digest does not match: got $actual_digest, expected $expected_digest"; | |||||||||||||
| 42 | |||||||||||||||
| 43 | 18 | }); | |||||||||||||
| 44 | } | ||||||||||||||
| 45 | |||||||||||||||
| 46 | 6 | 1; | |||||||||||||
| 47 | |||||||||||||||
| 48 | __END__ | ||||||||||||||