From ffb1a81f4048faa93a7896fe8d1c7bf4b793fc2a Mon Sep 17 00:00:00 2001 From: Steve Hay Date: Tue, 17 Jun 2014 14:07:35 +0100 Subject: Make Makefile.PL non-interactive when running via cpan, cpanp or cpanm --- Changes | 3 +++ Makefile.PL | 36 +++++++++++++++++++++++++++++++----- README | 13 +++++++------ 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/Changes b/Changes index 0cf63bf..64d7f7c 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ libnet 1.28 -- TODO + * Stop Makefile.PL from requiring interactive configuration when running via + cpan, cpanp or cpanm: just accept all defaults in these cases, as when + running non-interactively. [Resolves CPAN RT#48966] * Add optional POD coverage testing. * Add optional POD testing. * Add optional Perl::Critic testing. diff --git a/Makefile.PL b/Makefile.PL index b41a3c9..8bb6bb4 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -23,6 +23,8 @@ use warnings; use ExtUtils::MakeMaker 6.64; use ExtUtils::MakeMaker qw(WriteMakefile); +sub running_under_cpan(); + #=============================================================================== # INITIALIZATION #=============================================================================== @@ -42,10 +44,14 @@ MAIN: { my %prereq_pms = (); $prereq_pms{'Convert::EBCDIC'} = '0.06' if $^O eq 'os390'; - my $xt = prompt("Should I do external tests?\n" . - "These tests will fail if there is no internet connection or if a firewall\n" . - "blocks or modifies some traffic.\n" . - "[y/N]", 'n'); + my $xt = 'n'; + if (not running_under_cpan()) { + $xt = prompt("Should I do external tests?\n" . + "These tests will fail if there is no internet" . + " connection or if a firewall\n" . + "blocks or modifies some traffic.\n" . + "[y/N]", 'n'); + } my $tests = 't/*.t'; $tests .= ' t/external/*.t' if $xt =~ m/^y/io; @@ -211,10 +217,30 @@ MAIN: { sub MY::post_initialize { my $self = shift; + return '' if $self->{PERL_CORE}; - system(($^O eq 'VMS' ? 'mcr ': ()), $^X, 'Configure') unless -f $CfgFile; + + if (not -f $CfgFile) { + my @args = qw(Configure); + push @args, '-d' if $ENV{PERL5_CPAN_IS_RUNNING} || + $ENV{PERL5_CPANPLUS_IS_RUNNING} || + $ENV{PERL5_CPANM_IS_RUNNING}; + system(($^O eq 'VMS' ? 'mcr ': ()), $^X, @args) + } + $self->{PM}{$CfgFile} = $self->catfile('$(INST_LIBDIR)',$CfgPath); + return ''; } #=============================================================================== +# SUBROUTINES +#=============================================================================== + +sub running_under_cpan() { + return $ENV{PERL5_CPAN_IS_RUNNING} || # cpan + $ENV{PERL5_CPANPLUS_IS_RUNNING} || # cpanp + $ENV{PERL5_CPANM_IS_RUNNING}; # cpanm +} + +#=============================================================================== diff --git a/README b/README index 502ef70..e3183e7 100644 --- a/README +++ b/README @@ -57,20 +57,21 @@ together with libnet. These packages should be available on CPAN CONFIGURE -Normally when perl Makefile.PL is run it will run Configure which will +Normally when Makefile.PL is run it will run Configure which will ask some questions about your system. The results of these questions will be stored in a file called libnet.cfg which will be installed -alongside the other perl modules in this distribution. The Makefile.PL +alongside the other perl modules in this distribution. Makefile.PL will run Configure in an interactive mode unless these exists a file -called libnet.cfg in the build directory. +called libnet.cfg in the build directory or Makefile.PL itself is being +run non-interactively or via cpan, cpanp or cpanm. If you are on a system which cannot run this script you can create an empty file to make Makefile.PL skip running Configure. If you want to -keep your existing settings and not run interactivly the simple run +keep your existing settings and not run interactivly then simply run - Configure -d + perl Configure -d -before running the Makefile.PL. +before running Makefile.PL. DOCUMENTATION -- cgit v1.2.3-24-ge0c7