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.84'; # 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.84
=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