summaryrefslogtreecommitdiff
path: root/setup-deps.pl
diff options
context:
space:
mode:
Diffstat (limited to 'setup-deps.pl')
-rwxr-xr-xsetup-deps.pl38
1 files changed, 31 insertions, 7 deletions
diff --git a/setup-deps.pl b/setup-deps.pl
index 813cfb0..3fa2d06 100755
--- a/setup-deps.pl
+++ b/setup-deps.pl
@@ -5,9 +5,35 @@ use CPAN;
use CPAN::HandleConfig;
use CPAN::Shell;
+my $already_configured_cpan = 0;
my $root;
BEGIN {
+ sub CheckAvailability
+ {
+ my $code = "require $_[0]";
+ if (@_ > 1) {
+ $code .= "; $_[1]";
+ }
+ eval $code;
+ if ($@) {
+ if ($already_configured_cpan) {
+ print STDERR "Missing $_[0]; CPAN already initialized.\n";
+ } else {
+ print STDERR "Missing $_[0]; initializing CPAN.\n";
+ CPAN::HandleConfig->load(autoconfig => 1, auto_pick => 1,
+ doit => 1);
+ CPAN::Shell::setup_output;
+ CPAN::Index->reload;
+ $already_configured_cpan = 1;
+ }
+ return 0;
+ } else {
+ print STDERR "Found $_[0].\n";
+ return 1;
+ }
+ }
+
alarm(3600);
$root = $INC[0];
@@ -25,13 +51,11 @@ BEGIN {
};
}
# $CPAN::DEBUG ||= $CPAN::DEBUG{'FTP'};
- CPAN::HandleConfig->load(autoconfig => 1, auto_pick => 1, doit => 1);
- CPAN::Shell::setup_output;
- CPAN::Index->reload;
- my $ll = CPAN::Shell->expandany('local::lib');
- if ( ( ! $ll->inst_file || $ll->inst_version =~ /^1\./)
+ if ( !CheckAvailability('local::lib',
+ 'die unless $local::lib::VERSION >= 2')
&& ! -d "$root/aux/lib/perl5/local" ) {
+ my $ll = CPAN::Shell->expandany('local::lib');
$ll->get;
system('mkdir', '-p', "$root/aux/lib/perl5/local");
system('cp', $ll->distribution->dir . "/lib/local/lib.pm",
@@ -47,10 +71,10 @@ my @lwp_deps = qw(Encode::Locale File::Listing
IO::Socket::SSL LWP::MediaTypes LWP::Protocol::https
Net::HTTP URI WWW::RobotRules Mozilla::CA);
for my $module (@lwp_deps, 'Time::HiRes') {
- if ( ! CPAN::Shell->expandany($module)->inst_file ) {
+ if ( ! CheckAvailability($module) ) {
CPAN::Shell->install($module);
}
}
-if ( ! CPAN::Shell->expandany('LWP')->inst_file ) {
+if ( ! CheckAvailability('LWP') ) {
CPAN::Shell->install('Bundle::LWP');
}