1package Alien::Build::Plugin::Extract::Directory; 2 3use strict; 4use warnings; 5use 5.008004; 6use Alien::Build::Plugin; 7use Alien::Build::Util qw( _mirror ); 8use Path::Tiny (); 9 10# ABSTRACT: Plugin to extract a downloaded directory to a build directory 11our $VERSION = '2.45'; # VERSION 12 13 14has '+format' => 'd'; 15 16 17sub handles 18{ 19 my(undef, $ext) = @_; 20 $ext eq 'd' ? 1 : (); 21} 22 23 24sub available 25{ 26 my(undef, $ext) = @_; 27 __PACKAGE__->handles($ext); 28} 29 30sub init 31{ 32 my($self, $meta) = @_; 33 34 $meta->register_hook( 35 extract => sub { 36 my($build, $src) = @_; 37 38 die "not a directory: $src" unless -d $src; 39 40 if($build->meta_prop->{out_of_source}) 41 { 42 $build->install_prop->{extract} = Path::Tiny->new($src)->absolute->stringify; 43 } 44 else 45 { 46 my $dst = Path::Tiny->new('.')->absolute; 47 # Please note: _mirror and Alien::Build::Util are ONLY 48 # allowed to be used by core plugins. If you are writing 49 # a non-core plugin it may be removed. That is why it 50 # is private. 51 _mirror $src => $dst, { verbose => 1 }; 52 } 53 } 54 ); 55} 56 571; 58 59__END__ 60 61=pod 62 63=encoding UTF-8 64 65=head1 NAME 66 67Alien::Build::Plugin::Extract::Directory - Plugin to extract a downloaded directory to a build directory 68 69=head1 VERSION 70 71version 2.45 72 73=head1 SYNOPSIS 74 75 use alienfile; 76 plugin 'Extract::Directory'; 77 78=head1 DESCRIPTION 79 80Some Download or Fetch plugins may produce a directory instead of an archive 81file. This plugin is used to mirror the directory from the Download step 82into a fresh directory in the Extract step. An example of when you might use 83this plugin is if you were using the C<git> command in the Download step, 84which results in a directory hierarchy. 85 86=head1 PROPERTIES 87 88=head2 format 89 90Should always set to C<d> (for directories). 91 92=head1 METHODS 93 94=head2 handles 95 96 Alien::Build::Plugin::Extract::Directory->handles($ext); 97 $plugin->handles($ext); 98 99Returns true if the plugin is able to handle the archive of the 100given format. Only returns true for C<d> (for directory). 101 102=head2 available 103 104 Alien::Build::Plugin::Extract::Directory->available($ext); 105 $plugin->available($ext); 106 107Returns true if the plugin can extract the given format with 108what is already installed. 109 110=head1 SEE ALSO 111 112L<Alien::Build::Plugin::Extract::Negotiate>, L<Alien::Build>, L<alienfile>, L<Alien::Build::MM>, L<Alien> 113 114=head1 AUTHOR 115 116Author: Graham Ollis E<lt>plicease@cpan.orgE<gt> 117 118Contributors: 119 120Diab Jerius (DJERIUS) 121 122Roy Storey (KIWIROY) 123 124Ilya Pavlov 125 126David Mertens (run4flat) 127 128Mark Nunberg (mordy, mnunberg) 129 130Christian Walde (Mithaldu) 131 132Brian Wightman (MidLifeXis) 133 134Zaki Mughal (zmughal) 135 136mohawk (mohawk2, ETJ) 137 138Vikas N Kumar (vikasnkumar) 139 140Flavio Poletti (polettix) 141 142Salvador Fandiño (salva) 143 144Gianni Ceccarelli (dakkar) 145 146Pavel Shaydo (zwon, trinitum) 147 148Kang-min Liu (劉康民, gugod) 149 150Nicholas Shipp (nshp) 151 152Juan Julián Merelo Guervós (JJ) 153 154Joel Berger (JBERGER) 155 156Petr Písař (ppisar) 157 158Lance Wicks (LANCEW) 159 160Ahmad Fatoum (a3f, ATHREEF) 161 162José Joaquín Atria (JJATRIA) 163 164Duke Leto (LETO) 165 166Shoichi Kaji (SKAJI) 167 168Shawn Laffan (SLAFFAN) 169 170Paul Evans (leonerd, PEVANS) 171 172Håkon Hægland (hakonhagland, HAKONH) 173 174nick nauwelaerts (INPHOBIA) 175 176=head1 COPYRIGHT AND LICENSE 177 178This software is copyright (c) 2011-2020 by Graham Ollis. 179 180This is free software; you can redistribute it and/or modify it under 181the same terms as the Perl 5 programming language system itself. 182 183=cut 184