Initial Commit
This commit is contained in:
358
database/perl/vendor/lib/Alien/Build/Plugin/Fetch/CurlCommand.pm
vendored
Normal file
358
database/perl/vendor/lib/Alien/Build/Plugin/Fetch/CurlCommand.pm
vendored
Normal 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
|
||||
235
database/perl/vendor/lib/Alien/Build/Plugin/Fetch/HTTPTiny.pm
vendored
Normal file
235
database/perl/vendor/lib/Alien/Build/Plugin/Fetch/HTTPTiny.pm
vendored
Normal 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
|
||||
197
database/perl/vendor/lib/Alien/Build/Plugin/Fetch/LWP.pm
vendored
Normal file
197
database/perl/vendor/lib/Alien/Build/Plugin/Fetch/LWP.pm
vendored
Normal 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
|
||||
226
database/perl/vendor/lib/Alien/Build/Plugin/Fetch/Local.pm
vendored
Normal file
226
database/perl/vendor/lib/Alien/Build/Plugin/Fetch/Local.pm
vendored
Normal 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
|
||||
210
database/perl/vendor/lib/Alien/Build/Plugin/Fetch/LocalDir.pm
vendored
Normal file
210
database/perl/vendor/lib/Alien/Build/Plugin/Fetch/LocalDir.pm
vendored
Normal 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
|
||||
267
database/perl/vendor/lib/Alien/Build/Plugin/Fetch/NetFTP.pm
vendored
Normal file
267
database/perl/vendor/lib/Alien/Build/Plugin/Fetch/NetFTP.pm
vendored
Normal 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
|
||||
219
database/perl/vendor/lib/Alien/Build/Plugin/Fetch/Wget.pm
vendored
Normal file
219
database/perl/vendor/lib/Alien/Build/Plugin/Fetch/Wget.pm
vendored
Normal 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
|
||||
Reference in New Issue
Block a user