-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
2,043 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#line 1 | ||
package Module::Install::AuthorTests; | ||
|
||
use 5.005; | ||
use strict; | ||
use Module::Install::Base; | ||
use Carp (); | ||
|
||
#line 16 | ||
|
||
use vars qw{$VERSION $ISCORE @ISA}; | ||
BEGIN { | ||
$VERSION = '0.002'; | ||
$ISCORE = 1; | ||
@ISA = qw{Module::Install::Base}; | ||
} | ||
|
||
#line 42 | ||
|
||
sub author_tests { | ||
my ($self, @dirs) = @_; | ||
_add_author_tests($self, \@dirs, 0); | ||
} | ||
|
||
#line 56 | ||
|
||
sub recursive_author_tests { | ||
my ($self, @dirs) = @_; | ||
_add_author_tests($self, \@dirs, 1); | ||
} | ||
|
||
sub _wanted { | ||
my $href = shift; | ||
sub { /\.t$/ and -f $_ and $href->{$File::Find::dir} = 1 } | ||
} | ||
|
||
sub _add_author_tests { | ||
my ($self, $dirs, $recurse) = @_; | ||
return unless $Module::Install::AUTHOR; | ||
|
||
my @tests = $self->tests ? (split / /, $self->tests) : 't/*.t'; | ||
|
||
# XXX: pick a default, later -- rjbs, 2008-02-24 | ||
my @dirs = @$dirs ? @$dirs : Carp::confess "no dirs given to author_tests"; | ||
@dirs = grep { -d } @dirs; | ||
|
||
if ($recurse) { | ||
require File::Find; | ||
my %test_dir; | ||
File::Find::find(_wanted(\%test_dir), @dirs); | ||
$self->tests( join ' ', @tests, map { "$_/*.t" } sort keys %test_dir ); | ||
} else { | ||
$self->tests( join ' ', @tests, map { "$_/*.t" } sort @dirs ); | ||
} | ||
} | ||
|
||
#line 107 | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
#line 1 | ||
package Module::Install::Base; | ||
|
||
use strict 'vars'; | ||
use vars qw{$VERSION}; | ||
BEGIN { | ||
$VERSION = '1.00'; | ||
} | ||
|
||
# Suspend handler for "redefined" warnings | ||
BEGIN { | ||
my $w = $SIG{__WARN__}; | ||
$SIG{__WARN__} = sub { $w }; | ||
} | ||
|
||
#line 42 | ||
|
||
sub new { | ||
my $class = shift; | ||
unless ( defined &{"${class}::call"} ) { | ||
*{"${class}::call"} = sub { shift->_top->call(@_) }; | ||
} | ||
unless ( defined &{"${class}::load"} ) { | ||
*{"${class}::load"} = sub { shift->_top->load(@_) }; | ||
} | ||
bless { @_ }, $class; | ||
} | ||
|
||
#line 61 | ||
|
||
sub AUTOLOAD { | ||
local $@; | ||
my $func = eval { shift->_top->autoload } or return; | ||
goto &$func; | ||
} | ||
|
||
#line 75 | ||
|
||
sub _top { | ||
$_[0]->{_top}; | ||
} | ||
|
||
#line 90 | ||
|
||
sub admin { | ||
$_[0]->_top->{admin} | ||
or | ||
Module::Install::Base::FakeAdmin->new; | ||
} | ||
|
||
#line 106 | ||
|
||
sub is_admin { | ||
! $_[0]->admin->isa('Module::Install::Base::FakeAdmin'); | ||
} | ||
|
||
sub DESTROY {} | ||
|
||
package Module::Install::Base::FakeAdmin; | ||
|
||
use vars qw{$VERSION}; | ||
BEGIN { | ||
$VERSION = $Module::Install::Base::VERSION; | ||
} | ||
|
||
my $fake; | ||
|
||
sub new { | ||
$fake ||= bless(\@_, $_[0]); | ||
} | ||
|
||
sub AUTOLOAD {} | ||
|
||
sub DESTROY {} | ||
|
||
# Restore warning handler | ||
BEGIN { | ||
$SIG{__WARN__} = $SIG{__WARN__}->(); | ||
} | ||
|
||
1; | ||
|
||
#line 159 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#line 1 | ||
package Module::Install::Can; | ||
|
||
use strict; | ||
use Config (); | ||
use File::Spec (); | ||
use ExtUtils::MakeMaker (); | ||
use Module::Install::Base (); | ||
|
||
use vars qw{$VERSION @ISA $ISCORE}; | ||
BEGIN { | ||
$VERSION = '1.00'; | ||
@ISA = 'Module::Install::Base'; | ||
$ISCORE = 1; | ||
} | ||
|
||
# check if we can load some module | ||
### Upgrade this to not have to load the module if possible | ||
sub can_use { | ||
my ($self, $mod, $ver) = @_; | ||
$mod =~ s{::|\\}{/}g; | ||
$mod .= '.pm' unless $mod =~ /\.pm$/i; | ||
|
||
my $pkg = $mod; | ||
$pkg =~ s{/}{::}g; | ||
$pkg =~ s{\.pm$}{}i; | ||
|
||
local $@; | ||
eval { require $mod; $pkg->VERSION($ver || 0); 1 }; | ||
} | ||
|
||
# check if we can run some command | ||
sub can_run { | ||
my ($self, $cmd) = @_; | ||
|
||
my $_cmd = $cmd; | ||
return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd)); | ||
|
||
for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') { | ||
next if $dir eq ''; | ||
my $abs = File::Spec->catfile($dir, $_[1]); | ||
return $abs if (-x $abs or $abs = MM->maybe_command($abs)); | ||
} | ||
|
||
return; | ||
} | ||
|
||
# can we locate a (the) C compiler | ||
sub can_cc { | ||
my $self = shift; | ||
my @chunks = split(/ /, $Config::Config{cc}) or return; | ||
|
||
# $Config{cc} may contain args; try to find out the program part | ||
while (@chunks) { | ||
return $self->can_run("@chunks") || (pop(@chunks), next); | ||
} | ||
|
||
return; | ||
} | ||
|
||
# Fix Cygwin bug on maybe_command(); | ||
if ( $^O eq 'cygwin' ) { | ||
require ExtUtils::MM_Cygwin; | ||
require ExtUtils::MM_Win32; | ||
if ( ! defined(&ExtUtils::MM_Cygwin::maybe_command) ) { | ||
*ExtUtils::MM_Cygwin::maybe_command = sub { | ||
my ($self, $file) = @_; | ||
if ($file =~ m{^/cygdrive/}i and ExtUtils::MM_Win32->can('maybe_command')) { | ||
ExtUtils::MM_Win32->maybe_command($file); | ||
} else { | ||
ExtUtils::MM_Unix->maybe_command($file); | ||
} | ||
} | ||
} | ||
} | ||
|
||
1; | ||
|
||
__END__ | ||
#line 156 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#line 1 | ||
package Module::Install::Fetch; | ||
|
||
use strict; | ||
use Module::Install::Base (); | ||
|
||
use vars qw{$VERSION @ISA $ISCORE}; | ||
BEGIN { | ||
$VERSION = '1.00'; | ||
@ISA = 'Module::Install::Base'; | ||
$ISCORE = 1; | ||
} | ||
|
||
sub get_file { | ||
my ($self, %args) = @_; | ||
my ($scheme, $host, $path, $file) = | ||
$args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; | ||
|
||
if ( $scheme eq 'http' and ! eval { require LWP::Simple; 1 } ) { | ||
$args{url} = $args{ftp_url} | ||
or (warn("LWP support unavailable!\n"), return); | ||
($scheme, $host, $path, $file) = | ||
$args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return; | ||
} | ||
|
||
$|++; | ||
print "Fetching '$file' from $host... "; | ||
|
||
unless (eval { require Socket; Socket::inet_aton($host) }) { | ||
warn "'$host' resolve failed!\n"; | ||
return; | ||
} | ||
|
||
return unless $scheme eq 'ftp' or $scheme eq 'http'; | ||
|
||
require Cwd; | ||
my $dir = Cwd::getcwd(); | ||
chdir $args{local_dir} or return if exists $args{local_dir}; | ||
|
||
if (eval { require LWP::Simple; 1 }) { | ||
LWP::Simple::mirror($args{url}, $file); | ||
} | ||
elsif (eval { require Net::FTP; 1 }) { eval { | ||
# use Net::FTP to get past firewall | ||
my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600); | ||
$ftp->login("anonymous", '[email protected]'); | ||
$ftp->cwd($path); | ||
$ftp->binary; | ||
$ftp->get($file) or (warn("$!\n"), return); | ||
$ftp->quit; | ||
} } | ||
elsif (my $ftp = $self->can_run('ftp')) { eval { | ||
# no Net::FTP, fallback to ftp.exe | ||
require FileHandle; | ||
my $fh = FileHandle->new; | ||
|
||
local $SIG{CHLD} = 'IGNORE'; | ||
unless ($fh->open("|$ftp -n")) { | ||
warn "Couldn't open ftp: $!\n"; | ||
chdir $dir; return; | ||
} | ||
|
||
my @dialog = split(/\n/, <<"END_FTP"); | ||
open $host | ||
user anonymous anonymous\@example.com | ||
cd $path | ||
binary | ||
get $file $file | ||
quit | ||
END_FTP | ||
foreach (@dialog) { $fh->print("$_\n") } | ||
$fh->close; | ||
} } | ||
else { | ||
warn "No working 'ftp' program available!\n"; | ||
chdir $dir; return; | ||
} | ||
|
||
unless (-f $file) { | ||
warn "Fetching failed: $@\n"; | ||
chdir $dir; return; | ||
} | ||
|
||
return if exists $args{size} and -s $file != $args{size}; | ||
system($args{run}) if exists $args{run}; | ||
unlink($file) if $args{remove}; | ||
|
||
print(((!exists $args{check_for} or -e $args{check_for}) | ||
? "done!" : "failed! ($!)"), "\n"); | ||
chdir $dir; return !$?; | ||
} | ||
|
||
1; |
Oops, something went wrong.