Alien-Build
view release on metacpan or search on metacpan
lib/Alien/Build.pm view on Meta::CPAN
elsif($self->download_rule eq 'encrypt')
{
die "file was fetched insecurely for $archive" unless $encrypted_fetch;
}
elsif($self->download_rule eq 'digest_or_encrypt')
{
die "file was fetched insecurely and required digest missing for $archive" unless $checked_digest || $encrypted_fetch;
}
elsif($self->download_rule eq 'digest_and_encrypt')
{
die "file was fetched insecurely and required digest missing for $archive" unless $checked_digest || $encrypted_fetch;
die "required digest missing for $archive" unless $checked_digest;
die "file was fetched insecurely for $archive" unless $encrypted_fetch;
}
elsif($self->download_rule eq 'warn')
{
unless($checked_digest || $encrypted_fetch)
{
$self->log("!!! NOTICE OF FUTURE CHANGE IN BEHAVIOR !!!");
$self->log("a future version of Alien::Build will die here by default with this exception: file was fetched insecurely and required digest missing for $archive");
$self->log("!!! NOTICE OF FUTURE CHANGE IN BEHAVIOR !!!");
}
}
else
{
die "internal error, unknown download rule: @{[ $self->download_rule ]}";
}
}
my $nick_name = 'build';
if($self->meta_prop->{out_of_source})
{
$nick_name = 'extract';
my $extract = $self->install_prop->{extract};
return $extract if defined $extract && -d $extract;
}
my $tmp;
local $CWD;
my $ret;
$self->_call_hook({
before => sub {
# called build instead of extract, because this
# will be used for the build step, and technically
# extract is a substage of build anyway.
$tmp = Alien::Build::TempDir->new($self, $nick_name);
$CWD = "$tmp";
},
verify => sub {
my $path = '.';
if($self->meta_prop->{out_of_source} && $self->install_prop->{extract})
{
$path = $self->install_prop->{extract};
}
my @list = grep { $_->basename !~ /^\./ && $_->basename ne 'pax_global_header' } _path($path)->children;
my $count = scalar @list;
if($count == 0)
{
die "no files extracted";
}
elsif($count == 1 && -d $list[0])
{
$ret = $list[0]->absolute->stringify;
}
else
{
$ret = "$tmp";
}
},
after => sub {
$CWD = $self->root;
},
}, 'extract', $archive);
$self->install_prop->{extract} ||= $ret;
$ret ? $ret : ();
}
sub build
{
my($self) = @_;
# save the evironment, in case some plugins decide
# to alter it. Or us! See just a few lines below.
local %ENV = %ENV;
my $stage = _path($self->install_prop->{stage});
$stage->mkpath;
my $tmp;
if($self->install_type eq 'share')
{
foreach my $suffix ('', '_ffi')
{
local $CWD;
delete $ENV{DESTDIR} unless $self->meta_prop->{destdir};
my %env_meta = %{ $self->meta_prop ->{env} || {} };
my %env_inst = %{ $self->install_prop->{env} || {} };
if($self->meta_prop->{env_interpolate})
{
foreach my $key (keys %env_meta)
{
$env_meta{$key} = $self->meta->interpolator->interpolate($env_meta{$key}, $self);
}
}
%ENV = (%ENV, %env_meta);
lib/Alien/Build.pm view on Meta::CPAN
{
return 'share';
}
},
);
=head2 after_hook
$build->meta->after_hook($hook_name, sub {
my(@args) = @_;
...
});
Execute the given code reference after the hook. The original
arguments are passed into the code reference.
=head2 before_hook
$build->meta->before_hook($hook_name, sub {
my(@args) = @_;
...
});
Execute the given code reference before the hook. The original
arguments are passed into the code reference.
=head2 apply_plugin
Alien::Build->meta->apply_plugin($name);
Alien::Build->meta->apply_plugin($name, @args);
Apply the given plugin with the given arguments.
=head1 ENVIRONMENT
L<Alien::Build> responds to these environment variables:
=over 4
=item ALIEN_BUILD_LOG
The default log class used. See L<Alien::Build::Log> and L<Alien::Build::Log::Default>.
=item ALIEN_BUILD_PKG_CONFIG
Override the logic in L<Alien::Build::Plugin::PkgConfig::Negotiate> which
chooses the best C<pkg-config> plugin.
=item ALIEN_BUILD_POSTLOAD
semicolon separated list of plugins to automatically load after parsing
your L<alienfile>.
=item ALIEN_BUILD_PRELOAD
semicolon separated list of plugins to automatically load before parsing
your L<alienfile>.
=item ALIEN_BUILD_RC
Perl source file which can override some global defaults for L<Alien::Build>,
by, for example, setting preload and postload plugins.
=item ALIEN_DOWNLOAD_RULE
This value determines the rules by which types of downloads are allowed. The legal
values listed under L</download_rule>, plus C<default> which will be the default for
the current version of L<Alien::Build>. For this version that default is C<warn>.
=item ALIEN_INSTALL_NETWORK
If set to true (the default), then network fetch will be allowed. If set to
false, then network fetch will not be allowed.
What constitutes a local vs. network fetch is determined based on the C<start_url>
and C<local_source> meta properties. An L<alienfile> or plugin C<could> override
this detection (possibly inappropriately), so this variable is not a substitute
for properly auditing of Perl modules for environments that require that.
=item ALIEN_INSTALL_TYPE
If set to C<share> or C<system>, it will override the system detection logic.
If set to C<default>, it will use the default setting for the L<alienfile>.
The behavior of other values is undefined.
Although the recommended way for a consumer to use an L<Alien::Base> based L<Alien>
is to declare it as a static configure and build-time dependency, some consumers
may prefer to fallback on using an L<Alien> only when the consumer itself cannot
detect the necessary package. In some cases the consumer may want the user to opt-in
to using an L<Alien> before requiring it.
To keep the interface consistent among Aliens, the consumer of the fallback opt-in
L<Alien> may fallback on the L<Alien> if the environment variable C<ALIEN_INSTALL_TYPE>
is set to any value. The rationale is that by setting this environment variable the
user is aware that L<Alien> modules may be installed and have indicated consent.
The actual implementation of this, by its nature would have to be in the consuming
CPAN module.
=item DESTDIR
This environment variable will be manipulated during a destdir install.
=item PKG_CONFIG
This environment variable can be used to override the program name for C<pkg-config>
when using the command line plugin: L<Alien::Build::Plugin::PkgConfig::CommandLine>.
=item ftp_proxy, all_proxy
If these environment variables are set, it may influence the Download negotiation
plugin L<Alien::Build::Plugin::Download::Negotiate>. Other proxy variables may
be used by some Fetch plugins, if they support it.
=back
=head1 SUPPORT
The intent of the C<Alien-Build> team is to support the same versions of
Perl that are supported by the Perl toolchain. As of this writing that
means 5.16 and better.
( run in 5.680 seconds using v1.01-cache-2.11-cpan-cdf2f3d4e48 )