Alien-Base-ModuleBuild
view release on metacpan or search on metacpan
lib/Alien/Base/ModuleBuild/Repository.pm view on Meta::CPAN
package Alien::Base::ModuleBuild::Repository;
use strict;
use warnings;
use Carp;
use Alien::Base::ModuleBuild::File;
use Alien::Base::ModuleBuild::Utils qw/pattern_has_capture_groups/;
# ABSTRACT: Private class
our $VERSION = '1.17'; # VERSION
sub new {
my $class = shift;
my (%self) = ref $_[0] ? %{ shift() } : @_;
my $obj = bless \%self, $class;
$obj->{c_compiler_required} = 1
unless defined $obj->{c_compiler_required};
my $location = $obj->{location};
$location = '' unless defined $location;
if(defined $obj->{exact_filename} && $location !~ m{/$}) {
$obj->{location} = $location . '/'
}
return $obj;
}
sub protocol { return shift->{protocol} }
sub host {
my $self = shift;
$self->{host} = shift if @_;
return $self->{host};
}
sub location {
my $self = shift;
$self->{location} = shift if @_;
return $self->{location};
}
sub is_network_fetch {
die "must override in the subclass";
}
sub is_secure_fetch {
die "must override in the subclass";
}
sub has_digest
{
my($self) = @_;
defined $self->{exact_filename} && $self->{exact_version} && (defined $self->{sha1} || defined $self->{sha256});
}
sub probe {
my $self = shift;
require Alien::Base::ModuleBuild;
if(!Alien::Base::ModuleBuild->alien_install_network && $self->is_network_fetch) {
die "network fetch is disabled via ALIEN_INSTALL_NETWORK";
}
my $rule = Alien::Base::ModuleBuild->alien_download_rule;
if($rule eq 'warn') {
unless($self->is_secure_fetch || $self->has_digest) {
warn "!!! NOTICE OF FUTURE CHANGE IN BEHAVIOR !!!\n";
warn "A future version of Alien::Base::ModuleBuild will die here by default with this exception: File fetch is insecure and has no digest. Required by ALIEN_DOWNLOAD_RULE=digest_or_encrypt.";
warn "!!! NOTICE OF FUTURE CHANGE IN BEHAVIOR !!!\n";
}
} elsif($rule eq 'digest') {
( run in 0.926 second using v1.01-cache-2.11-cpan-62beec7d96d )