Alien-Base-ModuleBuild

 view release on metacpan or  search on metacpan

lib/Alien/Base/ModuleBuild.pm  view on Meta::CPAN

package Alien::Base::ModuleBuild;

use strict;
use warnings;
use 5.008001;
use parent 'Module::Build';
use Capture::Tiny 0.17 qw/capture tee/;
use File::chdir;
use File::Spec;
use File::Basename qw/fileparse/;
use Carp;
no warnings;
use Archive::Extract;
use warnings;
use Sort::Versions;
use List::Util qw( uniq any );
use ExtUtils::Installed;
use File::Copy qw/move/;
use Env qw( @PATH );
use Shell::Guess;
use Shell::Config::Generate;
use File::Path qw/mkpath/;
use Config;
use Text::ParseWords qw( shellwords );
use Alien::Base::PkgConfig;
use Alien::Base::ModuleBuild::Cabinet;
use Alien::Base::ModuleBuild::Repository;
use Alien::Base::ModuleBuild::Repository::HTTP;
use Alien::Base::ModuleBuild::Repository::FTP;
use Alien::Base::ModuleBuild::Repository::Local;

# ABSTRACT: A Module::Build subclass for building Alien:: modules and their libraries
our $VERSION = '1.17'; # VERSION

# setup protocol specific classes
# Alien:: author can override these defaults using alien_repository_class property
my %default_repository_class = (
  default => 'Alien::Base::ModuleBuild::Repository',
  http    => 'Alien::Base::ModuleBuild::Repository::HTTP',
  https   => 'Alien::Base::ModuleBuild::Repository::HTTP',
  ftp     => 'Alien::Base::ModuleBuild::Repository::FTP',
  local   => 'Alien::Base::ModuleBuild::Repository::Local',
);

our $Verbose;
$Verbose = $ENV{ALIEN_VERBOSE} if defined $ENV{ALIEN_VERBOSE};

our $Force;
our $ForceSystem;
_compute_force();

sub _compute_force
{
  undef $Force;
  undef $ForceSystem;

  if(defined $ENV{ALIEN_INSTALL_TYPE})
  {
    if($ENV{ALIEN_INSTALL_TYPE} eq 'share')
    {
      $Force       = 1;
      $ForceSystem = 0;
    }
    elsif($ENV{ALIEN_INSTALL_TYPE} eq 'system')
    {
      $Force       = 0;

lib/Alien/Base/ModuleBuild.pm  view on Meta::CPAN

The default implementation relies on L<Archive::Extract> that is able
to handle most common formats. In order to handle other formats or
archives requiring some special treatment you may want to override
this method.

=head2 alien_do_system

[version 0.024]

  my %result = $amb->alien_do_system($cmd)

Similar to
L<Module::Build's do_system|Module::Build::API/"do_system($cmd, @args)">,
also sets the path and several environment variables in accordance
to the object configuration (i.e. C<alien_bin_requires>) and
performs the interpolation of the patterns described in
L<Alien::Base::ModuleBuild::API/"COMMAND INTERPOLATION">.

Returns a set of key value pairs including C<stdout>, C<stderr>,
C<success> and C<command>.

=head2 alien_do_commands

 $amb->alien_do_commands($phase);

Executes the commands for the given phase.

=head2 alien_interpolate

 my $string = $amb->alien_interpolate($string);

Takes the input string and interpolates the results.

=head2 alien_install_network

[version 1.16]

 my $bool = $amb->alien_install_network;

Returns true if downloading source from the internet is allowed.  This
is true unless C<ALIEN_INSTALL_NETWORK> is defined and false.

=head2 alien_download_rule

[version 1.16]

 my $rule = $amb->alien_download_rule;

This will return one of C<warn>, C<digest>, C<encrypt>, C<digest_or_encrypt>
or C<digest_and_encrypt>.  This is based on the C<ALIEN_DOWNLOAD_RULE>
environment variable.

=head1 GUIDE TO DOCUMENTATION

The documentation for C<Module::Build> is broken up into sections:

=over

=item General Usage (L<Module::Build>)

This is the landing document for L<Alien::Base::ModuleBuild>'s parent class.
It describes basic usage and background information.
Its main purpose is to assist the user who wants to learn how to invoke
and control C<Module::Build> scripts at the command line.

It also lists the extra documentation for its use. Users and authors of Alien::
modules should familiarize themselves with these documents. L<Module::Build::API>
is of particular importance to authors.

=item Alien-Specific Usage (L<Alien::Base::ModuleBuild>)

This is the document you are currently reading.

=item Authoring Reference (L<Alien::Base::Authoring>)

This document describes the structure and organization of
C<Alien::Base> based projects, beyond that contained in
C<Module::Build::Authoring>, and the relevant concepts needed by authors who are
writing F<Build.PL> scripts for a distribution or controlling
C<Alien::Base::ModuleBuild> processes programmatically.

Note that as it contains information both for the build and use phases of
L<Alien::Base> projects, it is located in the upper namespace.

=item API Reference (L<Alien::Base::ModuleBuild::API>)

This is a reference to the C<Alien::Base::ModuleBuild> API beyond that contained
in C<Module::Build::API>.

=item Using the resulting L<Alien> (L<Alien::Build::Manual::AlienUser>)

Once you have an L<Alien> you or your users can review this manual for how to use
it.  Generally speaking you should have some useful usage information in your
L<Alien>'s POD, but some authors choose to direct their users to this manual
instead.

=item Using L<Alien::Build> instead (L<Alien::Build::Manual>)

As mentioned at the top, you are encouraged to use the L<Alien::Build> and
L<alienfile> system instead.  This manual is a starting point for the other
L<Alien::Build> documentation.

=back

=head1 ENVIRONMENT

=over 4

=item B<ALIEN_ARCH>

Set to a true value to install to an arch-specific directory.

=item B<ALIEN_DOWNLOAD_RULE>

This controls security options for fetching alienized packages over the internet.
The legal values are:

=over 4

=item C<warn>



( run in 0.999 second using v1.01-cache-2.11-cpan-2398b32b56e )