Initial Commit

This commit is contained in:
Riley Schneider
2025-12-03 16:38:10 +01:00
parent c5e26bf594
commit b732d8d4b5
17680 changed files with 5977495 additions and 2 deletions

View File

@@ -0,0 +1,115 @@
# PODNAME: Alien::Build::Plugin::Build
# ABSTRACT: Build Alien::Build plugins
# VERSION
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Build - Build Alien::Build plugins
=head1 VERSION
version 2.38
=head1 SYNOPSIS
For autoconf:
use alienfile;
plugin 'Build::Autoconf';
for unixy (even on windows):
use alienfile;
plugin 'Build::MSYS';
=head1 DESCRIPTION
Build plugins provide tools for building your package once it has been
downloaded and extracted.
=over 4
=item L<Alien::Build::Plugin::Build::Autoconf>
=item L<Alien::Build::Plugin::Build::MSYS>
=back
=head1 SEE ALSO
L<Alien::Build>, L<Alien::Build::Plugin>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,339 @@
package Alien::Build::Plugin::Build::Autoconf;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use constant _win => $^O eq 'MSWin32';
use Path::Tiny ();
use File::Temp ();
# ABSTRACT: Autoconf plugin for Alien::Build
our $VERSION = '2.38'; # VERSION
has with_pic => 1;
has ffi => 0;
has msys_version => undef;
has config_site => sub {
my $config_site = "# file automatically generated by @{[ __FILE__ ]}\n";
$config_site .= ". $ENV{CONFIG_SITE}\n" if defined $ENV{CONFIG_SITE};
$config_site .= ". $ENV{ALIEN_BUILD_SITE_CONFIG}\n" if defined $ENV{ALIEN_BUILD_SITE_CONFIG};
# on some platforms autofools sorry I mean autotools likes to install into
# exec_prefix/lib64 or even worse exec_prefix/lib/64 but that messes everything
# else up so we try to nip that in the bud.
$config_site .= "libdir='\${prefix}/lib'\n";
$config_site;
};
sub init
{
my($self, $meta) = @_;
$meta->apply_plugin('Build::MSYS',
(defined $self->msys_version ? (msys_version => $self->msys_version) : ()),
);
$meta->prop->{destdir} = 1;
$meta->prop->{autoconf} = 1;
my $intr = $meta->interpolator;
my $set_autoconf_prefix = sub {
my($build) = @_;
my $prefix = $build->install_prop->{prefix};
die "Prefix is not set. Did you forget to run 'make alien_prefix'?"
unless $prefix;
if(_win)
{
$prefix = Path::Tiny->new($prefix)->stringify;
$prefix =~ s!^([a-z]):!/$1!i if _win;
}
$build->install_prop->{autoconf_prefix} = $prefix;
};
$meta->before_hook(
build_ffi => $set_autoconf_prefix,
);
# FFI mode undocumented for now...
if($self->ffi)
{
$meta->add_requires('configure', 'Alien::Build::Plugin::Build::Autoconf' => '0.41');
$meta->default_hook(
build_ffi => [
'%{configure} --enable-shared --disable-static --libdir=%{.install.autoconf_prefix}/dynamic',
'%{make}',
'%{make} install',
]
);
if($^O eq 'MSWin32')
{
# for whatever reason autohell puts the .dll files in bin, even if you
# point --bindir somewhere else.
$meta->after_hook(
build_ffi => sub {
my($build) = @_;
my $prefix = $build->install_prop->{autoconf_prefix};
my $bin = Path::Tiny->new($ENV{DESTDIR})->child($prefix)->child('bin');
my $lib = Path::Tiny->new($ENV{DESTDIR})->child($prefix)->child('dynamic');
if(-d $bin)
{
foreach my $from (grep { $_->basename =~ /.dll$/i } $bin->children)
{
$lib->mkpath;
my $to = $lib->child($from->basename);
$build->log("copy $from => $to");
$from->copy($to);
}
}
}
);
}
}
$meta->around_hook(
build => sub {
my $orig = shift;
my $build = shift;
$set_autoconf_prefix->($build);
my $prefix = $build->install_prop->{autoconf_prefix};
die "Prefix is not set. Did you forget to run 'make alien_prefix'?"
unless $prefix;
local $ENV{CONFIG_SITE} = do {
my $site_config = Path::Tiny->new(File::Temp::tempdir( CLEANUP => 1 ))->child('config.site');
$site_config->spew($self->config_site);
"$site_config";
};
$intr->replace_helper(
configure => sub {
my $configure;
if($build->meta_prop->{out_of_source})
{
my $extract = $build->install_prop->{extract};
$configure = _win ? "sh $extract/configure" : "$extract/configure";
}
else
{
$configure = _win ? 'sh ./configure' : './configure';
}
$configure .= ' --prefix=' . $prefix;
$configure .= ' --with-pic' if $self->with_pic;
$configure;
}
);
my $ret = $orig->($build, @_);
if(_win)
{
my $real_prefix = Path::Tiny->new($build->install_prop->{prefix});
my @pkgconf_dirs;
push @pkgconf_dirs, Path::Tiny->new($ENV{DESTDIR})->child($prefix)->child("$_/pkgconfig") for qw(lib share);
# for any pkg-config style .pc files that are dropped, we need
# to convert the MSYS /C/Foo style paths to C:/Foo
for my $pkgconf_dir (@pkgconf_dirs) {
if(-d $pkgconf_dir)
{
foreach my $pc_file ($pkgconf_dir->children)
{
$pc_file->edit(sub {s/\Q$prefix\E/$real_prefix->stringify/eg;});
}
}
}
}
$ret;
},
);
$intr->add_helper(
configure => sub {
my $configure = _win ? 'sh configure' : './configure';
$configure .= ' --with-pic' if $self->with_pic;
$configure;
},
);
$meta->default_hook(
build => [
'%{configure} --disable-shared',
'%{make}',
'%{make} install',
]
);
$self;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Build::Autoconf - Autoconf plugin for Alien::Build
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Build::Autoconf';
=head1 DESCRIPTION
This plugin provides some tools for building projects that use autoconf. The main thing
this provides is a C<configure> helper, documented below and the default build stage,
which is:
'%{configure} --disable-shared',
'%{make}',
'%{make} install',
On Windows, this plugin also pulls in the L<Alien::Build::Plugin::Build::MSYS> which is
required for autoconf style projects on windows.
The other thing that this plugin does is that it does a double staged C<DESTDIR> install.
The author has found this improves the overall reliability of L<Alien> modules that are
based on autoconf packages.
This plugin supports out-of-source builds (known in autoconf terms as "VPATH" builds) via
the meta property C<out_of_source>.
=head1 PROPERTIES
=head2 with_pic
Adds C<--with-pic> option when running C<configure>. If supported by your package, it
will generate position independent code on platforms that support it. This is required
to XS modules, and generally what you want.
autoconf normally ignores options that it does not understand, so it is usually a safe
and reasonable default to include it. A small number of projects look like they use
autoconf, but are really an autoconf style interface with a different implementation.
They may fail if you try to provide it with options such as C<--with-pic> that they do
not recognize. Such packages are the rationale for this property.
=head2 msys_version
The version of L<Alien::MSYS> required if it is deemed necessary. If L<Alien::MSYS>
isn't needed (if running under Unix, or MSYS2, for example) this will do nothing.
=head2 config_site
The content for the generated C<config.site>.
=head1 HELPERS
=head2 configure
%{configure}
The correct incantation to start an autoconf style C<configure> script on your platform.
Some reasonable default flags will be provided.
=head1 ENVIRONMENT
=over 4
=item C<ALIEN_BUILD_SITE_CONFIG>
This plugin needs to alter the behavior of autotools via the C<site.config> file and so sets
and possibly overrides any existing C<SITE_CONFIG>. Normally that is what you want but you
can also insert your own C<site.config> in addition by using this environment variable.
=back
=head1 SEE ALSO
L<Alien::Build::Plugin::Build::MSYS>, L<Alien::Build::Plugin>, L<Alien::Build>, L<Alien::Base>, L<Alien>
L<https://www.gnu.org/software/autoconf/autoconf.html>
L<https://www.gnu.org/prep/standards/html_node/DESTDIR.html>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,276 @@
package Alien::Build::Plugin::Build::CMake;
use strict;
use warnings;
use 5.008004;
use Config;
use Alien::Build::Plugin;
use Capture::Tiny qw( capture );
# ABSTRACT: CMake plugin for Alien::Build
our $VERSION = '2.38'; # VERSION
sub cmake_generator
{
if($^O eq 'MSWin32')
{
return 'MinGW Makefiles' if is_dmake();
{
my($out, $err) = capture { system $Config{make}, '/?' };
return 'NMake Makefiles' if $out =~ /NMAKE/;
}
{
my($out, $err) = capture { system $Config{make}, '--version' };
return 'MinGW Makefiles' if $out =~ /GNU Make/;
}
die 'make not detected';
}
else
{
return 'Unix Makefiles';
}
}
sub init
{
my($self, $meta) = @_;
$meta->prop->{destdir} = $^O eq 'MSWin32' ? 0 : 1;
$meta->add_requires('configure' => 'Alien::Build::Plugin::Build::CMake' => '0.99');
$meta->add_requires('share' => 'Alien::cmake3' => '0.02');
if(is_dmake())
{
# even on at least some older versions of strawberry that do not
# use it, come with gmake in the PATH. So to save us the effort
# of having to install Alien::gmake lets just use that version
# if we can find it!
my $found_gnu_make = 0;
foreach my $exe (qw( gmake make mingw32-make ))
{
my($out, $err) = capture { system $exe, '--version' };
if($out =~ /GNU Make/)
{
$meta->interpolator->replace_helper('make' => sub { $exe });
$found_gnu_make = 1;
last;
}
}
if(!$found_gnu_make)
{
$meta->add_requires('share' => 'Alien::gmake' => '0.20');
$meta->interpolator->replace_helper('make' => sub { require Alien::gmake; Alien::gmake->exe });
}
}
$meta->interpolator->replace_helper('cmake' => sub { require Alien::cmake3; Alien::cmake3->exe });
$meta->interpolator->add_helper('cmake_generator' => \&cmake_generator);
my @args = (
-G => '%{cmake_generator}',
'-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true',
'-DCMAKE_INSTALL_PREFIX:PATH=%{.install.prefix}',
'-DCMAKE_INSTALL_LIBDIR:PATH=lib',
'-DCMAKE_MAKE_PROGRAM:PATH=%{make}',
);
$meta->prop->{plugin_build_cmake}->{args} = \@args;
$meta->default_hook(
build => [
['%{cmake}', @args, '%{.install.extract}' ],
['%{make}' ],
['%{make}', 'install' ],
],
);
# TODO: handle destdir on windows ??
}
my $is_dmake;
sub is_dmake
{
unless(defined $is_dmake)
{
if($^O eq 'MSWin32')
{
my($out, $err) = capture { system $Config{make}, '-V' };
$is_dmake = $out =~ /dmake/ ? 1 : 0;
}
else
{
$is_dmake = 0;
}
}
$is_dmake;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Build::CMake - CMake plugin for Alien::Build
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
share {
plugin 'Build::CMake';
build [
# this is the default build step, if you do not specify one.
[ '%{cmake}',
@{ meta->prop->{plugin_build_cmake}->{args} },
# ... put extra cmake args here ...
'%{.install.extract}'
],
'%{make}',
'%{make} install',
];
};
=head1 DESCRIPTION
This plugin helps build alienized projects that use C<cmake>.
The intention is to make this a core L<Alien::Build> plugin if/when
it becomes stable enough.
This plugin provides a meta property C<plugin_build_cmake.args> which may change over time
but for the moment includes:
-G %{cmake_generator} \
-DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=true \
-DCMAKE_INSTALL_PREFIX:PATH=%{.install.prefix} \
-DCMAKE_INSTALL_LIBDIR:PATH=lib \
-DCMAKE_MAKE_PROGRAM:PATH=%{make}
This plugin supports out-of-source builds via the meta property C<out_of_source>.
=head1 METHODS
=head2 cmake_generator
Returns the C<cmake> generator according to your Perl's C<make>.
=head2 is_dmake
Returns true if your Perls C<make> appears to be C<dmake>.
=head1 HELPERS
=head2 cmake
This plugin replaces the default C<cmake> helper with the one that comes from L<Alien::cmake3>.
=head2 cmake_generator
This is the appropriate C<cmake> generator to use based on the make used by your Perl. This is
frequently C<Unix Makefiles>. One place where it may be different is if your Windows Perl uses
C<nmake>, which comes with Visual C++.
=head2 make
This plugin I<may> replace the default C<make> helper if the default C<make> is not supported by
C<cmake>. This is most often an issue with older versions of Strawberry Perl which used C<dmake>.
On Perls that use C<dmake>, this plugin will search for GNU Make in the PATH, and if it can't be
found will fallback on using L<Alien::gmake>.
=head1 SEE ALSO
=over 4
=item L<Alien::Build>
=item L<Alien::Build::Plugin::Build::Autoconf>
=item L<alienfile>
=back
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,175 @@
package Alien::Build::Plugin::Build::Copy;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Path::Tiny ();
# ABSTRACT: Copy plugin for Alien::Build
our $VERSION = '2.38'; # VERSION
sub init
{
my($self, $meta) = @_;
$meta->add_requires( 'configure', __PACKAGE__, 0);
if($^O eq 'MSWin32')
{
$meta->register_hook(build => sub {
my($build) = @_;
my $stage = Path::Tiny->new($build->install_prop->{stage})->canonpath;
$build->system("xcopy . $stage /E");
});
}
else
{
$meta->register_hook(build => [
'cp -aR * %{.install.stage}', # TODO: some platforms might not support -a
# I think most platforms will support -r
]);
}
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Build::Copy - Copy plugin for Alien::Build
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Build::Copy';
=head1 DESCRIPTION
This plugin copies all of the files from the source to the staging prefix.
This is mainly useful for software packages that are provided as binary
blobs. It works on both Unix and Windows using the appropriate commands
for those platforms without having worry about the platform details in your
L<alienfile>.
If you want to filter add or remove files from what gets installed you can
use a C<before> hook.
build {
...
before 'build' => sub {
# remove or modify files
};
plugin 'Build::Copy';
...
};
Some packages might have binary blobs on some platforms and require build
from source on others. In that situation you can use C<if> statements
with the appropriate logic in your L<alienfile>.
configure {
# normally the Build::Copy plugin will insert itself
# as a config requires, but since it is only used
# on some platforms, you will want to explicitly
# require it in your alienfile in case you build your
# alien dist on a platform that doesn't use it.
requires 'Alien::Build::Plugin::Build::Copy';
};
build {
...
if($^O eq 'linux')
{
start_url 'http://example.com/binary-blob-linux.tar.gz';
plugin 'Download';
plugin 'Extract' => 'tar.gz';
plugin 'Build::Copy';
}
else
{
start_url 'http://example.com/source.tar.gz';
plugin 'Download';
plugin 'Extract' => 'tar.gz';
plugin 'Build::Autoconf';
}
};
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,189 @@
package Alien::Build::Plugin::Build::MSYS;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use File::Which ();
use Env qw( @PATH );
# ABSTRACT: MSYS plugin for Alien::Build
our $VERSION = '2.38'; # VERSION
has msys_version => '0.07';
sub init
{
my($self, $meta) = @_;
if($self->msys_version ne '0.07')
{
$meta->add_requires('configure' => 'Alien::Build::Plugin::Build::MSYS' => '0.84');
}
if(_win_and_needs_msys($meta))
{
$meta->add_requires('share' => 'Alien::MSYS' => $self->msys_version);
$meta->around_hook(
$_ => sub {
my $orig = shift;
my $build = shift;
local $ENV{PATH} = $ENV{PATH};
unshift @PATH, Alien::MSYS::msys_path();
$orig->($build, @_);
},
) for qw( build build_ffi test_share test_ffi );
}
if($^O eq 'MSWin32')
{
# Most likely if we are trying to build something unix-y and
# we are using MSYS, then we want to use the make that comes
# with MSYS.
$meta->interpolator->replace_helper(
make => sub { 'make' },
);
}
$self;
}
sub _win_and_needs_msys
{
my($meta) = @_;
# check to see if we are running on windows.
# if we are running on windows, check to see if
# it is MSYS2, then we can just use that. Otherwise
# we are probably on Strawberry, or (less likely)
# VC Perl, in which case we will still need Alien::MSYS
return 0 unless $^O eq 'MSWin32';
return 0 if $meta->prop->{platform}->{system_type} eq 'windows-mingw';
return 1;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Build::MSYS - MSYS plugin for Alien::Build
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Build::MSYS';
=head1 DESCRIPTION
This plugin sets up the MSYS environment for your build on Windows. It does
not do anything on non-windows platforms. MSYS provides the essential tools
for building software that is normally expected in a UNIX or POSIX environment.
This like C<sh>, C<awk> and C<make>. To provide MSYS, this plugin uses
L<Alien::MSYS>.
=head1 PROPERTIES
=head2 msys_version
The version of L<Alien::MSYS> required if it is deemed necessary. If L<Alien::MSYS>
isn't needed (if running under Unix, or MSYS2, for example) this will do nothing.
=head1 HELPERS
=head2 make
%{make}
On windows the default C<%{make}> helper is replace with the make that comes with
L<Alien::MSYS>. This is almost certainly what you want, as most unix style make
projects will not build with C<nmake> or C<dmake> typically used by Perl on Windows.
=head1 SEE ALSO
L<Alien::Build::Plugin::Autoconf>, L<Alien::Build::Plugin>, L<Alien::Build>, L<Alien::Base>, L<Alien>
L<http://www.mingw.org/wiki/MSYS>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,209 @@
package Alien::Build::Plugin::Build::Make;
use strict;
use warnings;
use 5.008004;
use Carp ();
use Capture::Tiny qw( capture );
use Alien::Build::Plugin;
# ABSTRACT: Make plugin for Alien::Build
our $VERSION = '2.38'; # VERSION
has '+make_type' => undef;
sub init
{
my($self, $meta) = @_;
$meta->add_requires('configure', 'Alien::Build::Plugin::Build::Make', '0.99');
my $type = $self->make_type;
return unless defined $type;
$type = 'gmake' if $^O eq 'MSWin32' && $type eq 'umake';
if($type eq 'nmake')
{
$meta->interpolator->replace_helper( make => sub { 'nmake' } );
}
elsif($type eq 'dmake')
{
$meta->interpolator->replace_helper( make => sub { 'dmake' } );
}
elsif($type eq 'gmake')
{
my $found = 0;
foreach my $make (qw( gmake make mingw32-make ))
{
my($out, $err) = capture { system $make, '--version' };
if($out =~ /GNU Make/)
{
$meta->interpolator->replace_helper( make => sub { $make } );
$found = 1;
}
}
unless($found)
{
$meta->add_requires('share' => 'Alien::gmake' => '0.20');
$meta->interpolator->replace_helper('make' => sub { require Alien::gmake; Alien::gmake->exe });
}
}
elsif($type eq 'umake')
{
# nothing
}
else
{
Carp::croak("unknown make type = ", $self->make_type);
}
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Build::Make - Make plugin for Alien::Build
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
# For a recipe that requires GNU Make
plugin 'Build::Make' => 'gmake';
=head1 DESCRIPTION
By default L<Alien::Build> provides a helper for the C<make> that is used by Perl and L<ExtUtils::MakeMaker> itself.
This is handy, because it is the one make that you can mostly guarantee that you will have. Unfortunately it may be
a C<make> that isn't supported by the library or tool that you are trying to alienize. This is mostly a problem on
Windows, where the supported C<make>s for years were Microsoft's C<nmake> and Sun's C<dmake>, which many open source
projects do not use. This plugin will alter the L<alienfile> recipe to use a different C<make>. It may (as in the
case of C<gmake> / L<Alien::gmake>) automatically download and install an alienized version of that C<make> if it
is not already installed.
This plugin should NOT be used with other plugins that replace the C<make> helper, like
L<Alien::Build::Plugin::Build::CMake>, L<Alien::Build::Plugin::Build::Autoconf>,
L<Alien::Build::Plugin::Build::MSYS>. This plugin is intended instead for projects that use vanilla makefiles of
a specific type.
This plugin is for now distributed separately from L<Alien::Build>, but the intention is for it to soon become
a core plugin for L<Alien::Build>.
=head1 PROPERTIES
=head2 make_type
The make type needed by the L<alienfile> recipe:
=over 4
=item dmake
Sun's dmake.
=item gmake
GNU Make.
=item nmake
Microsoft's nmake. It comes with Visual C++.
=item umake
Any UNIX C<make> Usually either BSD or GNU Make.
=back
=head1 HELPERS
=head2 make
%{make}
This plugin may change the make helper used by your L<alienfile> recipe.
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,234 @@
package Alien::Build::Plugin::Build::SearchDep;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Text::ParseWords qw( shellwords );
# ABSTRACT: Add dependencies to library and header search path
our $VERSION = '2.38'; # VERSION
has aliens => {};
has public_I => 0;
has public_l => 0;
sub init
{
my($self, $meta) = @_;
$meta->add_requires('configure' => 'Alien::Build::Plugin::Build::SearchDep' => '0.35');
$meta->add_requires('share' => 'Env::ShellWords' => 0.01);
if($self->public_I || $self->public_l)
{
$meta->add_requires('configure' => 'Alien::Build::Plugin::Build::SearchDep' => '0.53');
}
my @aliens;
if(ref($self->aliens) eq 'HASH')
{
@aliens = keys %{ $self->aliens };
$meta->add_requires('share' => $_ => $self->aliens->{$_}) for @aliens;
}
else
{
@aliens = ref $self->aliens ? @{ $self->aliens } : ($self->aliens);
$meta->add_requires('share' => $_ => 0) for @aliens;
}
$meta->around_hook(
build => sub {
my($orig, $build) = @_;
local $ENV{CFLAGS} = $ENV{CFLAGS};
local $ENV{CXXFLAGS} = $ENV{CXXFLAGS};
local $ENV{LDFLAGS} = $ENV{LDFLAGS};
tie my @CFLAGS, 'Env::ShellWords', 'CFLAGS';
tie my @CXXFLAGS, 'Env::ShellWords', 'CXXFLAGS';
tie my @LDFLAGS, 'Env::ShellWords', 'LDFLAGS';
my $cflags = $build->install_prop->{plugin_build_searchdep_cflags} = [];
my $ldflags = $build->install_prop->{plugin_build_searchdep_ldflags} = [];
my $libs = $build->install_prop->{plugin_build_searchdep_libs} = [];
foreach my $other (@aliens)
{
my $other_cflags;
my $other_libs;
if($other->install_type('share'))
{
$other_cflags = $other->cflags_static;
$other_libs = $other->libs_static;
}
else
{
$other_cflags = $other->cflags;
$other_libs = $other->libs;
}
unshift @$cflags, grep /^-I/, shellwords($other_cflags);
unshift @$ldflags, grep /^-L/, shellwords($other_libs);
unshift @$libs, grep /^-l/, shellwords($other_libs);
}
unshift @CFLAGS, @$cflags;
unshift @CXXFLAGS, @$cflags;
unshift @LDFLAGS, @$ldflags;
$orig->($build);
},
);
$meta->after_hook(
gather_share => sub {
my($build) = @_;
$build->runtime_prop->{libs} = '' unless defined $build->runtime_prop->{libs};
$build->runtime_prop->{libs_static} = '' unless defined $build->runtime_prop->{libs_static};
if($self->public_l)
{
$build->runtime_prop->{$_} = join(' ', _space_escape(@{ $build->install_prop->{plugin_build_searchdep_libs} })) . ' ' . $build->runtime_prop->{$_}
for qw( libs libs_static );
}
$build->runtime_prop->{$_} = join(' ', _space_escape(@{ $build->install_prop->{plugin_build_searchdep_ldflags} })) . ' ' . $build->runtime_prop->{$_}
for qw( libs libs_static );
if($self->public_I)
{
$build->runtime_prop->{cflags} = '' unless defined $build->runtime_prop->{cflags};
$build->runtime_prop->{cflags_static} = '' unless defined $build->runtime_prop->{cflags_static};
$build->runtime_prop->{$_} = join(' ', _space_escape(@{ $build->install_prop->{plugin_build_searchdep_cflags} })) . ' ' . $build->runtime_prop->{$_}
for qw( cflags cflags_static );
}
},
);
}
sub _space_escape
{
map {
my $str = $_;
$str =~ s{(\s)}{\\$1}g;
$str;
} @_;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Build::SearchDep - Add dependencies to library and header search path
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Build::SearchDep' => (
aliens => [qw( Alien::Foo Alien::Bar )],
);
=head1 DESCRIPTION
This plugin adds the other aliens as prerequisites, and adds their header and library
search path to C<CFLAGS> and C<LDFLAGS> environment variable, so that tools that use
them (like autoconf) can pick them up.
=head1 PROPERTIES
=head2 aliens
Either a list reference or hash reference of the other aliens. If a hash reference
then the keys are the class names and the values are the versions of those classes.
=head2 public_I
Include the C<-I> flags when setting the runtime cflags property.
=head2 public_l
Include the C<-l> flags when setting the runtime libs property.
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,109 @@
# PODNAME: Alien::Build::Plugin::Core
# ABSTRACT: Core Alien::Build plugins
# VERSION
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Core - Core Alien::Build plugins
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
# core plugins are already loaded
=head1 DESCRIPTION
Core plugins are special plugins that are always loaded, usually first.
=over 4
=item L<Alien::Build::Plugin::Core::Gather>
=item L<Alien::Build::Plugin::Core::Legacy>
Add interoperability with L<Alien::Base::ModuleBuild>
=back
=head1 SEE ALSO
L<Alien::Build>, L<Alien::Build::Plugin>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,139 @@
package Alien::Build::Plugin::Core::CleanInstall;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Path::Tiny ();
# ABSTRACT: Implementation for clean_install hook.
our $VERSION = '2.38'; # VERSION
sub init
{
my($self, $meta) = @_;
$meta->default_hook(
clean_install => sub {
my($build) = @_;
my $root = Path::Tiny->new(
$build->runtime_prop->{prefix}
);
if(-d $root)
{
foreach my $child ($root->children)
{
if($child->basename eq '_alien')
{
$build->log("keeping $child");
}
else
{
$build->log("removing $child");
$child->remove_tree({ safe => 0});
}
}
}
}
);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Core::CleanInstall - Implementation for clean_install hook.
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
# already loaded
=head1 DESCRIPTION
This plugin implements the default C<clean_install> hook.
You shouldn't use it directly.
=head1 SEE ALSO
L<Alien::Build>, L<Alien::Base::ModuleBuild>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,211 @@
package Alien::Build::Plugin::Core::Download;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Path::Tiny ();
use Alien::Build::Util qw( _mirror );
# ABSTRACT: Core download plugin
our $VERSION = '2.38'; # VERSION
sub _hook
{
my($build) = @_;
my $res = $build->fetch;
if($res->{type} =~ /^(?:html|dir_listing)$/)
{
my $type = $res->{type};
$type =~ s/_/ /;
$build->log("decoding $type");
$res = $build->decode($res);
}
if($res->{type} eq 'list')
{
$res = $build->prefer($res);
die "no matching files in listing" if @{ $res->{list} } == 0;
my $version = $res->{list}->[0]->{version};
my($pick, @other) = map { $_->{url} } @{ $res->{list} };
if(@other > 8)
{
splice @other, 7;
push @other, '...';
}
$build->log("candidate *$pick");
$build->log("candidate $_") for @other;
$res = $build->fetch($pick);
if($version)
{
$version =~ s/\.+$//;
$build->log("setting version based on archive to $version");
$build->runtime_prop->{version} = $version;
}
}
if($res->{type} eq 'file')
{
my $alienfile = $res->{filename};
$build->log("downloaded $alienfile");
if($res->{content})
{
my $tmp = Alien::Build::TempDir->new($build, "download");
my $path = Path::Tiny->new("$tmp/$alienfile");
$path->spew_raw($res->{content});
$build->install_prop->{download} = $path->stringify;
$build->install_prop->{complete}->{download} = 1;
return $build;
}
elsif($res->{path})
{
if(defined $res->{tmp} && !$res->{tmp})
{
if(-e $res->{path})
{
$build->install_prop->{download} = $res->{path};
$build->install_prop->{complete}->{download} = 1;
}
else
{
die "not a file or directory: @{[ $res->{path} ]}";
}
}
else
{
my $from = Path::Tiny->new($res->{path});
my $tmp = Alien::Build::TempDir->new($build, "download");
my $to = Path::Tiny->new("$tmp/@{[ $from->basename ]}");
if(-d $res->{path})
{
# Please note: _mirror and Alien::Build::Util are ONLY
# allowed to be used by core plugins. If you are writing
# a non-core plugin it may be removed. That is why it
# is private.
_mirror $from, $to;
}
else
{
require File::Copy;
File::Copy::copy(
"$from" => "$to",
) || die "copy $from => $to failed: $!";
}
$build->install_prop->{download} = $to->stringify;
$build->install_prop->{complete}->{download} = 1;
}
return $build;
}
die "file without content or path";
}
die "unknown fetch response type: @{[ $res->{type} ]}";
}
sub init
{
my($self, $meta) = @_;
$meta->default_hook(download => \&_hook);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Core::Download - Core download plugin
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
# already loaded
=head1 DESCRIPTION
This plugin does some core download logic.
=head1 SEE ALSO
L<Alien::Build>, L<Alien::Base::ModuleBuild>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,121 @@
package Alien::Build::Plugin::Core::FFI;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
# ABSTRACT: Core FFI plugin
our $VERSION = '2.38'; # VERSION
sub init
{
my($self, $meta) = @_;
$meta->default_hook(
$_ => sub {},
) for qw( build_ffi gather_ffi );
$meta->prop->{destdir_ffi_filter} = '^dynamic';
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Core::FFI - Core FFI plugin
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
# already loaded
=head1 DESCRIPTION
This plugin helps make the build_ffi work. You should not
need to interact with it directly.
=head1 SEE ALSO
L<Alien::Build>, L<Alien::Base::ModuleBuild>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,239 @@
package Alien::Build::Plugin::Core::Gather;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Env qw( @PATH @PKG_CONFIG_PATH );
use Path::Tiny ();
use File::chdir;
use Alien::Build::Util qw( _mirror _destdir_prefix );
use JSON::PP ();
# ABSTRACT: Core gather plugin
our $VERSION = '2.38'; # VERSION
sub init
{
my($self, $meta) = @_;
$meta->default_hook(
$_ => sub {},
) for qw( gather_system gather_share );
$meta->around_hook(
gather_share => sub {
my($orig, $build) = @_;
local $ENV{PATH} = $ENV{PATH};
local $ENV{PKG_CONFIG_PATH} = $ENV{PKG_CONFIG_PATH};
unshift @PATH, Path::Tiny->new('bin')->absolute->stringify
if -d 'bin';
for my $dir (qw(share lib)) {
unshift @PKG_CONFIG_PATH, Path::Tiny->new("$dir/pkgconfig")->absolute->stringify
if -d "$dir/pkgconfig";
}
$orig->($build)
}
);
foreach my $type (qw( share ffi ))
{
$meta->around_hook(
"gather_$type" => sub {
my($orig, $build) = @_;
if($build->meta_prop->{destdir})
{
my $destdir = $ENV{DESTDIR};
if(-d $destdir)
{
my $src = Path::Tiny->new(_destdir_prefix($ENV{DESTDIR}, $build->install_prop->{prefix}));
my $dst = Path::Tiny->new($build->install_prop->{stage});
my $res = do {
local $CWD = "$src";
$orig->($build);
};
$build->log("mirror $src => $dst");
$dst->mkpath;
# Please note: _mirror and Alien::Build::Util are ONLY
# allowed to be used by core plugins. If you are writing
# a non-core plugin it may be removed. That is why it
# is private.
_mirror("$src", "$dst", {
verbose => 1,
filter => $build->meta_prop->{$type eq 'share' ? 'destdir_filter' : 'destdir_ffi_filter'},
});
return $res;
}
else
{
die "nothing was installed into destdir" if $type eq 'share';
}
}
else
{
local $CWD = $build->install_prop->{stage};
my $ret = $orig->($build);
# if we are not doing a double staged install we want to substitute the install
# prefix with the runtime prefix.
my $old = $build->install_prop->{prefix};
my $new = $build->runtime_prop->{prefix};
foreach my $flag (qw( cflags cflags_static libs libs_static ))
{
next unless defined $build->runtime_prop->{$flag};
$build->runtime_prop->{$flag} =~ s{(-I|-L|-LIBPATH:)\Q$old\E}{$1 . $new}eg;
}
return $ret;
}
}
);
}
$meta->after_hook(
$_ => sub {
my($build) = @_;
die "stage is not defined. be sure to call set_stage on your Alien::Build instance"
unless $build->install_prop->{stage};
my $stage = Path::Tiny->new($build->install_prop->{stage});
$build->log("mkdir -p $stage/_alien");
$stage->child('_alien')->mkpath;
# drop a alien.json file for the runtime properties
$stage->child('_alien/alien.json')->spew(
JSON::PP->new->pretty->canonical(1)->ascii->encode($build->runtime_prop)
);
# copy the alienfile, if we managed to keep it around.
if($build->meta->filename &&
-r $build->meta->filename &&
$build->meta->filename !~ /\.(pm|pl)$/ &&
! -d $build->meta->filename)
{
Path::Tiny->new($build->meta->filename)
->copy($stage->child('_alien/alienfile'));
}
if($build->install_prop->{patch} && -d $build->install_prop->{patch})
{
# Please note: _mirror and Alien::Build::Util are ONLY
# allowed to be used by core plugins. If you are writing
# a non-core plugin it may be removed. That is why it
# is private.
_mirror($build->install_prop->{patch},
$stage->child('_alien/patch')->stringify);
}
},
) for qw( gather_share gather_system );
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Core::Gather - Core gather plugin
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
# already loaded
=head1 DESCRIPTION
This plugin helps make the gather stage work.
=head1 SEE ALSO
L<Alien::Build>, L<Alien::Base::ModuleBuild>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,139 @@
package Alien::Build::Plugin::Core::Legacy;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
# ABSTRACT: Core Alien::Build plugin to maintain compatibility with legacy Alien::Base
our $VERSION = '2.38'; # VERSION
sub init
{
my($self, $meta) = @_;
$meta->after_hook(
$_ => sub {
my($build) = @_;
$build->log("adding legacy hash to config");
my $runtime = $build->runtime_prop;
if($runtime->{cflags} && ! defined $runtime->{cflags_static})
{
$runtime->{cflags_static} = $runtime->{cflags};
}
if($runtime->{libs} && ! defined $runtime->{libs_static})
{
$runtime->{libs_static} = $runtime->{libs};
}
$runtime->{legacy}->{finished_installing} = 1;
$runtime->{legacy}->{install_type} = $runtime->{install_type};
$runtime->{legacy}->{version} = $runtime->{version};
$runtime->{legacy}->{original_prefix} = $runtime->{prefix};
}
) for qw( gather_system gather_share );
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Core::Legacy - Core Alien::Build plugin to maintain compatibility with legacy Alien::Base
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
# already loaded
=head1 DESCRIPTION
This plugin provides some compatibility with the legacy L<Alien::Build::ModuleBuild>
interfaces.
=head1 SEE ALSO
L<Alien::Build>, L<Alien::Base::ModuleBuild>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,120 @@
package Alien::Build::Plugin::Core::Override;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
# ABSTRACT: Core override plugin
our $VERSION = '2.38'; # VERSION
sub init
{
my($self, $meta) = @_;
$meta->default_hook(
override => sub {
my($build) = @_;
return $ENV{ALIEN_INSTALL_TYPE} || '';
},
);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Core::Override - Core override plugin
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
# already loaded
=head1 DESCRIPTION
This plugin implements the C<ALIEN_INSTALL_TYPE> environment variable.
=head1 SEE ALSO
L<Alien::Build>, L<Alien::Base::ModuleBuild>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,170 @@
package Alien::Build::Plugin::Core::Setup;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Config;
use File::Which qw( which );
# ABSTRACT: Core setup plugin
our $VERSION = '2.38'; # VERSION
sub init
{
my($self, $meta) = @_;
$meta->prop->{platform} ||= {};
$self->_platform($meta->prop->{platform});
}
sub _platform
{
my(undef, $hash) = @_;
if($^O eq 'MSWin32' && $Config{ccname} eq 'cl')
{
$hash->{compiler_type} = 'microsoft';
}
else
{
$hash->{compiler_type} = 'unix';
}
if($^O eq 'MSWin32')
{
$hash->{system_type} = 'windows-unknown';
if(defined &Win32::BuildNumber)
{
$hash->{system_type} = 'windows-activestate';
}
elsif($Config{myuname} =~ /strawberry-perl/)
{
$hash->{system_type} = 'windows-strawberry';
}
elsif($hash->{compiler_type} eq 'microsoft')
{
$hash->{system_type} = 'windows-microsoft';
}
else
{
my $uname_exe = which('uname');
if($uname_exe)
{
my $uname = `$uname_exe`;
if($uname =~ /^(MINGW)(32|64)_NT/)
{
$hash->{system_type} = 'windows-' . lc $1;
}
}
}
}
elsif($^O =~ /^(VMS)$/)
{
# others probably belong in here...
$hash->{system_type} = lc $^O;
}
else
{
$hash->{system_type} = 'unix';
}
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Core::Setup - Core setup plugin
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
# already loaded
=head1 DESCRIPTION
This plugin does some core setup for you.
=head1 SEE ALSO
L<Alien::Build>, L<Alien::Base::ModuleBuild>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,118 @@
package Alien::Build::Plugin::Core::Tail;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
# ABSTRACT: Core tail setup plugin
our $VERSION = '2.38'; # VERSION
sub init
{
my($self, $meta) = @_;
if($meta->prop->{out_of_source})
{
$meta->add_requires('configure' => 'Alien::Build' => '1.08');
}
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Core::Tail - Core tail setup plugin
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
# already loaded
=head1 DESCRIPTION
This plugin does some core tail setup for you.
=head1 SEE ALSO
L<Alien::Build>, L<Alien::Base::ModuleBuild>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,112 @@
# PODNAME: Alien::Build::Plugin::Decode
# ABSTRACT: Decode Alien::Build plugins
# VERSION
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Decode - Decode Alien::Build plugins
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Decode::HTML';
plugin 'Decode::DirListing';
=head1 DESCRIPTION
Decode plugins decode HTML and FTP file listings. Normally you
will want to use the L<Alien::Build::Plugin::Download::Negotiate>
plugin which will automatically load the appropriate Decode plugins.
=over 4
=item L<Alien::Build::Plugin::Decode::HTML>
=item L<Alien::Build::Plugin::Decode::DirListing>
=item L<Alien::Build::Plugin::Decode::DirListingFtpcopy>
=back
=head1 SEE ALSO
L<Alien::Build>, L<Alien::Build::Plugin>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,149 @@
package Alien::Build::Plugin::Decode::DirListing;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use File::Basename ();
# ABSTRACT: Plugin to extract links from a directory listing
our $VERSION = '2.38'; # VERSION
sub init
{
my($self, $meta) = @_;
$meta->add_requires('share' => 'File::Listing' => 0);
$meta->add_requires('share' => 'URI' => 0);
$meta->register_hook( decode => sub {
my(undef, $res) = @_;
die "do not know how to decode @{[ $res->{type} ]}"
unless $res->{type} eq 'dir_listing';
my $base = URI->new($res->{base});
return {
type => 'list',
list => [
map {
my($name) = @$_;
my $basename = $name;
$basename =~ s{/$}{};
my %h = (
filename => File::Basename::basename($basename),
url => URI->new_abs($name, $base)->as_string,
);
\%h;
} File::Listing::parse_dir($res->{content})
],
};
});
$self;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Decode::DirListing - Plugin to extract links from a directory listing
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Decode::DirListing';
=head1 DESCRIPTION
Note: in most case you will want to use L<Alien::Build::Plugin::Download::Negotiate>
instead. It picks the appropriate decode plugin based on your platform and environment.
In some cases you may need to use this plugin directly instead.
This plugin decodes a ftp file listing into a list of candidates for your Prefer plugin.
It is useful when fetching from an FTP server via L<Alien::Build::Plugin::Fetch::LWP>.
=head1 SEE ALSO
L<Alien::Build::Plugin::Download::Negotiate>, L<Alien::Build::Plugin::Decode::DirListingFtpcopy>, L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,154 @@
package Alien::Build::Plugin::Decode::DirListingFtpcopy;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use File::Basename ();
# ABSTRACT: Plugin to extract links from a directory listing using ftpcopy
our $VERSION = '2.38'; # VERSION
sub init
{
my($self, $meta) = @_;
$meta->add_requires('share' => 'File::Listing::Ftpcopy' => 0);
$meta->add_requires('share' => 'URI' => 0);
$meta->register_hook( decode => sub {
my(undef, $res) = @_;
die "do not know how to decode @{[ $res->{type} ]}"
unless $res->{type} eq 'dir_listing';
my $base = URI->new($res->{base});
return {
type => 'list',
list => [
map {
my($name) = @$_;
my $basename = $name;
$basename =~ s{/$}{};
my %h = (
filename => File::Basename::basename($basename),
url => URI->new_abs($name, $base)->as_string,
);
\%h;
} File::Listing::Ftpcopy::parse_dir($res->{content})
],
};
});
$self;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Decode::DirListingFtpcopy - Plugin to extract links from a directory listing using ftpcopy
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Decode::DirListingFtpcopy';
=head1 DESCRIPTION
Note: in most case you will want to use L<Alien::Build::Plugin::Download::Negotiate>
instead. It picks the appropriate decode plugin based on your platform and environment.
In some cases you may need to use this plugin directly instead.
This plugin decodes a ftp file listing into a list of candidates for your Prefer plugin.
It is useful when fetching from an FTP server via L<Alien::Build::Plugin::Fetch::LWP>.
It is different from the similarly named L<Alien::Build::Plugin::Decode::DirListingFtpcopy>
in that it uses L<File::Listing::Ftpcopy> instead of L<File::Listing>. The rationale for
the C<Ftpcopy> version is that it supports a different set of FTP servers, including
OpenVMS. In most cases, however, you probably want to use the non C<Ftpcopy> version
since it is pure perl.
=head1 SEE ALSO
L<Alien::Build::Plugin::Download::Negotiate>, L<Alien::Build::Plugin::Decode::DirListing>, L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,162 @@
package Alien::Build::Plugin::Decode::HTML;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use File::Basename ();
# ABSTRACT: Plugin to extract links from HTML
our $VERSION = '2.38'; # VERSION
sub init
{
my($self, $meta) = @_;
$meta->add_requires('share' => 'HTML::LinkExtor' => 0);
$meta->add_requires('share' => 'URI' => 0);
$meta->add_requires('share' => 'URI::Escape' => 0);
$meta->register_hook( decode => sub {
my(undef, $res) = @_;
die "do not know how to decode @{[ $res->{type} ]}"
unless $res->{type} eq 'html';
my $base = URI->new($res->{base});
my @list;
my $p = HTML::LinkExtor->new(sub {
my($tag, %links) = @_;
if($tag eq 'base' && $links{href})
{
$base = URI->new($links{href});
}
elsif($tag eq 'a' && $links{href})
{
my $href = $links{href};
return if $href =~ m!^\.\.?/?$!;
my $url = URI->new_abs($href, $base);
my $path = $url->path;
$path =~ s{/$}{}; # work around for Perl 5.8.7- gh#8
push @list, {
filename => URI::Escape::uri_unescape(File::Basename::basename($path)),
url => URI::Escape::uri_unescape($url->as_string),
};
}
});
$p->parse($res->{content});
return {
type => 'list',
list => \@list,
};
});
$self;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Decode::HTML - Plugin to extract links from HTML
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Decode::HTML';
=head1 DESCRIPTION
Note: in most case you will want to use L<Alien::Build::Plugin::Download::Negotiate>
instead. It picks the appropriate decode plugin based on your platform and environment.
In some cases you may need to use this plugin directly instead.
This plugin decodes an HTML file listing into a list of candidates for your Prefer plugin.
=head1 SEE ALSO
L<Alien::Build::Plugin::Download::Negotiate>, L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,209 @@
package Alien::Build::Plugin::Decode::Mojo;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
# ABSTRACT: Plugin to extract links from HTML using Mojo::DOM or Mojo::DOM58
our $VERSION = '2.38'; # VERSION
sub _load ($;$)
{
my($class, $version) = @_;
my $pm = "$class.pm";
$pm =~ s/::/\//g;
eval { require $pm };
return 0 if $@;
if(defined $version)
{
eval { $class->VERSION($version) };
return 0 if $@;
}
return 1;
}
has _class => sub {
return 'Mojo::DOM58' if _load 'Mojo::DOM58';
return 'Mojo::DOM' if _load 'Mojo::DOM' and _load 'Mojolicious', 7.00;
return 'Mojo::DOM58';
};
sub init
{
my($self, $meta) = @_;
$meta->add_requires('share' => 'URI' => 0);
$meta->add_requires('share' => 'URI::Escape' => 0);
my $class = $meta->prop->{plugin_decode_mojo_class} ||= $self->_class;
if($class eq 'Mojo::DOM58')
{
$meta->add_requires('share' => 'Mojo::DOM58' => '1.00');
}
elsif($class eq 'Mojo::DOM')
{
$meta->add_requires('share' => 'Mojolicious' => '7.00');
$meta->add_requires('share' => 'Mojo::DOM' => '0');
}
else
{
die "bad class";
}
$meta->register_hook( decode => sub {
my(undef, $res) = @_;
die "do not know how to decode @{[ $res->{type} ]}"
unless $res->{type} eq 'html';
my $dom = $class->new($res->{content});
my $base = URI->new($res->{base});
if(my $base_element = $dom->find('head base')->first)
{
my $href = $base_element->attr('href');
$base = URI->new($href) if defined $href;
}
my @list = map {
my $url = URI->new_abs($_, $base);
my $path = $url->path;
$path =~ s{/$}{}; # work around for Perl 5.8.7- gh#8
{
filename => URI::Escape::uri_unescape(File::Basename::basename($path)),
url => URI::Escape::uri_unescape($url->as_string),
}
}
grep !/^\.\.?\/?$/,
map { $_->attr('href') || () }
@{ $dom->find('a')->to_array };
return {
type => 'list',
list => \@list,
};
})
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Decode::Mojo - Plugin to extract links from HTML using Mojo::DOM or Mojo::DOM58
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Decode::Mojo';
Force using C<Decode::Mojo> via the download negotiator:
use alienfile 1.68;
configure {
requires 'Alien::Build::Plugin::Decode::Mojo';
};
plugin 'Download' => (
...
decoder => 'Decode::Mojo',
);
=head1 DESCRIPTION
Note: in most cases you will want to use L<Alien::Build::Plugin::Download::Negotiate>
instead. It picks the appropriate decode plugin based on your platform and environment.
In some cases you may need to use this plugin directly instead.
This plugin decodes an HTML file listing into a list of candidates for your Prefer plugin.
It works just like L<Alien::Build::Plugin::Decode::HTML> except it uses either L<Mojo::DOM>
or L<Mojo::DOM58> to do its job.
This plugin is much lighter than The C<Decode::HTML> plugin, and doesn't require XS. It
is the default decode plugin used by L<Alien::Build::Plugin::Download::Negotiate> if it
detects that you need to parse an HTML index.
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,108 @@
# PODNAME: Alien::Build::Plugin::Download
# ABSTRACT: Download Alien::Build plugins
# VERSION
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Download - Download Alien::Build plugins
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile
share {
start_url 'http://ftp.gnu.org/gnu/make';
plugin 'Download';
};
=head1 DESCRIPTION
Download plugins download packages from the internet.
=over 4
=item L<Alien::Build::Plugin::Download::Negotiate>
=back
=head1 SEE ALSO
L<Alien::Build>, L<Alien::Build::Plugin>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,377 @@
package Alien::Build::Plugin::Download::Negotiate;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Alien::Build::Util qw( _has_ssl );
use Carp ();
# ABSTRACT: Download negotiation plugin
our $VERSION = '2.38'; # VERSION
has '+url' => undef;
has 'filter' => undef;
has 'version' => undef;
has 'ssl' => 0;
has 'passive' => 0;
has 'scheme' => undef;
has 'bootstrap_ssl' => 0;
has 'prefer' => 1;
has 'decoder' => undef;
sub pick
{
my($self) = @_;
my($fetch, @decoders) = $self->_pick;
if($self->decoder)
{
@decoders = ref $self->decoder ? @{ $self->decoder } : ($self->decoder);
}
($fetch, @decoders);
}
sub _pick_decoder
{
my($self) = @_;
if(eval { require Mojo::DOM58; Mojo::DOM58->VERSION(1.00); 1 })
{ return "Decode::Mojo" }
elsif(eval { require Mojo::DOM; require Mojolicious; Mojolicious->VERSION('7.00'); 1 })
{ return "Decode::Mojo" }
elsif(eval { require HTML::LinkExtor; 1; })
{ return "Decode::HTML" }
else
{ return "Decode::Mojo" }
}
sub _pick
{
my($self) = @_;
$self->scheme(
$self->url !~ m!(ftps?|https?|file):!i
? 'file'
: $self->url =~ m!^([a-z]+):!i
) unless defined $self->scheme;
if($self->scheme eq 'https' || ($self->scheme eq 'http' && $self->ssl))
{
if($self->bootstrap_ssl && ! _has_ssl)
{
return (['Fetch::CurlCommand','Fetch::Wget'], __PACKAGE__->_pick_decoder);
}
elsif(_has_ssl)
{
return ('Fetch::HTTPTiny', __PACKAGE__->_pick_decoder);
}
elsif(do { require Alien::Build::Plugin::Fetch::CurlCommand; Alien::Build::Plugin::Fetch::CurlCommand->protocol_ok('https') })
{
return ('Fetch::CurlCommand', __PACKAGE__->_pick_decoder);
}
else
{
return ('Fetch::HTTPTiny', __PACKAGE__->_pick_decoder);
}
}
elsif($self->scheme eq 'http')
{
return ('Fetch::HTTPTiny', __PACKAGE__->_pick_decoder);
}
elsif($self->scheme eq 'ftp')
{
if($ENV{ftp_proxy} || $ENV{all_proxy})
{
return $self->scheme =~ /^ftps?/
? ('Fetch::LWP', 'Decode::DirListing', __PACKAGE__->_pick_decoder)
: ('Fetch::LWP', __PACKAGE__->_pick_decoder);
}
else
{
return ('Fetch::NetFTP');
}
}
elsif($self->scheme eq 'file')
{
return ('Fetch::Local');
}
else
{
die "do not know how to handle scheme @{[ $self->scheme ]} for @{[ $self->url ]}";
}
}
sub init
{
my($self, $meta) = @_;
unless(defined $self->url)
{
if(defined $meta->prop->{start_url})
{
$self->url($meta->prop->{start_url});
}
else
{
Carp::croak "url is a required property unless you use the start_url directive";
}
}
$meta->add_requires('share' => 'Alien::Build::Plugin::Download::Negotiate' => '0.61')
if $self->passive;
$meta->prop->{plugin_download_negotiate_default_url} = $self->url;
my($fetch, @decoders) = $self->pick;
$fetch = [ $fetch ] unless ref $fetch;
foreach my $fetch (@$fetch)
{
my @args;
push @args, ssl => $self->ssl;
# For historical reasons, we pass the URL into older fetch plugins, because
# this used to be the interface. Using start_url is now preferred!
push @args, url => $self->url if $fetch =~ /^Fetch::(HTTPTiny|LWP|Local|LocalDir|NetFTP|CurlCommand)$/;
push @args, passive => $self->passive if $fetch eq 'Fetch::NetFTP';
push @args, bootstrap_ssl => $self->bootstrap_ssl if $self->bootstrap_ssl;
$meta->apply_plugin($fetch, @args);
}
if($self->version)
{
$meta->apply_plugin($_) for @decoders;
if(defined $self->prefer && ref($self->prefer) eq 'CODE')
{
$meta->add_requires('share' => 'Alien::Build::Plugin::Download::Negotiate' => '1.30');
$meta->register_hook(
prefer => $self->prefer,
);
}
elsif($self->prefer)
{
$meta->apply_plugin('Prefer::SortVersions',
(defined $self->filter ? (filter => $self->filter) : ()),
version => $self->version,
);
}
else
{
$meta->add_requires('share' => 'Alien::Build::Plugin::Download::Negotiate' => '1.30');
}
}
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Download::Negotiate - Download negotiation plugin
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
share {
start_url 'http://ftp.gnu.org/gnu/make';
plugin 'Download' => (
filter => qr/^make-.*\.tar\.gz$/,
version => qr/([0-9\.]+)/,
);
};
=head1 DESCRIPTION
This is a negotiator plugin for downloading packages from the internet. This
plugin picks the best Fetch, Decode and Prefer plugins to do the actual work.
Which plugins are picked depend on the properties you specify, your platform
and environment. It is usually preferable to use a negotiator plugin rather
than the Fetch, Decode and Prefer plugins directly from your L<alienfile>.
=head1 PROPERTIES
=head2 url
[DEPRECATED] use C<start_url> instead.
The Initial URL for your package. This may be a directory listing (either in
HTML or ftp listing format) or the final tarball intended to be downloaded.
=head2 filter
This is a regular expression that lets you filter out files that you do not
want to consider downloading. For example, if the directory listing contained
tarballs and readme files like this:
foo-1.0.0.tar.gz
foo-1.0.0.readme
You could specify a filter of C<qr/\.tar\.gz$/> to make sure only tarballs are
considered for download.
=head2 version
Regular expression to parse out the version from a filename. The regular expression
should store the result in C<$1>.
Note: if you provide a C<version> property, this plugin will assume that you will
be downloading an initial index to select package downloads from. Depending on
the protocol (and typically this is the case for http and HTML) that may bring in
additional dependencies. If start_url points to a tarball or other archive directly
(without needing to do through an index selection process), it is recommended that
you not specify this property.
=head2 ssl
If your initial URL does not need SSL, but you know ahead of time that a subsequent
request will need it (for example, if your directory listing is on C<http>, but includes
links to C<https> URLs), then you can set this property to true, and the appropriate
Perl SSL modules will be loaded.
=head2 passive
If using FTP, attempt a passive mode transfer first, before trying an active mode transfer.
=head2 bootstrap_ssl
If set to true, then the download negotiator will avoid using plugins that have a dependency
on L<Net::SSLeay>, or other Perl SSL modules. The intent for this option is to allow
OpenSSL to be alienized and be a useful optional dependency for L<Net::SSLeay>.
The implementation may improve over time, but as of this writing, this option relies on you
having a working C<curl> or C<wget> with SSL support in your C<PATH>.
=head2 prefer
How to sort candidates for selection. This should be one of three types of values:
=over 4
=item code reference
This will be used as the prefer hook.
=item true value
Use L<Alien::Build::Plugin::Prefer::SortVersions>.
=item false value
Don't set any preference at all. A hook must be installed, or another prefer plugin specified.
=back
=head2 decoder
Override the detected decoder.
=head1 METHODS
=head2 pick
my($fetch, @decoders) = $plugin->pick;
Returns the fetch plugin and any optional decoders that should be used.
=head1 SEE ALSO
L<Alien::Build::Plugin::Prefer::BadVersion>, L<Alien::Build::Plugin::Prefer::GoodVersion>
L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,118 @@
# PODNAME: Alien::Build::Plugin::Extract
# ABSTRACT: Extract Alien::Build plugins
# VERSION
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Extract - Extract Alien::Build plugins
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile
share {
plugin 'Extract' => 'tar.gz';
};
=head1 DESCRIPTION
Extract plugins extract packages that have been downloaded from the internet.
Unless you are doing something unusual you will likely want to use the
L<Alien::Build::Plugin::Extract::Negotiate> plugin to select the best
Extract plugin available.
=over 4
=item L<Alien::Build::Plugin::Extract::ArchiveTar>
=item L<Alien::Build::Plugin::Extract::ArchiveZip>
=item L<Alien::Build::Plugin::Extract::CommandLine>
=item L<Alien::Build::Plugin::Extract::Directory>
=item L<Alien::Build::Plugin::Extract::Negotiate>
=back
=head1 SEE ALSO
L<Alien::Build>, L<Alien::Build::Plugin>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,218 @@
package Alien::Build::Plugin::Extract::ArchiveTar;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use File::chdir;
use File::Temp ();
use Path::Tiny ();
# ABSTRACT: Plugin to extract a tarball using Archive::Tar
our $VERSION = '2.38'; # VERSION
has '+format' => 'tar';
sub handles
{
my(undef, $ext) = @_;
return 1 if $ext =~ /^(tar|tar.gz|tar.bz2|tbz|taz)$/;
return 0;
}
sub available
{
my(undef, $ext) = @_;
if($ext eq 'tar.gz')
{
return !! eval { require Archive::Tar; Archive::Tar->has_zlib_support };
}
elsif($ext eq 'tar.bz2')
{
return !! eval { require Archive::Tar; Archive::Tar->has_bzip2_support && __PACKAGE__->_can_bz2 };
}
else
{
return $ext eq 'tar';
}
}
sub init
{
my($self, $meta) = @_;
$meta->add_requires('share' => 'Archive::Tar' => 0);
if($self->format eq 'tar.gz' || $self->format eq 'tgz')
{
$meta->add_requires('share' => 'IO::Zlib' => 0);
}
elsif($self->format eq 'tar.bz2' || $self->format eq 'tbz')
{
$meta->add_requires('share' => 'IO::Uncompress::Bunzip2' => 0);
$meta->add_requires('share' => 'IO::Compress::Bzip2' => 0);
}
$meta->register_hook(
extract => sub {
my($build, $src) = @_;
my $tar = Archive::Tar->new;
$tar->read($src);
$tar->extract;
}
);
}
sub _can_bz2
{
# even when Archive::Tar reports that it supports bz2, I can sometimes get this error:
# 'Cannot read enough bytes from the tarfile', so lets just probe for actual support!
my $dir = Path::Tiny->new(File::Temp::tempdir( CLEANUP => 1 ));
eval {
local $CWD = $dir;
my $tarball = unpack "u", q{M0EIH.3%!62936=+(]$0``$A[D-$0`8!``7^``!!AI)Y`!```""``=!JGIH-(MT#0]0/2!**---&F@;4#0&:D;X?(6@JH(2<%'N$%3VHC-9E>S/N@"6&I*1@GNJNHCC2>$I5(<0BKR.=XBZ""HVZ;T,CV\LJ!K&*?9`#\7<D4X4)#2R/1$`};
Path::Tiny->new('xx.tar.bz2')->spew_raw($tarball);
require Archive::Tar;
my $tar = Archive::Tar->new;
$tar->read('xx.tar.bz2');
$tar->extract;
my $content = Path::Tiny->new('xx.txt')->slurp;
die unless $content && $content eq "xx\n";
};
my $error = $@;
$dir->remove_tree;
!$error;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Extract::ArchiveTar - Plugin to extract a tarball using Archive::Tar
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Extract::ArchiveTar' => (
format => 'tar.gz',
);
=head1 DESCRIPTION
Note: in most case you will want to use L<Alien::Build::Plugin::Extract::Negotiate>
instead. It picks the appropriate Extract plugin based on your platform and environment.
In some cases you may need to use this plugin directly instead.
This plugin extracts from an archive in tarball format (optionally compressed by either
gzip or bzip2) using L<Archive::Tar>.
=head1 PROPERTIES
=head2 format
Gives a hint as to the expected format. This helps make sure the prerequisites are set
correctly, since compressed archives require extra Perl modules to be installed.
=head1 METHODS
=head2 handles
Alien::Build::Plugin::Extract::ArchiveTar->handles($ext);
$plugin->handles($ext);
Returns true if the plugin is able to handle the archive of the
given format.
=head2 available
Alien::Build::Plugin::Extract::ArchiveTar->available($ext);
Returns true if the plugin has what it needs right now to extract from the given format
=head1 SEE ALSO
L<Alien::Build::Plugin::Extract::Negotiate>, L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,174 @@
package Alien::Build::Plugin::Extract::ArchiveZip;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
# ABSTRACT: Plugin to extract a tarball using Archive::Zip
our $VERSION = '2.38'; # VERSION
has '+format' => 'zip';
sub handles
{
my($class, $ext) = @_;
return 1 if $ext eq 'zip';
return 0;
}
sub available
{
my(undef, $ext) = @_;
!! ( $ext eq 'zip' && eval { require Archive::Zip; 1} );
}
sub init
{
my($self, $meta) = @_;
$meta->add_requires('share' => 'Archive::Zip' => 0);
$meta->register_hook(
extract => sub {
my($build, $src) = @_;
my $zip = Archive::Zip->new;
$zip->read($src);
$zip->extractTree;
}
);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Extract::ArchiveZip - Plugin to extract a tarball using Archive::Zip
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Extract::ArchiveZip' => (
format => 'zip',
);
=head1 DESCRIPTION
Note: in most case you will want to use L<Alien::Build::Plugin::Extract::Negotiate>
instead. It picks the appropriate Extract plugin based on your platform and environment.
In some cases you may need to use this plugin directly instead.
B<Note>: Seriously do NOT use this plugin! L<Archive::Zip> is pretty unreliable and
breaks all-the-time. If you use the negotiator plugin mentioned above, then it will
prefer installing L<Alien::unzip>, which is much more reliable than L<Archive::Zip>.
This plugin extracts from an archive in zip format using L<Archive::Zip>.
=head2 format
Gives a hint as to the expected format. This should always be C<zip>.
=head1 METHODS
=head2 handles
Alien::Build::Plugin::Extract::ArchiveZip->handles($ext);
$plugin->handles($ext);
Returns true if the plugin is able to handle the archive of the
given format.
=head2 available
Alien::Build::Plugin::Extract::ArchiveZip->available($ext);
Returns true if the plugin has what it needs right now to extract from the given format
=head1 SEE ALSO
L<Alien::Build::Plugin::Extract::Negotiate>, L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,557 @@
package Alien::Build::Plugin::Extract::CommandLine;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Path::Tiny ();
use File::Which ();
use File::chdir;
use File::Temp qw( tempdir );
use Capture::Tiny qw( capture_merged );
# ABSTRACT: Plugin to extract an archive using command line tools
our $VERSION = '2.38'; # VERSION
has '+format' => 'tar';
sub gzip_cmd
{
_which('gzip') ? 'gzip' : undef;
}
sub _which { scalar File::Which::which(@_) }
sub bzip2_cmd
{
_which('bzip2') ? 'bzip2' : undef;
}
sub xz_cmd
{
_which('xz') ? 'xz' : undef;
}
{
my $bsd_tar;
# Note: GNU tar can be iffy to very bad on windows, where absolute
# paths get confused with remote tars. We used to assume that 'tar.exe'
# is borked on Windows, but recent versions of Windows 10 come bundled
# with bsdtar (libarchive) named 'tar.exe', and we should definitely
# prefer that to ptar.
sub _windows_tar_is_bsdtar
{
return 1 if $^O ne 'MSWin32';
return $bsd_tar if defined $bsd_tar;
my($out) = capture_merged {
system 'tar', '--version';
};
return $bsd_tar = $out =~ /bsdtar/ ? 1 : 0
}
}
sub tar_cmd
{
_which('bsdtar')
? 'bsdtar'
# Slowlaris /usr/bin/tar doesn't seem to like pax global header
# but seems to have gtar in the path by default, which is okay with it
: $^O eq 'solaris' && _which('gtar')
? 'gtar'
# See note above for Windows logic.
: _which('tar') && _windows_tar_is_bsdtar()
? 'tar'
: _which('ptar')
? 'ptar'
: undef;
};
sub unzip_cmd
{
if($^O eq 'MSWin32' && _which('tar') && _windows_tar_is_bsdtar())
{
(_which('tar'), 'xf');
}
else
{
_which('unzip') ? 'unzip' : undef;
}
}
sub _run
{
my(undef, $build, @cmd) = @_;
$build->log("+ @cmd");
system @cmd;
die "execute failed" if $?;
}
sub _cp
{
my(undef, $build, $from, $to) = @_;
require File::Copy;
$build->log("copy $from => $to");
File::Copy::cp($from, $to) || die "unable to copy: $!";
}
sub _mv
{
my(undef, $build, $from, $to) = @_;
$build->log("move $from => $to");
rename($from, $to) || die "unable to rename: $!";
}
sub _dcon
{
my($self, $src) = @_;
my $name;
my $cmd;
if($src =~ /\.(gz|tgz|Z|taz)$/)
{
$self->gzip_cmd(_which('gzip')) unless defined $self->gzip_cmd;
if($src =~ /\.(gz|tgz)$/)
{
$cmd = $self->gzip_cmd unless $self->_tar_can('tar.gz');
}
elsif($src =~ /\.(Z|taz)$/)
{
$cmd = $self->gzip_cmd unless $self->_tar_can('tar.Z');
}
}
elsif($src =~ /\.(bz2|tbz)$/)
{
$self->bzip2_cmd(_which('bzip2')) unless defined $self->bzip2_cmd;
$cmd = $self->bzip2_cmd unless $self->_tar_can('tar.bz2');
}
elsif($src =~ /\.(xz|txz)$/)
{
$self->xz_cmd(_which('xz')) unless defined $self->xz_cmd;
$cmd = $self->xz_cmd unless $self->_tar_can('tar.xz');
}
if($cmd && $src =~ /\.(gz|bz2|xz|Z)$/)
{
$name = $src;
$name =~ s/\.(gz|bz2|xz|Z)$//g;
}
elsif($cmd && $src =~ /\.(tgz|tbz|txz|taz)$/)
{
$name = $src;
$name =~ s/\.(tgz|tbz|txz|taz)$/.tar/;
}
($name,$cmd);
}
sub handles
{
my($class, $ext) = @_;
my $self = ref $class
? $class
: __PACKAGE__->new;
$ext = 'tar.Z' if $ext eq 'taz';
$ext = 'tar.gz' if $ext eq 'tgz';
$ext = 'tar.bz2' if $ext eq 'tbz';
$ext = 'tar.xz' if $ext eq 'txz';
return 1 if $ext eq 'tar.gz' && $self->_tar_can('tar.gz');
return 1 if $ext eq 'tar.Z' && $self->_tar_can('tar.Z');
return 1 if $ext eq 'tar.bz2' && $self->_tar_can('tar.bz2');
return 1 if $ext eq 'tar.xz' && $self->_tar_can('tar.xz');
return 0 if $ext =~ s/\.(gz|Z)$// && (!$self->gzip_cmd);
return 0 if $ext =~ s/\.bz2$// && (!$self->bzip2_cmd);
return 0 if $ext =~ s/\.xz$// && (!$self->xz_cmd);
return 1 if $ext eq 'tar' && $self->_tar_can('tar');
return 1 if $ext eq 'zip' && $self->_tar_can('zip');
return 0;
}
sub available
{
my(undef, $ext) = @_;
# this is actually the same as handles
__PACKAGE__->handles($ext);
}
sub init
{
my($self, $meta) = @_;
if($self->format eq 'tar.xz' && !$self->handles('tar.xz'))
{
$meta->add_requires('share' => 'Alien::xz' => '0.06');
}
elsif($self->format eq 'tar.bz2' && !$self->handles('tar.bz2'))
{
$meta->add_requires('share' => 'Alien::Libbz2' => '0.22');
}
elsif($self->format =~ /^tar\.(gz|Z)$/ && !$self->handles($self->format))
{
$meta->add_requires('share' => 'Alien::gzip' => '0.03');
}
elsif($self->format eq 'zip' && !$self->handles('zip'))
{
$meta->add_requires('share' => 'Alien::unzip' => '0');
}
$meta->register_hook(
extract => sub {
my($build, $src) = @_;
my($dcon_name, $dcon_cmd) = _dcon($self, $src);
if($dcon_name)
{
unless($dcon_cmd)
{
die "unable to decompress $src";
}
# if we have already decompressed, then keep it.
unless(-f $dcon_name)
{
# we don't use pipes, because that may not work on Windows.
# keep the original archive, in case another extract
# plugin needs it. keep the decompressed archive
# in case WE need it again.
my $src_tmp = Path::Tiny::path($src)
->parent
->child('x'.Path::Tiny::path($src)->basename);
my $dcon_tmp = Path::Tiny::path($dcon_name)
->parent
->child('x'.Path::Tiny::path($dcon_name)->basename);
$self->_cp($build, $src, $src_tmp);
$self->_run($build, $dcon_cmd, "-d", $src_tmp);
$self->_mv($build, $dcon_tmp, $dcon_name);
}
$src = $dcon_name;
}
if($src =~ /\.zip$/i)
{
$self->_run($build, $self->unzip_cmd, $src);
}
elsif($src =~ /\.tar/ || $src =~ /(\.tgz|\.tbz|\.txz|\.taz)$/i)
{
$self->_run($build, $self->tar_cmd, '-xf', $src);
}
else
{
die "not sure of archive type from extension";
}
}
);
}
my %tars;
sub _tar_can
{
my($self, $ext) = @_;
unless(%tars)
{
my $name = '';
local $_; # to avoid dynamically scoped read-only $_ from upper scopes
while(my $line = <DATA>)
{
if($line =~ /^\[ (.*) \]$/)
{
$name = $1;
}
else
{
$tars{$name} .= $line;
}
}
foreach my $key (keys %tars)
{
$tars{$key} = unpack "u", $tars{$key};
}
}
my $name = "xx.$ext";
return 0 unless $tars{$name};
local $CWD = tempdir( CLEANUP => 1 );
my $cleanup = sub {
my $save = $CWD;
unlink $name;
unlink 'xx.txt';
$CWD = '..';
rmdir $save;
};
Path::Tiny->new($name)->spew_raw($tars{$name});
my @cmd = ($self->tar_cmd, 'xf', $name);
if($ext eq 'zip')
{
@cmd = ($self->unzip_cmd, $name);
}
my(undef, $exit) = capture_merged {
system(@cmd);
$?;
};
if($exit)
{
$cleanup->();
return 0;
}
my $content = eval { Path::Tiny->new('xx.txt')->slurp };
$cleanup->();
return defined $content && $content eq "xx\n";
}
1;
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Extract::CommandLine - Plugin to extract an archive using command line tools
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Extract::CommandLine' => (
format => 'tar.gz',
);
=head1 DESCRIPTION
Note: in most case you will want to use L<Alien::Build::Plugin::Extract::Negotiate>
instead. It picks the appropriate Extract plugin based on your platform and environment.
In some cases you may need to use this plugin directly instead.
This plugin extracts from an archive in various formats using command line tools.
=head1 PROPERTIES
=head2 format
Gives a hint as to the expected format.
=head2 gzip_cmd
The C<gzip> command, if available. C<undef> if not available.
=head2 bzip2_cmd
The C<bzip2> command, if available. C<undef> if not available.
=head2 xz_cmd
The C<xz> command, if available. C<undef> if not available.
=head2 tar_cmd
The C<tar> command, if available. C<undef> if not available.
=head2 unzip_cmd
The C<unzip> command, if available. C<undef> if not available.
=head1 METHODS
=head2 handles
Alien::Build::Plugin::Extract::CommandLine->handles($ext);
$plugin->handles($ext);
Returns true if the plugin is able to handle the archive of the
given format.
=head2 available
Alien::Build::Plugin::Extract::CommandLine->available($ext);
Returns true if the plugin is available to extract without
installing anything new.
=head1 SEE ALSO
L<Alien::Build::Plugin::Extract::Negotiate>, L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut
__DATA__
[ xx.tar ]
M>'@N='AT````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M`````````````#`P,#8T-"``,#`P-S8U(``P,#`P,C0@`#`P,#`P,#`P,#`S
M(#$S-#,U,#0S-#(R(#`Q,C<P,P`@,```````````````````````````````
M````````````````````````````````````````````````````````````
M``````````````````````````````````````````!U<W1A<@`P,&]L;&ES
M9P``````````````````````````````````<W1A9F8`````````````````
M```````````````````P,#`P,#`@`#`P,#`P,"``````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M``````````````````````!X>`H`````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
M````````````````````````````````````````````````````````````
7````````````````````````````````
[ xx.tar.Z ]
M'YV0>/"XH(.'#H"#"!,J7,BPH<.'$"-*1`BCH@T:-$``J`CCAHT:&CG"D)%Q
MH\B3,T#$F$%C1@T8+6G(D`$"1@P9-V#,`%!SHL^?0(,*!5!G#ITP<DR^8<,F
MS9PS0Q<:#6/&3-2%)V&$/*GQJM>O8,.*'1I0P=BS:-.J7<NVK=NW<./*G4NW
7KMV[>//JW<NWK]^_@`,+'DRXL.'#0P$`
[ xx.tar.bz2 ]
M0EIH.3%!629365(,+ID``$A[D-$0`8!``7^``!!AI)Y`!```""``=!JGIBC3
M30&CU`]($HHTTR:`>D#0)SI*Z'R%H*J"&3@H]P@J>U$F5BMHOC`$L-"8C!(V
I"`'?*WA:(9*4U)@4)+"(V%.G]#W(_E6B'J8G]D`/Q=R13A0D%(,+ID``
[ xx.tar.gz ]
M'XL("!)'=%P``WAX+G1A<@"KJ-`KJ2AAH"DP,#`P,S%1`-'F9J9@VL`(PH<"
M8P5#8Q-C4P,38Q,C(P4#0R-S`V,&!0/:.@L"2HM+$HN`3LG/R<DL3L>M#J@L
E+0V/.1"/*,#I(0(J*K@&V@FC8!2,@E$P"@8````U:,3F``@`````
[ xx.tar.xz ]
M_3=Z6%H```3FUK1&`@`A`18```!T+^6CX`?_`&!=`#Q@M.AX.4O&N38V648.
M[J6L\\<_[3M*R;CASOTX?B.F\V:^)+G;\YY4"!4MLF9`*\N40G=O+K,J0"NF
M0VU7J%NN(A,R^DM8@/(_YGR5CAO+1CS_YNHE:,1!G%6L1\GT``"[$^?"O*"!
9`P`!?(`0````:OY*7K'$9_L"``````196@``
[ xx.zip ]
M4$L#!`H``````%5V64X:^I"B`P````,````&`!P`>'@N='AT550)``,21W1<
M$D=T7'5X"P`!!/4!```$%````'AX"E!+`0(>`PH``````%5V64X:^I"B`P``
M``,````&`!@```````$```"D@0````!X>"YT>'155`4``Q)'=%QU>`L``03U
>`0``!!0```!02P4&``````$``0!,````0P``````

View File

@@ -0,0 +1,181 @@
package Alien::Build::Plugin::Extract::Directory;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Alien::Build::Util qw( _mirror );
use Path::Tiny ();
# ABSTRACT: Plugin to extract a downloaded directory to a build directory
our $VERSION = '2.38'; # VERSION
has '+format' => 'd';
sub handles
{
my(undef, $ext) = @_;
$ext eq 'd' ? 1 : ();
}
sub available
{
my(undef, $ext) = @_;
__PACKAGE__->handles($ext);
}
sub init
{
my($self, $meta) = @_;
$meta->register_hook(
extract => sub {
my($build, $src) = @_;
die "not a directory: $src" unless -d $src;
if($build->meta_prop->{out_of_source})
{
$build->install_prop->{extract} = Path::Tiny->new($src)->absolute->stringify;
}
else
{
my $dst = Path::Tiny->new('.')->absolute;
# Please note: _mirror and Alien::Build::Util are ONLY
# allowed to be used by core plugins. If you are writing
# a non-core plugin it may be removed. That is why it
# is private.
_mirror $src => $dst, { verbose => 1 };
}
}
);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Extract::Directory - Plugin to extract a downloaded directory to a build directory
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Extract::Directory';
=head1 DESCRIPTION
Some Download or Fetch plugins may produce a directory instead of an archive
file. This plugin is used to mirror the directory from the Download step
into a fresh directory in the Extract step. An example of when you might use
this plugin is if you were using the C<git> command in the Download step,
which results in a directory hierarchy.
=head1 PROPERTIES
=head2 format
Should always set to C<d> (for directories).
=head1 METHODS
=head2 handles
Alien::Build::Plugin::Extract::Directory->handles($ext);
$plugin->handles($ext);
Returns true if the plugin is able to handle the archive of the
given format. Only returns true for C<d> (for directory).
=head2 available
Alien::Build::Plugin::Extract::Directory->available($ext);
$plugin->available($ext);
Returns true if the plugin can extract the given format with
what is already installed.
=head1 SEE ALSO
L<Alien::Build::Plugin::Extract::Negotiate>, L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,194 @@
package Alien::Build::Plugin::Extract::Negotiate;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Alien::Build::Plugin::Extract::ArchiveTar;
use Alien::Build::Plugin::Extract::ArchiveZip;
use Alien::Build::Plugin::Extract::CommandLine;
use Alien::Build::Plugin::Extract::Directory;
# ABSTRACT: Extraction negotiation plugin
our $VERSION = '2.38'; # VERSION
has '+format' => 'tar';
sub init
{
my($self, $meta) = @_;
my $format = $self->format;
$format = 'tar.gz' if $format eq 'tgz';
$format = 'tar.bz2' if $format eq 'tbz';
$format = 'tar.xz' if $format eq 'txz';
my $plugin = $self->pick($format);
$meta->apply_plugin($plugin, format => $format);
$self;
}
sub pick
{
my(undef, $format) = @_;
if($format =~ /^tar(\.(gz|bz2))?$/)
{
if(Alien::Build::Plugin::Extract::ArchiveTar->available($format))
{
return 'Extract::ArchiveTar';
}
else
{
return 'Extract::CommandLine';
}
}
elsif($format eq 'zip')
{
# Archive::Zip is not that reliable. But if it is already installed it is probably working
if(Alien::Build::Plugin::Extract::ArchiveZip->available($format))
{
return 'Extract::ArchiveZip';
}
# If it isn't available, then use the command-line unzip. Alien::unzip will be used
# as necessary in environments where it isn't already installed.
else
{
return 'Extract::CommandLine';
}
}
elsif($format eq 'tar.xz' || $format eq 'tar.Z')
{
return 'Extract::CommandLine';
}
elsif($format eq 'd')
{
return 'Extract::Directory';
}
else
{
die "do not know how to handle format: $format";
}
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Extract::Negotiate - Extraction negotiation plugin
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Extract' => (
format => 'tar.gz',
);
=head1 DESCRIPTION
This is a negotiator plugin for extracting packages downloaded from the internet.
This plugin picks the best Extract plugin to do the actual work. Which plugins are
picked depend on the properties you specify, your platform and environment. It is
usually preferable to use a negotiator plugin rather than using a specific Extract
Plugin from your L<alienfile>.
=head1 PROPERTIES
=head2 format
The expected format for the download. Possible values include:
C<tar>, C<tar.gz>, C<tar.bz2>, C<tar.xz>, C<zip>, C<d>.
=head1 METHODS
=head2 pick
my $name = Alien::Build::Plugin::Extract::Negotiate->pick($format);
Returns the name of the best plugin for the given format.
=head1 SEE ALSO
L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,120 @@
# PODNAME: Alien::Build::Plugin::Fetch
# ABSTRACT: Fetch Alien::Build plugins
# VERSION
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Fetch - Fetch Alien::Build plugins
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
share {
start_url 'http://ftp.gnu.org/gnu/make';
plugin 'Download';
};
=head1 DESCRIPTION
Fetch plugins retrieve single resources from the internet. The difference
between a Fetch plugin and a Download plugin is that Download
plugin may fetch several resources from the internet (usually using
a Fetch plugin), before finding the final archive. Normally you
will not need to use Fetch plugins directly but should instead
use the L<Alien::Build::Plugin::Download::Negotiate> plugin, which
will pick the best plugins for your given URL.
=over 4
=item L<Alien::Build::Plugin::Fetch::HTTPTiny>
=item L<Alien::Build::Plugin::Fetch::Local>
=item L<Alien::Build::Plugin::Fetch::LWP>
=item L<Alien::Build::Plugin::Fetch::NetFTP>
=back
=head1 SEE ALSO
L<Alien::Build>, L<Alien::Build::Plugin>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,358 @@
package Alien::Build::Plugin::Fetch::CurlCommand;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use File::Which qw( which );
use Path::Tiny qw( path );
use Capture::Tiny qw( capture );
use File::Temp qw( tempdir );
use List::Util 1.33 qw( any );
use File::chdir;
# ABSTRACT: Plugin for fetching files using curl
our $VERSION = '2.38'; # VERSION
sub curl_command
{
defined $ENV{CURL} ? scalar which($ENV{CURL}) : scalar which('curl');
}
has ssl => 0;
has _see_headers => 0;
has '+url' => '';
# when bootstrapping we have to specify this plugin as a prereq
# 1 is the default so that when this plugin is used directly
# you also get the prereq
has bootstrap_ssl => 1;
sub protocol_ok
{
my($class, $protocol) = @_;
my $curl = $class->curl_command;
return 0 unless defined $curl;
my($out, $err, $exit) = capture {
system $curl, '--version';
};
{
# make sure curl supports the -J option.
# CentOS 6 for example is recent enough
# that it does not. gh#147, gh#148, gh#149
local $CWD = tempdir( CLEANUP => 1 );
my $file1 = path('foo/foo.txt');
$file1->parent->mkpath;
$file1->spew("hello world\n");
my $url = 'file://' . $file1->absolute;
my($out, $err, $exit) = capture {
system $curl, '-O', '-J', $url;
};
my $file2 = $file1->parent->child($file1->basename);
unlink "$file1";
unlink "$file2";
rmdir($file1->parent);
return 0 if $exit;
}
foreach my $line (split /\n/, $out)
{
if($line =~ /^Protocols:\s*(.*)\s*$/)
{
my %proto = map { $_ => 1 } split /\s+/, $1;
return $proto{$protocol} if $proto{$protocol};
}
}
return 0;
}
sub init
{
my($self, $meta) = @_;
$meta->prop->{start_url} ||= $self->url;
$self->url($meta->prop->{start_url});
$self->url || Carp::croak('url is a required property');
$meta->add_requires('configure', 'Alien::Build::Plugin::Fetch::CurlCommand' => '1.19')
if $self->bootstrap_ssl;
$meta->register_hook(
fetch => sub {
my($build, $url) = @_;
$url ||= $self->url;
my($scheme) = $url =~ /^([a-z0-9]+):/i;
if($scheme =~ /^https?$/)
{
local $CWD = tempdir( CLEANUP => 1 );
my @writeout = (
"ab-filename :%{filename_effective}",
"ab-content_type :%{content_type}",
"ab-url :%{url_effective}",
);
$build->log("writeout: $_\\n") for @writeout;
path('writeout')->spew(join("\\n", @writeout));
my @command = (
$self->curl_command,
'-L', '-f', '-O', '-J',
-w => '@writeout',
);
push @command, -D => 'head' if $self->_see_headers;
push @command, $url;
my($stdout, $stderr) = $self->_execute($build, @command);
my %h = map { /^ab-(.*?)\s*:(.*)$/ ? ($1 => $2) : () } split /\n/, $stdout;
if(-e 'head')
{
$build->log(" ~ $_ => $h{$_}") for sort keys %h;
$build->log(" header: $_") for path('headers')->lines;
}
my($type) = split /;/, $h{content_type};
if($type eq 'text/html')
{
return {
type => 'html',
base => $h{url},
content => scalar path($h{filename})->slurp,
};
}
else
{
return {
type => 'file',
filename => $h{filename},
path => path($h{filename})->absolute->stringify,
};
}
}
# elsif($scheme eq 'ftp')
# {
# if($url =~ m{/$})
# {
# my($stdout, $stderr) = $self->_execute($build, $self->curl_command, -l => $url);
# chomp $stdout;
# return {
# type => 'list',
# list => [
# map { { filename => $_, url => "$url$_" } } sort split /\n/, $stdout,
# ],
# };
# }
#
# my $first_error;
#
# {
# local $CWD = tempdir( CLEANUP => 1 );
#
# my($filename) = $url =~ m{/([^/]+)$};
# $filename = 'unknown' if (! defined $filename) || ($filename eq '');
# my($stdout, $stderr) = eval { $self->_execute($build, $self->curl_command, -o => $filename, $url) };
# $first_error = $@;
# if($first_error eq '')
# {
# return {
# type => 'file',
# filename => $filename,
# path => path($filename)->absolute->stringify,
# };
# }
# }
#
# {
# my($stdout, $stderr) = eval { $self->_execute($build, $self->curl_command, -l => "$url/") };
# if($@ eq '')
# {
# chomp $stdout;
# return {
# type => 'list',
# list => [
# map { { filename => $_, url => "$url/$_" } } sort split /\n/, $stdout,
# ],
# };
# };
# }
#
# $first_error ||= 'unknown error';
# die $first_error;
#
# }
else
{
die "scheme $scheme is not supported by the Fetch::CurlCommand plugin";
}
},
) if $self->curl_command;
$self;
}
sub _execute
{
my($self, $build, @command) = @_;
$build->log("+ @command");
my($stdout, $stderr, $err) = capture {
system @command;
$?;
};
if($err)
{
chomp $stderr;
$build->log($_) for split /\n/, $stderr;
if($stderr =~ /Remote filename has no length/ && !!(any { /^-O$/ } @command))
{
my @new_command = map {
/^-O$/ ? ( -o => 'index.html' ) : /^-J$/ ? () : ($_)
} @command;
return $self->_execute($build, @new_command);
}
die "error in curl fetch";
}
($stdout, $stderr);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Fetch::CurlCommand - Plugin for fetching files using curl
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
share {
start_url 'https://www.openssl.org/source/';
plugin 'Fetch::CurlCommand';
};
=head1 DESCRIPTION
This plugin provides a fetch based on the C<curl> command. It works with other fetch
plugins (that is, the first one which succeeds will be used). Most of the time the best plugin
to use will be L<Alien::Build::Plugin::Download::Negotiate>, but for some SSL bootstrapping
it may be desirable to try C<curl> first.
Protocols supported: C<http>, C<https>
C<https> support requires that curl was built with SSL support.
=head1 PROPERTIES
=head2 curl_command
The full path to the C<curl> command. The default is usually correct.
=head2 ssl
Ignored by this plugin. Provided for compatibility with some other fetch plugins.
=head1 METHODS
=head2 protocol_ok
my $bool = $plugin->protocol_ok($protocol);
my $bool = Alien::Build::Plugin::Fetch::CurlCommand->protocol_ok($protocol);
=head1 SEE ALSO
=over 4
=item L<alienfile>
=item L<Alien::Build>
=back
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,235 @@
package Alien::Build::Plugin::Fetch::HTTPTiny;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use File::Basename ();
use Alien::Build::Util qw( _ssl_reqs );
use Carp ();
# ABSTRACT: Plugin for fetching files using HTTP::Tiny
our $VERSION = '2.38'; # VERSION
has '+url' => '';
has ssl => 0;
# ignored for compatability
has bootstrap_ssl => 1;
sub init
{
my($self, $meta) = @_;
$meta->add_requires('share' => 'HTTP::Tiny' => '0.044' );
$meta->add_requires('share' => 'URI' => 0 );
$meta->prop->{start_url} ||= $self->url;
$self->url($meta->prop->{start_url});
$self->url || Carp::croak('url is a required property');
if($self->url =~ /^https:/ || $self->ssl)
{
my $reqs = _ssl_reqs;
foreach my $mod (sort keys %$reqs)
{
$meta->add_requires('share' => $mod => $reqs->{$mod});
}
}
$meta->register_hook( fetch => sub {
my($build, $url) = @_;
$url ||= $self->url;
my $ua = HTTP::Tiny->new;
my $res = $ua->get($url);
unless($res->{success})
{
my $status = $res->{status} || '---';
my $reason = $res->{reason} || 'unknown';
$build->log("$status $reason fetching $url");
if($status == 599)
{
$build->log("exception: $_") for split /\n/, $res->{content};
my($can_ssl, $why_ssl) = HTTP::Tiny->can_ssl;
if(! $can_ssl)
{
if($res->{redirects}) {
foreach my $redirect (@{ $res->{redirects} })
{
if(defined $redirect->{headers}->{location} && $redirect->{headers}->{location} =~ /^https:/)
{
$build->log("An attempt at a SSL URL https was made, but your HTTP::Tiny does not appear to be able to use https.");
$build->log("Please see: https://metacpan.org/pod/Alien::Build::Manual::FAQ#599-Internal-Exception-errors-downloading-packages-from-the-internet");
}
}
}
}
}
die "error fetching $url: $status $reason";
}
my($type) = split /;/, $res->{headers}->{'content-type'};
$type = lc $type;
my $base = URI->new($res->{url});
my $filename = File::Basename::basename do { my $name = $base->path; $name =~ s{/$}{}; $name };
# TODO: this doesn't get exercised by t/bin/httpd
if(my $disposition = $res->{headers}->{"content-disposition"})
{
# Note: from memory without quotes does not match the spec,
# but many servers actually return this sort of value.
if($disposition =~ /filename="([^"]+)"/ || $disposition =~ /filename=([^\s]+)/)
{
$filename = $1;
}
}
if($type eq 'text/html')
{
return {
type => 'html',
base => $base->as_string,
content => $res->{content},
};
}
else
{
return {
type => 'file',
filename => $filename || 'downloadedfile',
content => $res->{content},
};
}
});
$self;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Fetch::HTTPTiny - Plugin for fetching files using HTTP::Tiny
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
share {
start_url 'http://ftp.gnu.org/gnu/make';
plugin 'Fetch::HTTPTiny';
};
=head1 DESCRIPTION
Note: in most case you will want to use L<Alien::Build::Plugin::Download::Negotiate>
instead. It picks the appropriate fetch plugin based on your platform and environment.
In some cases you may need to use this plugin directly instead.
This fetch plugin fetches files and directory listings via the C<http> and C<https>
protocol using L<HTTP::Tiny>. If the URL specified uses the C<https> scheme, then
the required SSL modules will automatically be injected as requirements. If your
initial URL is not C<https>, but you know that it will be needed on a subsequent
request you can use the ssl property below.
=head1 PROPERTIES
=head2 url
The initial URL to fetch. This may be a directory listing (in HTML) or the final file.
=head2 ssl
If set to true, then the SSL modules required to make an C<https> connection will be
added as prerequisites.
=head1 SEE ALSO
L<Alien::Build::Plugin::Download::Negotiate>, L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,197 @@
package Alien::Build::Plugin::Fetch::LWP;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Carp ();
# ABSTRACT: Plugin for fetching files using LWP
our $VERSION = '2.38'; # VERSION
has '+url' => '';
has ssl => 0;
sub init
{
my($self, $meta) = @_;
$meta->add_requires('share' => 'LWP::UserAgent' => 0 );
$meta->prop->{start_url} ||= $self->url;
$self->url($meta->prop->{start_url});
$self->url || Carp::croak('url is a required property');
if($self->url =~ /^https:/ || $self->ssl)
{
$meta->add_requires('share' => 'LWP::Protocol::https' => 0 );
}
$meta->register_hook( fetch => sub {
my(undef, $url) = @_;
$url ||= $self->url;
my $ua = LWP::UserAgent->new;
$ua->env_proxy;
my $res = $ua->get($url);
die "error fetching $url: @{[ $res->status_line ]}"
unless $res->is_success;
my($type, $charset) = $res->content_type_charset;
my $base = $res->base;
my $filename = $res->filename;
if($type eq 'text/html')
{
return {
type => 'html',
charset => $charset,
base => "$base",
content => $res->decoded_content || $res->content,
};
}
elsif($type eq 'text/ftp-dir-listing')
{
return {
type => 'dir_listing',
base => "$base",
content => $res->decoded_content || $res->content,
};
}
else
{
return {
type => 'file',
filename => $filename || 'downloadedfile',
content => $res->content,
};
}
});
$self;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Fetch::LWP - Plugin for fetching files using LWP
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
share {
start_url 'http://ftp.gnu.org/gnu/make';
plugin 'Fetch::LWP';
};
=head1 DESCRIPTION
Note: in most case you will want to use L<Alien::Build::Plugin::Download::Negotiate>
instead. It picks the appropriate fetch plugin based on your platform and environment.
In some cases you may need to use this plugin directly instead.
This fetch plugin fetches files and directory listings via the C<http> C<https>, C<ftp>,
C<file> protocol using L<LWP>. If the URL specified uses the C<https> scheme, then
the required SSL modules will automatically be injected as requirements. If your
initial URL is not C<https>, but you know that it will be needed on a subsequent
request you can use the ssl property below.
=head1 PROPERTIES
=head2 url
The initial URL to fetch. This may be a directory listing (in HTML) or the final file.
=head2 ssl
If set to true, then the SSL modules required to make an C<https> connection will be
added as prerequisites.
=head1 SEE ALSO
L<Alien::Build::Plugin::Download::Negotiate>, L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,226 @@
package Alien::Build::Plugin::Fetch::Local;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use File::chdir;
use Path::Tiny ();
# ABSTRACT: Plugin for fetching a local file
our $VERSION = '2.38'; # VERSION
has '+url' => '';
has root => undef;
has ssl => 0;
sub init
{
my($self, $meta) = @_;
$meta->prop->{start_url} ||= $self->url;
$self->url($meta->prop->{start_url} || 'patch');
if($self->url =~ /^file:/)
{
$meta->add_requires('share' => 'URI' => 0 );
$meta->add_requires('share' => 'URI::file' => 0 );
$meta->add_requires('share' => 'URI::Escape' => 0 );
}
{
my $root = $self->root;
if(defined $root)
{
$root = Path::Tiny->new($root)->absolute->stringify;
}
else
{
$root = "$CWD";
}
$self->root($root);
}
$meta->register_hook( fetch => sub {
my(undef, $path) = @_;
$path ||= $self->url;
if($path =~ /^file:/)
{
my $root = URI::file->new($self->root);
my $url = URI->new_abs($path, $root);
$path = URI::Escape::uri_unescape($url->path);
$path =~ s{^/([a-z]:)}{$1}i if $^O eq 'MSWin32';
}
$path = Path::Tiny->new($path)->absolute($self->root);
if(-d $path)
{
return {
type => 'list',
list => [
map { { filename => $_->basename, url => $_->stringify } }
sort { $a->basename cmp $b->basename } $path->children,
],
};
}
elsif(-f $path)
{
return {
type => 'file',
filename => $path->basename,
path => $path->stringify,
tmp => 0,
};
}
else
{
die "no such file or directory $path";
}
});
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Fetch::Local - Plugin for fetching a local file
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
share {
start_url 'patch/libfoo-1.00.tar.gz';
plugin 'Fetch::Local';
};
=head1 DESCRIPTION
Note: in most case you will want to use L<Alien::Build::Plugin::Download::Negotiate>
instead. It picks the appropriate fetch plugin based on your platform and environment.
In some cases you may need to use this plugin directly instead.
This fetch plugin fetches files from the local file system. It is mostly useful if you
intend to bundle packages (as tarballs or zip files) with your Alien. If you intend to
bundle a source tree, use L<Alien::Build::Plugin::Fetch::LocalDir>.
=head1 PROPERTIES
=head2 url
The initial URL to fetch. This may be a C<file://> style URL, or just the path on the
local system.
=head2 root
The directory from which the URL should be relative. The default is usually reasonable.
=head2 ssl
This property is for compatibility with other fetch plugins, but is not used.
=head1 SEE ALSO
=over 4
=item L<Alien::Build::Plugin::Download::Negotiate>
=item L<Alien::Build::Plugin::Fetch::LocalDir>
=item L<Alien::Build>
=item L<alienfile>
=item L<Alien::Build::MM>
=item L<Alien>
=back
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,210 @@
package Alien::Build::Plugin::Fetch::LocalDir;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use File::chdir;
use Path::Tiny ();
# ABSTRACT: Plugin for fetching a local directory
our $VERSION = '2.38'; # VERSION
has root => undef;
has ssl => 0;
sub init
{
my($self, $meta) = @_;
my $url = $meta->prop->{start_url} || 'patch';
$meta->add_requires('configure' => 'Alien::Build::Plugin::Fetch::LocalDir' => '0.72' );
if($url =~ /^file:/)
{
$meta->add_requires('share' => 'URI' => 0 );
$meta->add_requires('share' => 'URI::file' => 0 );
}
{
my $root = $self->root;
if(defined $root)
{
$root = Path::Tiny->new($root)->absolute->stringify;
}
else
{
$root = "$CWD";
}
$self->root($root);
}
$meta->register_hook(
fetch => sub {
my($build, $path) = @_;
$path ||= $url;
if($path =~ /^file:/)
{
my $root = URI::file->new($self->root);
my $url = URI->new_abs($path, $root);
$path = $url->path;
$path =~ s{^/([a-z]:)}{$1}i if $^O eq 'MSWin32';
}
$path = Path::Tiny->new($path)->absolute($self->root);
if(-d $path)
{
return {
type => 'file',
filename => $path->basename,
path => $path->stringify,
tmp => 0,
};
}
else
{
$build->log("path $path is not a directory");
$build->log("(you specified $url with root @{[ $self->root ]})");
die "$path is not a directory";
}
}
);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Fetch::LocalDir - Plugin for fetching a local directory
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
share {
start_url 'patch/libfoo-1.00/';
plugin 'Fetch::LocalDir';
};
=head1 DESCRIPTION
Note: in most case you will want to use L<Alien::Build::Plugin::Download::Negotiate>
instead. It picks the appropriate fetch plugin based on your platform and environment.
In some cases you may need to use this plugin directly instead.
This fetch plugin fetches files from the local file system. It is mostly useful if you
intend to bundle source with your Alien. If you are bundling tarballs see
L<Alien::Build::Plugin::Fetch::Local>.
=head1 PROPERTIES
=head2 root
The directory from which the start URL should be relative. The default is usually reasonable.
=head2 ssl
This property is for compatibility with other fetch plugins, but is not used.
=head1 SEE ALSO
=over 4
=item L<Alien::Build::Plugin::Download::Negotiate>
=item L<Alien::Build::Plugin::Fetch::Local>
=item L<Alien::Build>
=item L<alienfile>
=item L<Alien::Build::MM>
=item L<Alien>
=back
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,267 @@
package Alien::Build::Plugin::Fetch::NetFTP;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Carp ();
use File::Temp ();
use Path::Tiny qw( path );
# ABSTRACT: Plugin for fetching files using Net::FTP
our $VERSION = '2.38'; # VERSION
has '+url' => '';
has ssl => 0;
has passive => 0;
sub init
{
my($self, $meta) = @_;
$meta->prop->{start_url} ||= $self->url;
$self->url($meta->prop->{start_url});
$self->url || Carp::croak('url is a required property');
$meta->add_requires('share' => 'Net::FTP' => 0 );
$meta->add_requires('share' => 'URI' => 0 );
$meta->add_requires('share' => 'Alien::Build::Plugin::Fetch::NetFTP' => '0.61')
if $self->passive;
$meta->register_hook( fetch => sub {
my($build, $url) = @_;
$url ||= $self->url;
$url = URI->new($url);
die "Fetch::NetFTP does not support @{[ $url->scheme ]}"
unless $url->scheme eq 'ftp';
$build->log("trying passive mode FTP first") if $self->passive;
my $ftp = _ftp_connect($url, $self->passive);
my $path = $url->path;
unless($path =~ m!/$!)
{
my(@parts) = split /\//, $path;
my $filename = pop @parts;
my $dir = join '/', @parts;
my $path = eval {
$ftp->cwd($dir) or die;
my $tdir = File::Temp::tempdir( CLEANUP => 1);
my $path = path("$tdir/$filename")->stringify;
unless(eval { $ftp->get($filename, $path) }) # NAT problem? try to use passive mode
{
$ftp->quit;
$build->log("switching to @{[ $self->passive ? 'active' : 'passive' ]} mode");
$ftp = _ftp_connect($url, !$self->passive);
$ftp->cwd($dir) or die;
$ftp->get($filename, $path) or die;
}
$path;
};
if(defined $path)
{
return {
type => 'file',
filename => $filename,
path => $path,
};
}
$path .= "/";
}
$ftp->quit;
$ftp = _ftp_connect($url, $self->passive);
$ftp->cwd($path) or die "unable to fetch $url as either a directory or file";
my $list = eval { $ftp->ls };
unless(defined $list) # NAT problem? try to use passive mode
{
$ftp->quit;
$build->log("switching to @{[ $self->passive ? 'active' : 'passive' ]} mode");
$ftp = _ftp_connect($url, !$self->passive);
$ftp->cwd($path) or die "unable to fetch $url as either a directory or file";
$list = $ftp->ls;
die "cannot list directory $path on $url" unless defined $list;
}
die "no files found at $url" unless @$list;
$path .= '/' unless $path =~ /\/$/;
return {
type => 'list',
list => [
map {
my $filename = $_;
my $furl = $url->clone;
$furl->path($path . $filename);
my %h = (
filename => $filename,
url => $furl->as_string,
);
\%h;
} sort @$list,
],
};
});
$self;
}
sub _ftp_connect {
my $url = shift;
my $is_passive = shift || 0;
my $ftp = Net::FTP->new(
$url->host, Port =>$url->port, Passive =>$is_passive,
) or die "error fetching $url: $@";
$ftp->login($url->user, $url->password)
or die "error on login $url: @{[ $ftp->message ]}";
$ftp->binary;
$ftp;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Fetch::NetFTP - Plugin for fetching files using Net::FTP
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
share {
start_url 'ftp://ftp.gnu.org/gnu/make';
plugin 'Fetch::NetFTP';
};
=head1 DESCRIPTION
Note: in most case you will want to use L<Alien::Build::Plugin::Download::Negotiate>
instead. It picks the appropriate fetch plugin based on your platform and environment.
In some cases you may need to use this plugin directly instead.
This fetch plugin fetches files and directory listings via the C<ftp>, protocol using
L<Net::FTP>.
=head1 PROPERTIES
=head2 url
The initial URL to fetch. This may be a directory or the final file.
=head2 ssl
This property is for compatibility with other fetch plugins, but is not used.
=head2 passive
If set to true, try passive mode FIRST. By default it will try an active mode, then
passive mode.
=head1 SEE ALSO
L<Alien::Build::Plugin::Download::Negotiate>, L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,219 @@
package Alien::Build::Plugin::Fetch::Wget;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use File::Temp qw( tempdir );
use Path::Tiny qw( path );
use File::Which qw( which );
use Capture::Tiny qw( capture );
use File::chdir;
# ABSTRACT: Plugin for fetching files using wget
our $VERSION = '2.38'; # VERSION
has wget_command => sub { defined $ENV{WGET} ? which($ENV{WGET}) : which('wget') };
has ssl => 0;
# when bootstrapping we have to specify this plugin as a prereq
# 1 is the default so that when this plugin is used directly
# you also get the prereq
has bootstrap_ssl => 1;
sub init
{
my($self, $meta) = @_;
$meta->add_requires('configure', 'Alien::Build::Plugin::Fetch::Wget' => '1.19')
if $self->bootstrap_ssl;
$meta->register_hook(
fetch => sub {
my($build, $url) = @_;
$url ||= $meta->prop->{start_url};
my($scheme) = $url =~ /^([a-z0-9]+):/i;
if($scheme eq 'http' || $scheme eq 'https')
{
local $CWD = tempdir( CLEANUP => 1 );
my($stdout, $stderr) = $self->_execute(
$build,
$self->wget_command,
'-k', '--content-disposition', '-S',
$url,
);
my($path) = path('.')->children;
die "no file found after wget" unless $path;
my($type) = $stderr =~ /Content-Type:\s*(.*?)$/m;
$type =~ s/;.*$// if $type;
if($type eq 'text/html')
{
return {
type => 'html',
base => $url,
content => scalar $path->slurp,
};
}
else
{
return {
type => 'file',
filename => $path->basename,
path => $path->absolute->stringify,
};
}
}
else
{
die "scheme $scheme is not supported by the Fetch::Wget plugin";
}
},
) if $self->wget_command;
}
sub _execute
{
my($self, $build, @command) = @_;
$build->log("+ @command");
my($stdout, $stderr, $err) = capture {
system @command;
$?;
};
if($err)
{
chomp $stderr;
$stderr = [split /\n/, $stderr]->[-1];
die "error in wget fetch: $stderr";
}
($stdout, $stderr);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Fetch::Wget - Plugin for fetching files using wget
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
share {
start_url 'https://www.openssl.org/source/';
plugin 'Fetch::Wget';
};
=head1 DESCRIPTION
B<WARNING>: This plugin is somewhat experimental at this time.
This plugin provides a fetch based on the C<wget> command. It works with other fetch
plugins (that is, the first one which succeeds will be used). Most of the time the best plugin
to use will be L<Alien::Build::Plugin::Download::Negotiate>, but for some SSL bootstrapping
it may be desirable to try C<wget> first.
Protocols supported: C<http>, C<https>
=head1 PROPERTIES
=head2 wget_command
The full path to the C<wget> command. The default is usually correct.
=head2 ssl
Ignored by this plugin. Provided for compatibility with some other fetch plugins.
=head1 SEE ALSO
=over 4
=item L<alienfile>
=item L<Alien::Build>
=back
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,159 @@
package Alien::Build::Plugin::Gather::IsolateDynamic;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Path::Tiny ();
use Alien::Build::Util qw( _destdir_prefix );
use File::Copy ();
# ABSTRACT: Plugin to gather dynamic libraries into a separate directory
our $VERSION = '2.38'; # VERSION
sub init
{
my($self, $meta) = @_;
# plugin was introduced in 0.42, but had a bug which was fixed in 0.48
$meta->add_requires('share' => 'Alien::Build::Plugin::Gather::IsolateDynamic' => '0.48' );
$meta->after_hook(
gather_share => sub {
my($build) = @_;
$build->log("Isolating dynamic libraries ...");
my $install_root;
if($build->meta_prop->{destdir})
{
my $destdir = $ENV{DESTDIR};
$install_root = Path::Tiny->new(_destdir_prefix($ENV{DESTDIR}, $build->install_prop->{prefix}));
}
else
{
$install_root = Path::Tiny->new($build->install_prop->{stage});
}
foreach my $dir (map { $install_root->child($_) } qw( bin lib ))
{
next unless -d $dir;
foreach my $from ($dir->children)
{
next unless $from->basename =~ /\.so/
|| $from->basename =~ /\.(dylib|bundle|la|dll|dll\.a)$/;
my $to = $install_root->child('dynamic', $from->basename);
$to->parent->mkpath;
unlink "$to" if -e $to;
$build->log("move @{[ $from->parent->basename ]}/@{[ $from->basename ]} => dynamic/@{[ $to->basename ]}");
File::Copy::move("$from", "$to") || die "unable to move $from => $to $!";
}
}
$build->log(" Done!");
},
);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Gather::IsolateDynamic - Plugin to gather dynamic libraries into a separate directory
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Gather::IsolateDynamic';
=head1 DESCRIPTION
This plugin moves dynamic libraries from the C<lib> and C<bin> directories and puts them in
their own C<dynamic> directory. This allows them to be used by FFI modules, but to be ignored
by XS modules.
This plugin provides the equivalent functionality of the C<alien_isolate_dynamic> attribute
from L<Alien::Base::ModuleBuild>.
=head1 SEE ALSO
L<Alien::Build>, L<alienfile>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,326 @@
package Alien::Build::Plugin::PkgConfig::CommandLine;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Carp ();
# ABSTRACT: Probe system and determine library or tool properties using the pkg-config command line interface
our $VERSION = '2.38'; # VERSION
has '+pkg_name' => sub {
Carp::croak "pkg_name is a required property";
};
# NOT used, for compat with other PkgConfig plugins
has register_prereqs => 1;
sub _bin_name {
# We prefer pkgconf to pkg-config because it seems to be the future.
require File::Which;
File::Which::which($ENV{PKG_CONFIG})
? $ENV{PKG_CONFIG}
: File::Which::which('pkgconf')
? 'pkgconf'
: File::Which::which('pkg-config')
? 'pkg-config'
: undef;
};
has bin_name => \&_bin_name;
has atleast_version => undef;
has exact_version => undef;
has max_version => undef;
has minimum_version => undef;
sub _val
{
my($build, $args, $prop_name) = @_;
my $string = $args->{out};
chomp $string;
$string =~ s{^\s+}{};
if($prop_name =~ /version$/)
{ $string =~ s{\s*$}{} }
else
{ $string =~ s{\s*$}{ } }
if($prop_name =~ /^(.*?)\.(.*?)\.(.*?)$/)
{ $build->runtime_prop->{$1}->{$2}->{$3} = $string }
else
{ $build->runtime_prop->{$prop_name} = $string }
();
}
sub available
{
!!_bin_name();
}
sub init
{
my($self, $meta) = @_;
my @probe;
my @gather;
my $pkgconf = $self->bin_name;
unless(defined $meta->prop->{env}->{PKG_CONFIG})
{
$meta->prop->{env}->{PKG_CONFIG} = $pkgconf;
}
my($pkg_name, @alt_names) = (ref $self->pkg_name) ? (@{ $self->pkg_name }) : ($self->pkg_name);
push @probe, map { [$pkgconf, '--exists', $_] } ($pkg_name, @alt_names);
if(defined $self->minimum_version)
{
push @probe, [ $pkgconf, '--atleast-version=' . $self->minimum_version, $pkg_name ];
}
elsif(defined $self->atleast_version)
{
push @probe, [ $pkgconf, '--atleast-version=' . $self->atleast_version, $pkg_name ];
}
if(defined $self->exact_version)
{
push @probe, [ $pkgconf, '--exact-version=' . $self->exact_version, $pkg_name ];
}
if(defined $self->max_version)
{
push @probe, [ $pkgconf, '--max-version=' . $self->max_version, $pkg_name ];
}
push @probe, [ $pkgconf, '--modversion', $pkg_name, sub {
my($build, $args) = @_;
my $version = $args->{out};
$version =~ s{^\s+}{};
$version =~ s{\s*$}{};
$build->hook_prop->{version} = $version;
}];
unshift @probe, sub {
my($build) = @_;
$build->runtime_prop->{legacy}->{name} ||= $pkg_name;
$build->hook_prop->{probe_class} = __PACKAGE__;
$build->hook_prop->{probe_instance_id} = $self->instance_id;
};
$meta->register_hook(
probe => \@probe
);
push @gather, sub {
my($build) = @_;
die 'pkg-config command line probe does not match gather' if $build->hook_prop->{name} eq 'gather_system'
&& ($build->install_prop->{system_probe_instance_id} || '') ne $self->instance_id;
};
push @gather, map { [ $pkgconf, '--exists', $_] } ($pkg_name, @alt_names);
foreach my $prop_name (qw( cflags libs version ))
{
my $flag = $prop_name eq 'version' ? '--modversion' : "--$prop_name";
push @gather,
[ $pkgconf, $flag, $pkg_name, sub { _val @_, $prop_name } ];
if(@alt_names)
{
foreach my $alt ($pkg_name, @alt_names)
{
push @gather,
[ $pkgconf, $flag, $alt, sub { _val @_, "alt.$alt.$prop_name" } ];
}
}
}
foreach my $prop_name (qw( cflags libs ))
{
push @gather,
[ $pkgconf, '--static', "--$prop_name", $pkg_name, sub { _val @_, "${prop_name}_static" } ];
if(@alt_names)
{
foreach my $alt ($pkg_name, @alt_names)
{
push @gather,
[ $pkgconf, '--static', "--$prop_name", $alt, sub { _val @_, "alt.$alt.${prop_name}_static" } ];
}
}
}
$meta->register_hook(gather_system => [@gather]);
if($meta->prop->{platform}->{system_type} eq 'windows-mingw')
{
@gather = map {
if(ref $_ eq 'ARRAY') {
my($pkgconf, @rest) = @$_;
[$pkgconf, '--dont-define-prefix', @rest],
} else {
$_
}
} @gather;
}
$meta->register_hook(gather_share => [@gather]);
$meta->after_hook(
$_ => sub {
my($build) = @_;
if(keys %{ $build->runtime_prop->{alt} } < 2)
{
delete $build->runtime_prop->{alt};
}
},
) for qw( gather_system gather_share );
$self;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::PkgConfig::CommandLine - Probe system and determine library or tool properties using the pkg-config command line interface
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'PkgConfig::CommandLine' => (
pkg_name => 'libfoo',
);
=head1 DESCRIPTION
Note: in most case you will want to use L<Alien::Build::Plugin::PkgConfig::Negotiate>
instead. It picks the appropriate fetch plugin based on your platform and environment.
In some cases you may need to use this plugin directly instead.
This plugin provides Probe and Gather steps for pkg-config based packages. It uses
the best command line tools to accomplish this task.
=head1 PROPERTIES
=head2 pkg_name
The package name. If this is a list reference then .pc files with all those package
names must be present.
=head2 atleast_version
The minimum required version that is acceptable version as provided by the system.
=head2 exact_version
The exact required version that is acceptable version as provided by the system.
=head2 max_version
The max required version that is acceptable version as provided by the system.
=head2 minimum_version
Alias for C<atleast_version> for backward compatibility.
=head1 METHODS
=head2 available
my $bool = Alien::Build::Plugin::PkgConfig::CommandLine->available;
Returns true if the necessary prereqs for this plugin are I<already> installed.
=head1 SEE ALSO
L<Alien::Build::Plugin::PkgConfig::Negotiate>, L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,301 @@
package Alien::Build::Plugin::PkgConfig::LibPkgConf;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Carp ();
# ABSTRACT: Probe system and determine library or tool properties using PkgConfig::LibPkgConf
our $VERSION = '2.38'; # VERSION
has '+pkg_name' => sub {
Carp::croak "pkg_name is a required property";
};
has atleast_version => undef;
has exact_version => undef;
has max_version => undef;
has minimum_version => undef;
# private for now, used by negotiator
has register_prereqs => 1;
use constant _min_version => '0.04';
sub available
{
!!eval { require PkgConfig::LibPkgConf; PkgConfig::LibPkgConf->VERSION(_min_version) };
}
sub init
{
my($self, $meta) = @_;
unless(defined $meta->prop->{env}->{PKG_CONFIG})
{
# TODO: this doesn't yet find pkgconf in the bin dir of a share
# install.
my $command_line =
File::Which::which('pkgconf')
? 'pkgconf'
: File::Which::which('pkg-config')
? 'pkg-config'
: undef;
$meta->prop->{env}->{PKG_CONFIG} = $command_line
if defined $command_line;
}
if($self->register_prereqs)
{
# Also update in Neotiate.pm
$meta->add_requires('configure' => 'PkgConfig::LibPkgConf::Client' => _min_version);
if(defined $self->minimum_version || defined $self->atleast_version || defined $self->exact_version || defined $self->max_version)
{
$meta->add_requires('configure' => 'PkgConfig::LibPkgConf::Util' => _min_version);
}
}
my($pkg_name, @alt_names) = (ref $self->pkg_name) ? (@{ $self->pkg_name }) : ($self->pkg_name);
$meta->register_hook(
probe => sub {
my($build) = @_;
$build->runtime_prop->{legacy}->{name} ||= $pkg_name;
$build->hook_prop->{probe_class} = __PACKAGE__;
$build->hook_prop->{probe_instance_id} = $self->instance_id;
require PkgConfig::LibPkgConf::Client;
my $client = PkgConfig::LibPkgConf::Client->new;
my $pkg = $client->find($pkg_name);
die "package $pkg_name not found" unless $pkg;
$build->hook_prop->{version} = $pkg->version;
my $atleast_version = $self->atleast_version;
$atleast_version = $self->minimum_version unless defined $self->atleast_version;
if($atleast_version)
{
require PkgConfig::LibPkgConf::Util;
if(PkgConfig::LibPkgConf::Util::compare_version($pkg->version, $atleast_version) < 0)
{
die "package $pkg_name is version @{[ $pkg->version ]}, but at least $atleast_version is required.";
}
}
if($self->exact_version)
{
require PkgConfig::LibPkgConf::Util;
if(PkgConfig::LibPkgConf::Util::compare_version($pkg->version, $self->exact_version) != 0)
{
die "package $pkg_name is version @{[ $pkg->version ]}, but exactly @{[ $self->exact_version ]} is required.";
}
}
if($self->max_version)
{
require PkgConfig::LibPkgConf::Util;
if(PkgConfig::LibPkgConf::Util::compare_version($pkg->version, $self->max_version) > 0)
{
die "package $pkg_name is version @{[ $pkg->version ]}, but max @{[ $self->max_version ]} is required.";
}
}
foreach my $alt (@alt_names)
{
my $pkg = $client->find($alt);
die "package $alt not found" unless $pkg;
}
'system';
},
);
$meta->register_hook(
$_ => sub {
my($build) = @_;
return if $build->hook_prop->{name} eq 'gather_system'
&& ($build->install_prop->{system_probe_instance_id} || '') ne $self->instance_id;
require PkgConfig::LibPkgConf::Client;
my $client = PkgConfig::LibPkgConf::Client->new;
foreach my $name ($pkg_name, @alt_names)
{
my $pkg = $client->find($name);
die "reload of package $name failed" unless defined $pkg;
my %prop;
$prop{version} = $pkg->version;
$prop{cflags} = $pkg->cflags;
$prop{libs} = $pkg->libs;
$prop{cflags_static} = $pkg->cflags_static;
$prop{libs_static} = $pkg->libs_static;
$build->runtime_prop->{alt}->{$name} = \%prop;
}
foreach my $key (keys %{ $build->runtime_prop->{alt}->{$pkg_name} })
{
$build->runtime_prop->{$key} = $build->runtime_prop->{alt}->{$pkg_name}->{$key};
}
if(keys %{ $build->runtime_prop->{alt} } == 1)
{
delete $build->runtime_prop->{alt};
}
},
) for qw( gather_system gather_share );
$self;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::PkgConfig::LibPkgConf - Probe system and determine library or tool properties using PkgConfig::LibPkgConf
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'PkgConfig::LibPkgConf' => (
pkg_name => 'libfoo',
);
=head1 DESCRIPTION
Note: in most case you will want to use L<Alien::Build::Plugin::PkgConfig::Negotiate>
instead. It picks the appropriate fetch plugin based on your platform and environment.
In some cases you may need to use this plugin directly instead.
This plugin provides Probe and Gather steps for pkg-config based packages. It uses
L<PkgConfig::LibPkgConf> to accomplish this task.
This plugin is part of the Alien::Build core For Now, but may be removed in a future
date. While It Seemed Like A Good Idea at the time, it may not be appropriate to keep
it in core. If it is spun off it will get its own distribution some time in the future.
=head1 PROPERTIES
=head2 pkg_name
The package name. If this is a list reference then .pc files with all those package
names must be present.
=head2 atleast_version
The minimum required version that is acceptable version as provided by the system.
=head2 exact_version
The exact required version that is acceptable version as provided by the system.
=head2 max_version
The max required version that is acceptable version as provided by the system.
=head2 minimum_version
Alias for C<atleast_version> for backward compatibility.
=head1 METHODS
=head2 available
my $bool = Alien::Build::Plugin::PkgConfig::LibPkgConf->available;
Returns true if the necessary prereqs for this plugin are I<already> installed.
=head1 SEE ALSO
L<Alien::Build::Plugin::PkgConfig::Negotiate>, L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,200 @@
package Alien::Build::Plugin::PkgConfig::MakeStatic;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Path::Tiny ();
# ABSTRACT: Convert .pc files into static
our $VERSION = '2.38'; # VERSION
has path => undef;
sub _convert
{
my($self, $build, $path) = @_;
die "unable to read $path" unless -r $path;
die "unable to write $path" unless -w $path;
$build->log("converting $path to static");
my %h = map {
my($key, $value) = /^(.*?):(.*?)$/;
$value =~ s{^\s+}{};
$value =~ s{\s+$}{};
($key => $value);
} grep /^(?:Libs|Cflags)(?:\.private)?:/, $path->lines;
$h{Cflags} = '' unless defined $h{Cflags};
$h{Libs} = '' unless defined $h{Libs};
$h{Cflags} .= ' ' . $h{"Cflags.private"} if defined $h{"Cflags.private"};
$h{Libs} .= ' ' . $h{"Libs.private"} if defined $h{"Libs.private"};
$h{"Cflags.private"} = '';
$h{"Libs.private"} = '';
$path->edit_lines(sub {
if(/^(.*?):/)
{
my $key = $1;
if(defined $h{$key})
{
s/^(.*?):.*$/$1: $h{$key} /;
delete $h{$key};
}
}
});
$path->append("$_: $h{$_}\n") foreach keys %h;
}
sub _recurse
{
my($self, $build, $dir) = @_;
foreach my $child ($dir->children)
{
if(-d $child)
{
$self->_recurse($build, $child);
}
elsif($child->basename =~ /\.pc$/)
{
$self->_convert($build, $child);
}
}
}
sub init
{
my($self, $meta) = @_;
$meta->add_requires('configure' => 'Alien::Build::Plugin::Build::SearchDep' => '0.35');
$meta->before_hook(
gather_share => sub {
my($build) = @_;
if($self->path)
{
$self->_convert($build, Path::Tiny->new($self->path)->absolute);
}
else
{
$self->_recurse($build, Path::Tiny->new(".")->absolute);
}
},
);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::PkgConfig::MakeStatic - Convert .pc files into static
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'PkgConfig::MakeStatic' => (
path => 'lib/pkgconfig/foo.pc',
);
=head1 DESCRIPTION
Convert C<.pc> file to use static linkage by default. This is an experimental
plugin, so use with caution.
=head1 PROPERTIES
=head2 path
The path to the C<.pc> file. If not provided, all C<.pc> files in the stage
directory will be converted.
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,248 @@
package Alien::Build::Plugin::PkgConfig::Negotiate;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Alien::Build::Plugin::PkgConfig::PP;
use Alien::Build::Plugin::PkgConfig::LibPkgConf;
use Alien::Build::Plugin::PkgConfig::CommandLine;
use Alien::Build::Util qw( _perl_config );
use Carp ();
# ABSTRACT: Package configuration negotiation plugin
our $VERSION = '2.38'; # VERSION
has '+pkg_name' => sub {
Carp::croak "pkg_name is a required property";
};
has atleast_version => undef;
has exact_version => undef;
has max_version => undef;
has minimum_version => undef;
sub pick
{
my($class) = @_;
return $ENV{ALIEN_BUILD_PKG_CONFIG} if $ENV{ALIEN_BUILD_PKG_CONFIG};
if(Alien::Build::Plugin::PkgConfig::LibPkgConf->available)
{
return 'PkgConfig::LibPkgConf';
}
if(Alien::Build::Plugin::PkgConfig::CommandLine->available)
{
# TODO: determine environment or flags necessary for using pkg-config
# on solaris 64 bit.
# Some advice on pkg-config and 64 bit Solaris
# https://docs.oracle.com/cd/E53394_01/html/E61689/gplhi.html
my $is_solaris64 = (_perl_config('osname') eq 'solaris' && _perl_config('ptrsize') == 8);
# PkgConfig.pm is more reliable on windows
my $is_windows = _perl_config('osname') eq 'MSWin32';
if(!$is_solaris64 && !$is_windows)
{
return 'PkgConfig::CommandLine';
}
}
if(Alien::Build::Plugin::PkgConfig::PP->available)
{
return 'PkgConfig::PP';
}
else
{
# this is a fata error. because we check for a pkg-config implementation
# at configure time, we expect at least one of these to work. (and we
# fallback on installing PkgConfig.pm as a prereq if nothing else is avail).
# we therefore expect at least one of these to work, if not, then the configuration
# of the system has shifted from underneath us.
Carp::croak("Could not find an appropriate pkg-config or pkgconf implementation, please install PkgConfig.pm, PkgConfig::LibPkgConf, pkg-config or pkgconf");
}
}
sub init
{
my($self, $meta) = @_;
my $plugin = $self->pick;
Alien::Build->log("Using PkgConfig plugin: $plugin");
if(ref($self->pkg_name) eq 'ARRAY')
{
$meta->add_requires('configure', 'Alien::Build::Plugin::PkgConfig::Negotiate' => '0.79');
}
if($self->atleast_version || $self->exact_version || $self->max_version)
{
$meta->add_requires('configure', 'Alien::Build::Plugin::PkgConfig::Negotiate' => '1.53');
}
my @args;
push @args, pkg_name => $self->pkg_name;
push @args, register_prereqs => 0;
foreach my $method (map { "${_}_version" } qw( minimum atleast exact max ))
{
push @args, $method => $self->$method if defined $self->$method;
}
$meta->apply_plugin($plugin, @args);
$self;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::PkgConfig::Negotiate - Package configuration negotiation plugin
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'PkgConfig' => (
pkg_name => 'libfoo',
);
=head1 DESCRIPTION
This plugin provides Probe and Gather steps for pkg-config based packages. It picks
the best C<PkgConfig> plugin depending your platform and environment.
=head1 PROPERTIES
=head2 pkg_name
The package name.
=head2 atleast_version
The minimum required version that is acceptable version as provided by the system.
=head2 exact_version
The exact required version that is acceptable version as provided by the system.
=head2 max_version
The max required version that is acceptable version as provided by the system.
=head2 minimum_version
Alias for C<atleast_version> for backward compatibility.
=head1 METHODS
=head2 pick
my $name = Alien::Build::Plugijn::PkgConfig::Negotiate->pick;
Returns the name of the negotiated plugin.
=head1 ENVIRONMENT
=over 4
=item ALIEN_BUILD_PKG_CONFIG
If set, this plugin will be used instead of the build in logic
which attempts to automatically pick the best plugin.
=back
=head1 SEE ALSO
L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,313 @@
package Alien::Build::Plugin::PkgConfig::PP;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Carp ();
use File::Which ();
use Env qw( @PKG_CONFIG_PATH );
# ABSTRACT: Probe system and determine library or tool properties using PkgConfig.pm
our $VERSION = '2.38'; # VERSION
has '+pkg_name' => sub {
Carp::croak "pkg_name is a required property";
};
has atleast_version => undef;
has exact_version => undef;
has max_version => undef;
has minimum_version => undef;
use constant _min_version => '0.14026';
# private for now, used by negotiator
has register_prereqs => 1;
sub available
{
!!eval { require PkgConfig; PkgConfig->VERSION(_min_version) };
}
sub _cleanup
{
my($value) = @_;
$value =~ s{\s*$}{ };
$value;
}
sub init
{
my($self, $meta) = @_;
unless(defined $meta->prop->{env}->{PKG_CONFIG})
{
# TODO: Better would be to to "execute" lib/PkgConfig.pm
# as that should always be available, and will match the
# exact version of PkgConfig.pm that we are using here.
# there are a few corner cases to deal with before we
# can do this. What is here should handle most use cases.
my $command_line =
File::Which::which('ppkg-config')
? 'ppkg-config'
: File::Which::which('pkg-config.pl')
? 'pkg-config.pl'
: File::Which::which('pkg-config')
? 'pkg-config'
: undef;
$meta->prop->{env}->{PKG_CONFIG} = $command_line
if defined $command_line;
}
if($self->register_prereqs)
{
$meta->add_requires('configure' => 'PkgConfig' => _min_version);
}
my($pkg_name, @alt_names) = (ref $self->pkg_name) ? (@{ $self->pkg_name }) : ($self->pkg_name);
$meta->register_hook(
probe => sub {
my($build) = @_;
$build->runtime_prop->{legacy}->{name} ||= $pkg_name;
$build->hook_prop->{probe_class} = __PACKAGE__;
$build->hook_prop->{probe_instance_id} = $self->instance_id;
require PkgConfig;
my $pkg = PkgConfig->find($pkg_name);
die "package @{[ $pkg_name ]} not found" if $pkg->errmsg;
$build->hook_prop->{version} = $pkg->pkg_version;
my $version = PkgConfig::Version->new($pkg->pkg_version);
my $atleast_version = $self->atleast_version;
$atleast_version = $self->minimum_version unless defined $atleast_version;
if(defined $atleast_version)
{
my $need = PkgConfig::Version->new($atleast_version);
if($version < $need)
{
die "package @{[ $pkg_name ]} is @{[ $pkg->pkg_version ]}, but at least $atleast_version is required.";
}
}
if(defined $self->exact_version)
{
my $need = PkgConfig::Version->new($self->exact_version);
if($version != $need)
{
die "package @{[ $pkg_name ]} is @{[ $pkg->pkg_version ]}, but exactly @{[ $self->exact_version ]} is required.";
}
}
if(defined $self->max_version)
{
my $need = PkgConfig::Version->new($self->max_version);
if($version > $need)
{
die "package @{[ $pkg_name ]} is @{[ $pkg->pkg_version ]}, but max of @{[ $self->max_version ]} is required.";
}
}
foreach my $alt (@alt_names)
{
my $pkg = PkgConfig->find($alt);
die "package $alt not found" if $pkg->errmsg;
}
'system';
},
);
$meta->register_hook(
$_ => sub {
my($build) = @_;
return if $build->hook_prop->{name} eq 'gather_system'
&& ($build->install_prop->{system_probe_instance_id} || '') ne $self->instance_id;
require PkgConfig;
foreach my $name ($pkg_name, @alt_names)
{
require PkgConfig;
my $pkg = PkgConfig->find($name, search_path => [@PKG_CONFIG_PATH]);
if($pkg->errmsg)
{
$build->log("Trying to load the pkg-config information from the source code build");
$build->log("of your package failed");
$build->log("You are currently using the pure-perl implementation of pkg-config");
$build->log("(AB Plugin is named PkgConfig::PP, which uses PkgConfig.pm");
$build->log("It may work better with the real pkg-config.");
$build->log("Try installing your OS' version of pkg-config or unset ALIEN_BUILD_PKG_CONFIG");
die "second load of PkgConfig.pm @{[ $name ]} failed: @{[ $pkg->errmsg ]}"
}
my %prop;
$prop{cflags} = _cleanup scalar $pkg->get_cflags;
$prop{libs} = _cleanup scalar $pkg->get_ldflags;
$prop{version} = $pkg->pkg_version;
$pkg = PkgConfig->find($name, static => 1, search_path => [@PKG_CONFIG_PATH]);
$prop{cflags_static} = _cleanup scalar $pkg->get_cflags;
$prop{libs_static} = _cleanup scalar $pkg->get_ldflags;
$build->runtime_prop->{alt}->{$name} = \%prop;
}
foreach my $key (keys %{ $build->runtime_prop->{alt}->{$pkg_name} })
{
$build->runtime_prop->{$key} = $build->runtime_prop->{alt}->{$pkg_name}->{$key};
}
if(keys %{ $build->runtime_prop->{alt} } == 1)
{
delete $build->runtime_prop->{alt};
}
}
) for qw( gather_system gather_share );
$self;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::PkgConfig::PP - Probe system and determine library or tool properties using PkgConfig.pm
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'PkgConfig::PP' => (
pkg_name => 'libfoo',
);
=head1 DESCRIPTION
Note: in most case you will want to use L<Alien::Build::Plugin::PkgConfig::Negotiate>
instead. It picks the appropriate fetch plugin based on your platform and environment.
In some cases you may need to use this plugin directly instead.
This plugin provides Probe and Gather steps for pkg-config based packages. It uses
L<PkgConfig> to accomplish this task.
=head1 PROPERTIES
=head2 pkg_name
The package name. If this is a list reference then .pc files with all those package
names must be present.
=head2 atleast_version
The minimum required version that is acceptable version as provided by the system.
=head2 exact_version
The exact required version that is acceptable version as provided by the system.
=head2 max_version
The max required version that is acceptable version as provided by the system.
=head2 minimum_version
Alias for C<atleast_version> for backward compatibility.
=head1 METHODS
=head2 available
my $bool = Alien::Build::Plugin::PkgConfig::PP->available;
Returns true if the necessary prereqs for this plugin are I<already> installed.
=head1 SEE ALSO
L<Alien::Build::Plugin::PkgConfig::Negotiate>, L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,112 @@
# PODNAME: Alien::Build::Plugin::Prefer
# ABSTRACT: Prefer Alien::Build plugins
# VERSION
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Prefer - Prefer Alien::Build plugins
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
share {
start_url 'http://ftp.gnu.org/gnu/make';
plugin 'Download';
};
=head1 DESCRIPTION
Prefer plugins sort
Decode plugins decode HTML and FTP file listings. Normally you
will want to use the L<Alien::Build::Plugin::Download::Negotiate>
plugin which will automatically load the appropriate Prefer plugins.
=over 4
=item L<Alien::Build::Plugin::Prefer::SortVersions>
=back
=head1 SEE ALSO
L<Alien::Build>, L<Alien::Build::Plugin>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,219 @@
package Alien::Build::Plugin::Prefer::BadVersion;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Carp ();
# ABSTRACT: Plugin to filter out known bad versions
our $VERSION = '2.38'; # VERSION
has '+filter' => sub { Carp::croak("The filter property is required for the Prefer::BadVersion plugin") };
sub init
{
my($self, $meta) = @_;
$meta->add_requires('configure', __PACKAGE__, '1.05');
my $filter;
if(ref($self->filter) eq '')
{
my $string = $self->filter;
$filter = sub {
my($file) = @_;
$file->{version} ne $string;
};
}
elsif(ref($self->filter) eq 'ARRAY')
{
my %filter = map { $_ => 1 } @{ $self->filter };
$filter = sub {
my($file) = @_;
! $filter{$file->{version}};
};
}
elsif(ref($self->filter) eq 'CODE')
{
my $code = $self->filter;
$filter = sub { ! $code->($_[0]) };
}
else
{
Carp::croak("unknown filter type for Prefer::BadVersion");
}
$meta->around_hook(
prefer => sub {
my($orig, $build, @therest) = @_;
my $res1 = $orig->($build, @therest);
return $res1 unless $res1->{type} eq 'list';
return {
type => 'list',
list => [
grep { $filter->($_) } @{ $res1->{list} }
],
};
},
);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Prefer::BadVersion - Plugin to filter out known bad versions
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Prefer::BadVersion' => '1.2.3';
=head1 DESCRIPTION
This plugin allows you to easily filter out known bad versions of libraries in a share install.
It doesn't affect a system install at all. You need a Prefer plugin that filters and sorts files
first. You may specify the filter in one of three ways:
=over
=item as a string
Filter out any files that match the given version.
use alienfile;
plugin 'Prefer::BadVersion' => '1.2.3';
=item as an array
Filter out all files that match any of the given versions.
use alienfile;
plugin 'Prefer::BadVersion' => [ '1.2.3', '1.2.4' ];
=item as a code reference
Filter out any files return a true value.
use alienfile;
plugin 'Prefer::BadVersion' => sub {
my($file) = @_;
$file->{version} eq '1.2.3'; # same as the string version above
};
=back
This plugin can also be used to filter out known bad versions of a library on just one platform.
For example, if you know that version 1.2.3 if bad on windows, but okay on other platforms:
use alienfile;
plugin 'Prefer::BadVersion' => '1.2.3' if $^O eq 'MSWin32';
=head1 PROPERTIES
=head2 filter
Filter out entries that match the filter.
=head1 CAVEATS
If you are using the string or array mode, then you need an existing Prefer plugin that sets the
version number for each file candidate, such as L<Alien::Build::Plugin::Prefer::SortVersions>.
Unless you want to exclude the latest version from a share install, this plugin isn't really
that useful. It has no effect on system installs, which may not be obvious at first.
=head1 SEE ALSO
=over 4
=item L<alienfile>
=item L<Alien::Build>
=item L<Alien::Build::Plugin::Prefer::SortVersions>
=back
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,221 @@
package Alien::Build::Plugin::Prefer::GoodVersion;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Carp ();
# ABSTRACT: Plugin to filter known good versions
our $VERSION = '2.38'; # VERSION
has '+filter' => sub { Carp::croak("The filter property is required for the Prefer::GoodVersion plugin") };
sub init
{
my($self, $meta) = @_;
$meta->add_requires('configure', __PACKAGE__, '1.44');
my $filter;
if(ref($self->filter) eq '')
{
my $string = $self->filter;
$filter = sub {
my($file) = @_;
$file->{version} eq $string;
};
}
elsif(ref($self->filter) eq 'ARRAY')
{
my %filter = map { $_ => 1 } @{ $self->filter };
$filter = sub {
my($file) = @_;
!! $filter{$file->{version}};
};
}
elsif(ref($self->filter) eq 'CODE')
{
my $code = $self->filter;
$filter = sub { !! $code->($_[0]) };
}
else
{
Carp::croak("unknown filter type for Prefer::GoodVersion");
}
$meta->around_hook(
prefer => sub {
my($orig, $build, @therest) = @_;
my $res1 = $orig->($build, @therest);
return $res1 unless $res1->{type} eq 'list';
return {
type => 'list',
list => [
grep { $filter->($_) } @{ $res1->{list} }
],
};
},
);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Prefer::GoodVersion - Plugin to filter known good versions
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Prefer::GoodVersion' => '1.2.3';
=head1 DESCRIPTION
This plugin allows you to specify one or more good versions of a library. This doesn't affect
a system install at all. This plugin does the opposite of the C<Prefer::BadVersion> plugin.
You need need a Prefer plugin that filters and sorts files first. You may specify the filter
in one of three ways:
=over
=item as a string
Filter any files that match the given version.
use alienfile;
plugin 'Prefer::GoodVersion' => '1.2.3';
=item as an array
Filter all files that match any of the given versions.
use alienfile;
plugin 'Prefer::GoodVersion' => [ '1.2.3', '1.2.4' ];
=item as a code reference
Filter any files return a true value.
use alienfile;
plugin 'Prefer::GoodVersion' => sub {
my($file) = @_;
$file->{version} eq '1.2.3'; # same as the string version above
};
=back
This plugin can also be used to filter known good versions of a library on just one platform.
For example, if you know that version 1.2.3 if good on windows, but the default logic is fine
on other platforms:
use alienfile;
plugin 'Prefer::GoodVersion' => '1.2.3' if $^O eq 'MSWin32';
=head1 PROPERTIES
=head2 filter
Filter entries that match the filter.
=head1 CAVEATS
If you are using the string or array mode, then you need an existing Prefer plugin that sets the
version number for each file candidate, such as L<Alien::Build::Plugin::Prefer::SortVersions>.
Unless you want to exclude the latest version from a share install, this plugin isn't really
that useful. It has no effect on system installs, which may not be obvious at first.
=head1 SEE ALSO
=over 4
=item L<alienfile>
=item L<Alien::Build>
=item L<Alien::Build::Plugin::Prefer::SortVersions>
=back
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,172 @@
package Alien::Build::Plugin::Prefer::SortVersions;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
# ABSTRACT: Plugin to sort candidates by most recent first
our $VERSION = '2.38'; # VERSION
has 'filter' => undef;
has '+version' => qr/([0-9](?:[0-9\.]*[0-9])?)/;
sub init
{
my($self, $meta) = @_;
$meta->add_requires('share' => 'Sort::Versions' => 0);
$meta->register_hook( prefer => sub {
my(undef, $res) = @_;
my $cmp = sub {
my($A,$B) = map { ($_ =~ $self->version)[0] } @_;
Sort::Versions::versioncmp($B,$A);
};
my @list = sort { $cmp->($a->{filename}, $b->{filename}) }
map {
($_->{version}) = $_->{filename} =~ $self->version;
$_ }
grep { $_->{filename} =~ $self->version }
grep { defined $self->filter ? $_->{filename} =~ $self->filter : 1 }
@{ $res->{list} };
return {
type => 'list',
list => \@list,
};
});
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Prefer::SortVersions - Plugin to sort candidates by most recent first
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Prefer::SortVersions';
=head1 DESCRIPTION
Note: in most case you will want to use L<Alien::Build::Plugin::Download::Negotiate>
instead. It picks the appropriate fetch plugin based on your platform and environment.
In some cases you may need to use this plugin directly instead.
This Prefer plugin sorts the packages that were retrieved from a dir listing, either
directly from a Fetch plugin, or from a Decode plugin. It Returns a listing with the
items sorted from post preferable to least, and filters out any undesirable candidates.
This plugin updates the file list to include the versions that are extracted, so they
can be used by other plugins, such as L<Alien::Build::Plugin::Prefer::BadVersion>.
=head1 PROPERTIES
=head2 filter
This is a regular expression that lets you filter out files that you do not
want to consider downloading. For example, if the directory listing contained
tarballs and readme files like this:
foo-1.0.0.tar.gz
foo-1.0.0.readme
You could specify a filter of C<qr/\.tar\.gz$/> to make sure only tarballs are
considered for download.
=head2 version
Regular expression to parse out the version from a filename. The regular expression
should store the result in C<$1>. The default C<qr/([0-9\.]+)/> is frequently
reasonable.
=head1 SEE ALSO
L<Alien::Build::Plugin::Download::Negotiate>, L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,125 @@
# PODNAME: Alien::Build::Plugin::Probe
# ABSTRACT: Probe Alien::Build plugins
# VERSION
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Probe - Probe Alien::Build plugins
=head1 VERSION
version 2.38
=head1 SYNOPSIS
look for libraries in known location:
use alienfile;
plugin 'Probe::CBuilder' => (
cflags => '-I/opt/libfoo/include',
libs => '-L/opt/libfoo/lib -lfoo',
);
look for tools in the path:
use alienfile;
plugin 'Probe::CommandLine' => (
command => 'gzip',
args => [ '--version' ],
match => qr/gzip/,
version => qr/gzip ([0-9\.]+)/,
);
=head1 DESCRIPTION
Probe plugins try to find existing libraries and tools
I<already> installed on the system. If found they can
be used instead of downloading the source from the
internet and building.
=over 4
=item L<Alien::Build::Plugin::Probe::CBuilder>
=item L<Alien::Build::Plugin::Probe::CommandLine>
=back
=head1 SEE ALSO
L<Alien::Build>, L<Alien::Build::Plugin>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,297 @@
package Alien::Build::Plugin::Probe::CBuilder;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use File::chdir;
use File::Temp ();
use Capture::Tiny qw( capture_merged capture );
# ABSTRACT: Probe for system libraries by guessing with ExtUtils::CBuilder
our $VERSION = '2.38'; # VERSION
has options => sub { {} };
has cflags => '';
has libs => '';
has program => 'int main(int argc, char *argv[]) { return 0; }';
has version => undef;
has aliens => [];
has lang => 'C';
sub init
{
my($self, $meta) = @_;
$meta->add_requires('configure' => 'ExtUtils::CBuilder' => 0 );
if(@{ $self->aliens })
{
die "You can't specify both 'aliens' and either 'cflags' or 'libs' for the Probe::CBuilder plugin" if $self->cflags || $self->libs;
$meta->add_requires('configure' => $_ => 0 ) for @{ $self->aliens };
$meta->add_requires('Alien::Build::Plugin::Probe::CBuilder' => '0.53');
my $cflags = '';
my $libs = '';
foreach my $alien (@{ $self->aliens })
{
my $pm = "$alien.pm";
$pm =~ s/::/\//g;
require $pm;
$cflags .= $alien->cflags . ' ';
$libs .= $alien->libs . ' ';
}
$self->cflags($cflags);
$self->libs($libs);
}
my @cpp;
if($self->lang ne 'C')
{
$meta->add_requires('Alien::Build::Plugin::Probe::CBuilder' => '0.53');
@cpp = ('C++' => 1) if $self->lang eq 'C++';
}
$meta->register_hook(
probe => sub {
my($build) = @_;
$build->hook_prop->{probe_class} = __PACKAGE__;
$build->hook_prop->{probe_instance_id} = $self->instance_id;
local $CWD = File::Temp::tempdir( CLEANUP => 1, DIR => $CWD );
open my $fh, '>', 'mytest.c';
print $fh $self->program;
close $fh;
$build->log("trying: cflags=@{[ $self->cflags ]} libs=@{[ $self->libs ]}");
my $cb = ExtUtils::CBuilder->new(%{ $self->options });
my($out1, $obj) = capture_merged { eval {
$cb->compile(
source => 'mytest.c',
extra_compiler_flags => $self->cflags,
@cpp,
);
} };
if(my $error = $@)
{
$build->log("compile failed: $error");
$build->log("compile failed: $out1");
die $@;
}
my($out2, $exe) = capture_merged { eval {
$cb->link_executable(
objects => [$obj],
extra_linker_flags => $self->libs,
);
} };
if(my $error = $@)
{
$build->log("link failed: $error");
$build->log("link failed: $out2");
die $@;
}
my($out, $err, $ret) = capture { system($^O eq 'MSWin32' ? $exe : "./$exe") };
die "execute failed" if $ret;
my $cflags = $self->cflags;
my $libs = $self->libs;
$cflags =~ s{\s*$}{ };
$libs =~ s{\s*$}{ };
$build->install_prop->{plugin_probe_cbuilder_gather}->{$self->instance_id} = {
cflags => $cflags,
libs => $libs,
};
if(defined $self->version)
{
my($version) = $out =~ $self->version;
$build->hook_prop->{version} = $version;
$build->install_prop->{plugin_probe_cbuilder_gather}->{$self->instance_id}->{version} = $version;
}
'system';
}
);
$meta->register_hook(
gather_system => sub {
my($build) = @_;
return if $build->hook_prop->{name} eq 'gather_system'
&& ($build->install_prop->{system_probe_instance_id} || '') ne $self->instance_id;
if(my $p = $build->install_prop->{plugin_probe_cbuilder_gather}->{$self->instance_id})
{
$build->runtime_prop->{$_} = $p->{$_} for keys %$p;
}
},
);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Probe::CBuilder - Probe for system libraries by guessing with ExtUtils::CBuilder
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Probe::CBuilder' => (
cflags => '-I/opt/libfoo/include',
libs => '-L/opt/libfoo/lib -lfoo',
);
alternately:
ues alienfile;
plugin 'Probe::CBuilder' => (
aliens => [ 'Alien::libfoo', 'Alien::libbar' ],
);
=head1 DESCRIPTION
This plugin probes for compiler and linker flags using L<ExtUtils::CBuilder>. This is a useful
alternative to L<Alien::Build::Plugin::PkgConfig::Negotiate> for packages that do not provide
a pkg-config C<.pc> file, or for when those C<.pc> files may not be available. (For example,
on FreeBSD, C<libarchive> is a core part of the operating system, but doesn't include a C<.pc>
file which is usually provided when you install the C<libarchive> package on Linux).
=head1 PROPERTIES
=head2 options
Any extra options that you want to have passed into the constructor to L<ExtUtils::CBuilder>.
=head2 cflags
The compiler flags.
=head2 libs
The linker flags
=head2 program
The program to use in the test.
=head2 version
This is a regular expression to parse the version out of the output from the
test program.
=head2 aliens
List of aliens to query fro compiler and linker flags.
=head2 lang
The programming language to use. One of either C<C> or C<C++>.
=head1 SEE ALSO
L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,248 @@
package Alien::Build::Plugin::Probe::CommandLine;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Carp ();
use Capture::Tiny qw( capture );
use File::Which ();
# ABSTRACT: Probe for tools or commands already available
our $VERSION = '2.38'; # VERSION
has '+command' => sub { Carp::croak "@{[ __PACKAGE__ ]} requires command property" };
has 'args' => [];
has 'secondary' => 0;
has 'match' => undef;
has 'match_stderr' => undef;
has 'version' => undef;
has 'version_stderr' => undef;
sub init
{
my($self, $meta) = @_;
my $check = sub {
my($build) = @_;
unless(File::Which::which($self->command))
{
die 'Command not found ' . $self->command;
}
if(defined $self->match || defined $self->match_stderr || defined $self->version || defined $self->version_stderr)
{
my($out,$err,$ret) = capture {
system( $self->command, @{ $self->args } );
};
die 'Command did not return a true value' if $ret;
die 'Command output did not match' if defined $self->match && $out !~ $self->match;
die 'Command standard error did not match' if defined $self->match_stderr && $err !~ $self->match_stderr;
if(defined $self->version)
{
if($out =~ $self->version)
{
$build->runtime_prop->{version} = $1;
}
}
if(defined $self->version_stderr)
{
if($err =~ $self->version_stderr)
{
$build->hook_prop->{version} = $1;
$build->runtime_prop->{version} = $1;
}
}
}
$build->runtime_prop->{command} = $self->command;
'system';
};
if($self->secondary)
{
$meta->around_hook(
probe => sub {
my $orig = shift;
my $build = shift;
my $type = $orig->($build, @_);
return $type unless $type eq 'system';
$check->($build);
},
);
}
else
{
$meta->register_hook(
probe => $check,
);
}
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Probe::CommandLine - Probe for tools or commands already available
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Probe::CommandLine' => (
command => 'gzip',
args => [ '--version' ],
match => qr/gzip/,
version => qr/gzip ([0-9\.]+)/,
);
=head1 DESCRIPTION
This plugin probes for the existence of the given command line program.
=head1 PROPERTIES
=head2 command
The name of the command.
=head2 args
The arguments to pass to the command.
=head2 secondary
If you are using another probe plugin (such as L<Alien::Build::Plugin::Probe::CBuilder> or
L<Alien::Build::Plugin::PkgConfig::Negotiate>) to detect the existence of a library, but
also need a program to exist, then you should set secondary to a true value. For example
when you need both:
use alienfile;
# requires both liblzma library and xz program
plugin 'PkgConfig' => 'liblzma';
plugin 'Probe::CommandLine => (
command => 'xz',
secondary => 1,
);
When you don't:
use alienfile;
plugin 'Probe::CommandLine' => (
command => 'gzip',
secondary => 0, # default
);
=head2 match
Regular expression for which the program output should match.
=head2 match_stderr
Regular expression for which the program standard error should match.
=head2 version
Regular expression to parse out the version from the program output.
The regular expression should store the version number in C<$1>.
=head2 version_stderr
Regular expression to parse out the version from the program standard error.
The regular expression should store the version number in C<$1>.
=head1 SEE ALSO
L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,269 @@
package Alien::Build::Plugin::Probe::Vcpkg;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
# ABSTRACT: Probe for system libraries using Vcpkg
our $VERSION = '2.38'; # VERSION
has '+name';
has 'lib';
has 'ffi_name';
has 'include';
sub init
{
my($self, $meta) = @_;
if(defined $self->include)
{
$meta->add_requires('configure' => 'Alien::Build::Plugin::Probe::Vcpkg' => '2.16' );
}
elsif(defined $self->ffi_name)
{
$meta->add_requires('configure' => 'Alien::Build::Plugin::Probe::Vcpkg' => '2.14' );
}
else
{
$meta->add_requires('configure' => 'Alien::Build::Plugin::Probe::Vcpkg' => '0' );
}
if($meta->prop->{platform}->{compiler_type} eq 'microsoft')
{
$meta->register_hook(
probe => sub {
my($build) = @_;
$build->hook_prop->{probe_class} = __PACKAGE__;
$build->hook_prop->{probe_instance_id} = $self->instance_id;
eval {
require Win32::Vcpkg;
require Win32::Vcpkg::List;
require Win32::Vcpkg::Package;
Win32::Vcpkg->VERSION('0.02');
};
if(my $error = $@)
{
$build->log("unable to load Win32::Vcpkg: $error");
return 'share';
}
my $package;
if($self->name)
{
$package = Win32::Vcpkg::List->new
->search($self->name, include => $self->include);
}
elsif($self->lib)
{
$package = eval { Win32::Vcpkg::Package->new( lib => $self->lib, include => $self->include) };
return 'share' if $@;
}
else
{
$build->log("you must provode either name or lib property for Probe::Vcpkg");
return 'share';
}
my $version = $package->version;
$version = 'unknown' unless defined $version;
$build->install_prop->{plugin_probe_vcpkg}->{$self->instance_id} = {
version => $version,
cflags => $package->cflags,
libs => $package->libs,
};
$build->hook_prop->{version} = $version;
$build->install_prop->{plugin_probe_vcpkg}->{$self->instance_id}->{ffi_name} = $self->ffi_name
if defined $self->ffi_name;
return 'system';
},
);
$meta->register_hook(
gather_system => sub {
my($build) = @_;
return if $build->hook_prop->{name} eq 'gather_system'
&& ($build->install_prop->{system_probe_instance_id} || '') ne $self->instance_id;
if(my $c = $build->install_prop->{plugin_probe_vcpkg}->{$self->instance_id})
{
$build->runtime_prop->{version} = $c->{version} unless defined $build->runtime_prop->{version};
$build->runtime_prop->{$_} = $c->{$_} for grep { defined $c->{$_} } qw( cflags libs ffi_name );
}
},
);
}
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Probe::Vcpkg - Probe for system libraries using Vcpkg
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Probe::Vcpkg' => 'libffi';
=head1 DESCRIPTION
This plugin probe can be used to find "system" packages using Microsoft's C<Vcpkg> package manager for
Visual C++ builds of Perl. C<Vcpkg> is a package manager for Visual C++ that includes a number of
open source packages. Although C<Vcpkg> does also support Linux and macOS, this plugin does not
support finding C<Vcpkg> packages on those platforms. For more details on C<Vcpkg>, see the project
github page here:
L<https://github.com/microsoft/vcpkg>
Here is the quick start guide for getting L<Alien::Build> to work with C<Vpkg>:
# install Vcpkg
C:\> git clone https://github.com/Microsoft/vcpkg.git
C:\> cd vcpkg
C:\vcpkg> .\bootstrap-vcpkg.bat
C:\vcpkg> .\vcpkg integrate install
# update PATH to include the bin directory
# so that .DLL files can be found by Perl
C:\vcpkg> path c:\vcpkg\installed\x64-windows\bin;%PATH%
# install the packages that you want
C:\vcpkg> .\vcpkg install libffi
# install the alien that uses it
C:\vcpkg> cpanm Alien::FFI
If you are using 32 bit build of Perl, then substitute C<x86-windows> for C<x64-windows>. If you do
not want to add the C<bin> directory to the C<PATH>, then you can use C<x64-windows-static> instead,
which will provide static libraries. (As of this writing static libraries for 32 bit Windows are not
available). The main downside to using C<x64-windows-static> is that Aliens that require dynamic
libraries for FFI will not be installable.
If you do not want to install C<Vcpkg> user wide (the C<integrate install> command above), then you
can use the C<PERL_WIN32_VCPKG_ROOT> environment variable instead:
# install Vcpkg
C:\> git clone https://github.com/Microsoft/vcpkg.git
C:\> cd vcpkg
C:\vcpkg> .\bootstrap-vcpkg.bat
C:\vcpkg> set PERL_WIN32_VCPKG_ROOT=c:\vcpkg
=head1 PROPERTIES
=head2 name
Specifies the name of the Vcpkg. This should not be used with the C<lib> property below, choose only one.
This is the default property, so these two are equivalent:
plugin 'Probe::Vcpkg' => (name => 'foo');
and
plugin 'Probe::Vcpkg' => 'foo';
=head2 lib
Specifies the list of libraries that make up the Vcpkg. This should not be used with the C<name> property
above, choose only one. Note that using this detection method, the version number of the package will
not be automatically determined (since multiple packages could potentially make up the list of libraries),
so you need to determine the version number another way if you need it.
This must be an array reference. Do not include the C<.lib> extension.
plugin 'Probe::Vcpkg' => (lib => ['foo','bar']);
=head2 ffi_name
Specifies an alternate ffi_name for finding dynamic libraries.
=head1 SEE ALSO
L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien>
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut

View File

@@ -0,0 +1,442 @@
package Alien::Build::Plugin::Test::Mock;
use strict;
use warnings;
use 5.008004;
use Alien::Build::Plugin;
use Carp ();
use Path::Tiny ();
use File::chdir;
# ABSTRACT: Mock plugin for testing
our $VERSION = '2.38'; # VERSION
has 'probe';
has 'download';
has 'extract';
has 'build';
has 'gather';
sub init
{
my($self, $meta) = @_;
if(my $probe = $self->probe)
{
if($probe =~ /^(share|system)$/)
{
$meta->register_hook(
probe => sub {
$probe;
},
);
}
elsif($probe eq 'die')
{
$meta->register_hook(
probe => sub {
die "fail";
},
);
}
else
{
Carp::croak("usage: plugin 'Test::Mock' => ( probe => $probe ); where $probe is one of share, system or die");
}
}
if(my $download = $self->download)
{
$download = { 'foo-1.00.tar.gz' => _tarball() } unless ref $download eq 'HASH';
$meta->register_hook(
download => sub {
my($build) = @_;
_fs($build, $download);
},
);
}
if(my $extract = $self->extract)
{
$extract = {
'foo-1.00' => {
'configure' => _tarball_configure(),
'foo.c' => _tarball_foo_c(),
},
} unless ref $extract eq 'HASH';
$meta->register_hook(
extract => sub {
my($build) = @_;
_fs($build, $extract);
},
);
}
if(my $build = $self->build)
{
$build = [
{
'foo.o', => _build_foo_o(),
'libfoo.a' => _build_libfoo_a(),
},
{
'lib' => {
'libfoo.a' => _build_libfoo_a(),
'pkgconfig' => {
'foo.pc' => sub {
my($build) = @_;
"prefix=$CWD\n" .
"exec_prefix=\${prefix}\n" .
"libdir=\${prefix}/lib\n" .
"includedir=\${prefix}/include\n" .
"\n" .
"Name: libfoo\n" .
"Description: libfoo\n" .
"Version: 1.0.0\n" .
"Cflags: -I\${includedir}\n" .
"Libs: -L\${libdir} -lfoo\n";
},
},
},
},
] unless ref $build eq 'ARRAY';
my($build_dir, $install_dir) = @$build;
$meta->register_hook(
build => sub {
my($build) = @_;
_fs($build, $build_dir);
local $CWD = $build->install_prop->{prefix};
_fs($build, $install_dir);
},
);
}
if(my $gather = $self->gather)
{
$meta->register_hook(
$_ => sub {
my($build) = @_;
if(ref $gather eq 'HASH')
{
foreach my $key (keys %$gather)
{
$build->runtime_prop->{$key} = $gather->{$key};
}
}
else
{
my $prefix = $build->runtime_prop->{prefix};
$build->runtime_prop->{cflags} = "-I$prefix/include";
$build->runtime_prop->{libs} = "-L$prefix/lib -lfoo";
}
},
) for qw( gather_share gather_system );
}
}
sub _fs
{
my($build, $hash) = @_;
foreach my $key (sort keys %$hash)
{
my $val = $hash->{$key};
if(ref $val eq 'HASH')
{
mkdir $key;
local $CWD = $key;
_fs($build,$val);
}
elsif(ref $val eq 'CODE')
{
Path::Tiny->new($key)->spew($val->($build));
}
elsif(defined $val)
{
Path::Tiny->new($key)->spew($val);
}
}
}
sub _tarball
{
return unpack 'u', <<'EOF';
M'XL(`+DM@5@``^V4P4K$,!"&>YZGF-V]J*SM9#=)#RN^B'BHV;0)U`32U(OX
M[D;0*LJREZVRF.\R?TA@)OS\TWI_S4JBJI@/(JJ%P%19+>AKG4"V)4Z;C922
M(;T=6(%BQIDFQB$V(8WB^]X.W>%WQ^[?_S'5,Z']\%]YU]IN#/KT/8[ZO^6?
M_B=-C-=<%$BG'^4G_]S_U:)ZL*X:#(!6QN/26(Q&![W<P5_/EIF?*?])E&J>
M'BD/DO/#^6<DON__6O*<_]]@99WJQ[W&FR'NK2_-+8!U$1X;ZRZ2P"9T:HW*
D-`&ODGZZN[^$9T`,.H[!(>W@)2^*3":3.3]>`:%LBYL`#@``
`
EOF
}
sub _tarball_configure
{
return unpack 'u', <<'EOF';
<(R$O8FEN+W-H"@IE8VAO(")H:2!T:&5R92(["@``
`
EOF
}
sub _tarball_foo_c
{
return unpack 'u', <<'EOF';
M(VEN8VQU9&4@/'-T9&EO+F@^"@II;G0*;6%I;BAI;G0@87)G8RP@8VAA<B`J
887)G=EM=*0I["B`@<F5T=7)N(#`["GT*
`
EOF
}
sub _build_foo_o
{
return unpack 'u', <<'EOF';
MS_KM_@<```$#`````0````0```"P`0```"`````````9````.`$`````````
M`````````````````````````&@`````````T`$```````!H``````````<`
M```'`````P````````!?7W1E>'0`````````````7U]415A4````````````
M````````````"`````````#0`0``!`````````````````0`@```````````
M`````%]?8V]M<&%C=%]U;G=I;F1?7TQ$````````````````"``````````@
M`````````-@!```#````.`(```$````````"````````````````7U]E:%]F
M<F%M90```````%]?5$585``````````````H`````````$``````````^`$`
M``,```````````````L``&@````````````````D````$``````-"@``````
M`@```!@```!``@```0```%`"```(````"P```%`````````````````````!
M`````0``````````````````````````````````````````````````````
M``````````````````!52(GE,<!=PP``````````"`````````$`````````
M````````````%``````````!>E(``7@0`1`,!PB0`0``)````!P```"X____
M_____P@``````````$$.$(8"0PT&```````````````!```&`0````\!````
/``````````!?;6%I;@``
`
EOF
}
sub _build_libfoo_a
{
return unpack 'u', <<'EOF';
M(3QA<F-H/@HC,2\R,"`@("`@("`@("`@,34S,S$U-38Q."`@-3`Q("`@,C`@
M("`@,3`P-C0T("`T-"`@("`@("`@8`I?7RY364U$148@4T]25$5$``````@`
M````````<`````@```!?;6%I;@```",Q+S$R("`@("`@("`@("`Q-3,S,34U
M-#8X("`U,#$@("`R,"`@("`Q,#`V-#0@(#8Q,B`@("`@("!@"F9O;RYO````
M`````,_Z[?X'```!`P````$````$````L`$````@````````&0```#@!````
M``````````````````````````````!H`````````-`!````````:```````
M```'````!P````,`````````7U]T97AT`````````````%]?5$585```````
M``````````````````@`````````T`$```0````````````````$`(``````
M``````````!?7V-O;7!A8W1?=6YW:6YD7U],1`````````````````@`````
M````(`````````#8`0```P```#@"```!`````````@```````````````%]?
M96A?9G)A;64```````!?7U1%6%0`````````````*`````````!`````````
M`/@!```#```````````````+``!H````````````````)````!``````#0H`
M``````(````8````0`(```$```!0`@``"`````L```!0````````````````
M`````0````$`````````````````````````````````````````````````
M````````````````````````54B)Y3'`7<,```````````@````````!````
M`````````````````!0``````````7I2``%X$`$0#`<(D`$``"0````<````
MN/________\(``````````!!#A"&`D,-!@```````````````0``!@$````/
3`0``````````````7VUA:6X`````
`
EOF
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Test::Mock - Mock plugin for testing
=head1 VERSION
version 2.38
=head1 SYNOPSIS
use alienfile;
plugin 'Test::Mock' => (
probe => 'share',
download => 1,
extract => 1,
build => 1,
gather => 1,
);
=head1 DESCRIPTION
This plugin is used for testing L<Alien::Build> plugins. Usually you only want to test
one or two phases in an L<alienfile> for your plugin, but you still have to have a fully
formed L<alienfile> that contains all required phases. This plugin lets you fill in the
other phases with the appropriate hooks. This is usually better than using real plugins
which may pull in additional dynamic requirements that you do not want to rely on at
test time.
=head1 PROPERTIES
=head2 probe
plugin 'Test::Mock' => (
probe => $probe,
);
Override the probe behavior by one of the following:
=over
=item share
For a C<share> build.
=item system
For a C<system> build.
=item die
To throw an exception in the probe hook. This will usually cause L<Alien::Build>
to try the next probe hook, if available, or to assume a C<share> install.
=back
=head2 download
plugin 'Test::Mock' => (
download => \%fs_spec,
);
plugin 'Test::Mock' => (
download => 1,
);
Mock out a download. The C<%fs_spec> is a hash where the hash values are directories
and the string values are files. This a spec like this:
plugin 'Test::Mock' => (
download => {
'foo-1.00' => {
'README.txt' => "something to read",
'foo.c' => "#include <stdio.h>\n",
"int main() {\n",
" printf(\"hello world\\n\");\n",
"}\n",
}
},
);
Would generate two files in the directory 'foo-1.00', a C<README.txt> and a C file named C<foo.c>.
The default, if you provide a true non-hash value is to generate a single tarball with the name
C<foo-1.00.tar.gz>.
=head2 extract
plugin 'Test::Mock' => (
extract => \%fs_spec,
);
plugin 'Test::Mock' => (
extract => 1,
);
Similar to C<download> above, but for the C<extract> phase.
=head2 build
plugin 'Test::Mock' => (
build => [ \%fs_spec_build, \%fs_spec_install ],
);
plugin 'Test::Mock' => (
build => 1,
);
=head2 gather
plugin 'Test::Mock' => (
gather => \%runtime_prop,
);
plugin 'Test::Mock' => (
gather => 1,
);
This adds a gather hook (for both C<share> and C<system>) that adds the given runtime properties, or
if a true non-hash value is provided, some reasonable runtime properties for testing.
=head1 AUTHOR
Author: Graham Ollis E<lt>plicease@cpan.orgE<gt>
Contributors:
Diab Jerius (DJERIUS)
Roy Storey (KIWIROY)
Ilya Pavlov
David Mertens (run4flat)
Mark Nunberg (mordy, mnunberg)
Christian Walde (Mithaldu)
Brian Wightman (MidLifeXis)
Zaki Mughal (zmughal)
mohawk (mohawk2, ETJ)
Vikas N Kumar (vikasnkumar)
Flavio Poletti (polettix)
Salvador Fandiño (salva)
Gianni Ceccarelli (dakkar)
Pavel Shaydo (zwon, trinitum)
Kang-min Liu (劉康民, gugod)
Nicholas Shipp (nshp)
Juan Julián Merelo Guervós (JJ)
Joel Berger (JBERGER)
Petr Pisar (ppisar)
Lance Wicks (LANCEW)
Ahmad Fatoum (a3f, ATHREEF)
José Joaquín Atria (JJATRIA)
Duke Leto (LETO)
Shoichi Kaji (SKAJI)
Shawn Laffan (SLAFFAN)
Paul Evans (leonerd, PEVANS)
Håkon Hægland (hakonhagland, HAKONH)
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2011-2020 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.
=cut