alienfile - Specification for defining an external dependency for CPAN
version 0.16
Do-it-yourself approach:
use alienfile; probe sub { system 'pkg-config', '--exists', 'libarchive'; $? ? 'share' : 'system'; }; share { # the first one which succeeds will be used download [ 'wget http://libarchive.org/downloads/libarchive-3.2.2.tar.gz' ]; download [ 'curl -o http://libarchive.org/downloads/libarchive-3.2.2.tar.gz' ]; extract [ 'tar xf %{alien.install.download}' ]; plugin 'Build::Autoconf'; build [ '%{configure} --disable-shared', '%{make}', '%{make} install', ]; } sub pkgconfig_value { my($name, $build, $args) = @_; my $value = $args->{out}; # stdout from the pkg-config command chomp $value; # probably has \n $build->runtime_prop->{$name} = $value; } gather [ [ 'pkg-config', '--modversion', 'libarchive', sub { pkgconfig_value 'version', @_ } ], [ 'pkg-config', '--cflags', 'libarchive', sub { pkgconfig_value 'cflags', @_ } ], [ 'pkg-config', '--libs', 'libarchive', sub { pkgconfig_value 'libs', @_ } ], ];
With plugins (better):
use alienfile; plugin 'PkgConfig' => 'libarchive'; share { plugin Download => ( url => 'http://libarchive.org/downloads/', filter => qr/^libarchive-.*\.tar\.gz$/, version => qr/([0-9\.]+)/, ); plugin Extract => 'tar.gz'; plugin 'Build::Autoconf' => (); };
An alienfile is a recipe used by Alien::Build to, probe for system libraries or download from the internet, and build source for those libraries.
"any" requirement (either share or system):
requires $module; requires $module => $verson;
configure time requirement:
configure { requires $module; requires $module => $verson; };
system requirement:
sys { requires $module; requires $module => $verson; };
share requirement:
share { requires $module; requires $module => $verson; };
specifies a requirement. Alien::Build takes advantage of dynamic requirements, so only modules that are needed for the specific type of install need to be loaded. Here are the different types of requirements:
Configure requirements should already be installed before the alienfile is loaded.
"Any" requirements are those that are needed either for the probe stage, or in either the system or share installs.
Share requirements are those modules needed when downloading and building from source.
System requirements are those modules needed when the system provides the library or tool.
plugin $name => (%args); plugin $name => $arg;
Load the given plugin. If you prefix the plugin name with an = sign, then it will be assumed to be a fully qualified path name. Otherwise the plugin will be assumed to live in the Alien::Build::Plugin namespace. If there is an appropriate negotiate plugin, that one will be loaded. Examples:
=
Alien::Build::Plugin
# Loads Alien::Build::Plugin::Fetch::Negotiate # which will pick the best Alien::Build::Plugin::Fetch # plugin based on the URL, and system configuration plugin 'Fetch' => 'http://ftp.gnu.org/gnu/gcc'; # loads the plugin with the badly named class! plugin '=Badly::Named::Plugin::Not::In::Alien::Build::Namespace' => (); # explicitly loads Alien::Build::Plugin::Prefer::SortVersions plugin 'Prefer::SortVersions => ( filter => qr/^gcc-.*\.tar.gz$/, version => qr/([0-9\.]+)/, );
probe $code; probe \@commandlist;
Instructions for the probe stage. May be either a code reference, or a command list.
configure { ... };
Configure block. The only directive allowed in a configure block is requires.
sys { ... };
System block. Allowed directives are: requires and gather.
share { ... };
System block. Allowed directives are: download, fetch, decode, prefer, extract, build, gather.
share { download $code; download \@commandlist; };
Instructions for the download stage. May be either a code reference, or a command list.
share { fetch $code; fetch \@commandlist; };
Instructions for the fetch stage. May be either a code reference, or a command list.
share { decode $code; decode \@commandlist; };
Instructions for the decode stage. May be either a code reference, or a command list.
share { prefer $code; prefer \@commandlist; };
Instructions for the prefer stage. May be either a code reference, or a command list.
share { extract $code; extract \@commandlist; };
Instructions for the extract stage. May be either a code reference, or a command list.
share { patch $code; patch \@commandlist; };
Instructions for the patch stage. May be either a code reference, or a command list.
share { build $code; build \@commandlist; };
Instructions for the build stage. May be either a code reference, or a command list.
gather $code; gather \@commandlist; share { gather $code; gather \@commandlist; }; sys { gather $code; gather \@commandlist; };
Instructions for the gather stage. May be either a code reference, or a command list. In the root block of the alienfile it will trigger in both share and system build. In the share or sys block it will only trigger in the corresponding build.
my $hash = meta_prop;
Get the meta_prop hash reference.
my $meta = meta;
Returns the meta object for your alienfile.
Alien::Build, Alien::Build::MM, Alien::Base
Graham Ollis <plicease@cpan.org>
This software is copyright (c) 2017 by Graham Ollis.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Alien::Build, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Alien::Build
CPAN shell
perl -MCPAN -e shell install Alien::Build
For more information on module installation, please visit the detailed CPAN module installation guide.