@@ -1,5 +1,9 @@
Revision history for Perl extension Server::Starter.
+0.19
+ - reimplement changes in 0.15, 0.16 for stability (#13)
+ - update inc/Module/Install
+
0.17
- add option: --backlog to change the backlog size (default: SOMAXCONN) (thanks to Yuryu)
@@ -3,11 +3,12 @@ abstract: 'a superdaemon for hot-deploying server programs'
author:
- 'Kazuho Oku'
build_requires:
- ExtUtils::MakeMaker: 6.42
+ ExtUtils::MakeMaker: 6.59
configure_requires:
- ExtUtils::MakeMaker: 6.42
+ ExtUtils::MakeMaker: 6.59
distribution_type: module
-generated_by: 'Module::Install version 1.00'
+dynamic_config: 1
+generated_by: 'Module::Install version 1.14'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -25,4 +26,4 @@ requires:
perl: 5.8.0
resources:
license: http://dev.perl.org/licenses/
-version: 0.17
+version: '0.19'
@@ -4,7 +4,7 @@
"Kazuho Oku"
],
"dynamic_config" : 0,
- "generated_by" : "Module::Install version 1.00, CPAN::Meta::Converter version 2.131560",
+ "generated_by" : "Module::Install version 1.14, CPAN::Meta::Converter version 2.120921",
"license" : [
"perl_5"
],
@@ -22,12 +22,12 @@
"prereqs" : {
"build" : {
"requires" : {
- "ExtUtils::MakeMaker" : "6.42"
+ "ExtUtils::MakeMaker" : "6.59"
}
},
"configure" : {
"requires" : {
- "ExtUtils::MakeMaker" : "6.42"
+ "ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
@@ -40,11 +40,11 @@
}
}
},
- "release_status" : "stable",
+ "release_status" : "testing",
"resources" : {
"license" : [
"http://dev.perl.org/licenses/"
]
},
- "version" : "0.16"
+ "version" : "0.18_02"
}
@@ -3,26 +3,26 @@ abstract: 'a superdaemon for hot-deploying server programs'
author:
- 'Kazuho Oku'
build_requires:
- ExtUtils::MakeMaker: 6.42
+ ExtUtils::MakeMaker: '6.59'
configure_requires:
- ExtUtils::MakeMaker: 6.42
+ ExtUtils::MakeMaker: '0'
dynamic_config: 0
-generated_by: 'Module::Install version 1.00, CPAN::Meta::Converter version 2.131560'
+generated_by: 'Module::Install version 1.14, CPAN::Meta::Converter version 2.120921'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
- version: 1.4
+ version: '1.4'
name: Server-Starter
no_index:
directory:
- inc
- t
requires:
- Getopt::Long: 0
- List::MoreUtils: 0
- Proc::Wait3: 0
- Scope::Guard: 0
- perl: 5.008
+ Getopt::Long: '0'
+ List::MoreUtils: '0'
+ Proc::Wait3: '0'
+ Scope::Guard: '0'
+ perl: '5.008'
resources:
license: http://dev.perl.org/licenses/
-version: 0.16
+version: 0.18_02
@@ -3,11 +3,12 @@ package Module::AutoInstall;
use strict;
use Cwd ();
+use File::Spec ();
use ExtUtils::MakeMaker ();
use vars qw{$VERSION};
BEGIN {
- $VERSION = '1.03';
+ $VERSION = '1.14';
}
# special map on pre-defined feature sets
@@ -17,11 +18,14 @@ my %FeatureMap = (
);
# various lexical flags
-my ( @Missing, @Existing, %DisabledTests, $UnderCPAN, $HasCPANPLUS );
+my ( @Missing, @Existing, %DisabledTests, $UnderCPAN, $InstallDepsTarget, $HasCPANPLUS );
my (
- $Config, $CheckOnly, $SkipInstall, $AcceptDefault, $TestOnly, $AllDeps
+ $Config, $CheckOnly, $SkipInstall, $AcceptDefault, $TestOnly, $AllDeps,
+ $UpgradeDeps
);
-my ( $PostambleActions, $PostambleUsed );
+my ( $PostambleActions, $PostambleActionsNoTest, $PostambleActionsUpgradeDeps,
+ $PostambleActionsUpgradeDepsNoTest, $PostambleActionsListDeps,
+ $PostambleActionsListAllDeps, $PostambleUsed, $NoTest);
# See if it's a testing or non-interactive session
_accept_default( $ENV{AUTOMATED_TESTING} or ! -t STDIN );
@@ -31,6 +35,10 @@ sub _accept_default {
$AcceptDefault = shift;
}
+sub _installdeps_target {
+ $InstallDepsTarget = shift;
+}
+
sub missing_modules {
return @Missing;
}
@@ -63,6 +71,11 @@ sub _init {
__PACKAGE__->install( $Config, @Missing = split( /,/, $1 ) );
exit 0;
}
+ elsif ( $arg =~ /^--upgradedeps=(.*)$/ ) {
+ $UpgradeDeps = 1;
+ __PACKAGE__->install( $Config, @Missing = split( /,/, $1 ) );
+ exit 0;
+ }
elsif ( $arg =~ /^--default(?:deps)?$/ ) {
$AcceptDefault = 1;
}
@@ -102,7 +115,7 @@ sub import {
print "*** $class version " . $class->VERSION . "\n";
print "*** Checking for Perl dependencies...\n";
- my $cwd = Cwd::cwd();
+ my $cwd = Cwd::getcwd();
$Config = [];
@@ -125,7 +138,7 @@ sub import {
# check entirely since we don't want to have to load (and configure)
# an old CPAN just for a cosmetic message
- $UnderCPAN = _check_lock(1) unless $SkipInstall;
+ $UnderCPAN = _check_lock(1) unless $SkipInstall || $InstallDepsTarget;
while ( my ( $feature, $modules ) = splice( @args, 0, 2 ) ) {
my ( @required, @tests, @skiptests );
@@ -153,7 +166,7 @@ sub import {
$modules = [ %{$modules} ] if UNIVERSAL::isa( $modules, 'HASH' );
unshift @$modules, -default => &{ shift(@$modules) }
- if ( ref( $modules->[0] ) eq 'CODE' ); # XXX: bugward combatability
+ if ( ref( $modules->[0] ) eq 'CODE' ); # XXX: bugward compatibility
while ( my ( $mod, $arg ) = splice( @$modules, 0, 2 ) ) {
if ( $mod =~ m/^-(\w+)$/ ) {
@@ -175,7 +188,7 @@ sub import {
}
# XXX: check for conflicts and uninstalls(!) them.
- my $cur = _load($mod);
+ my $cur = _version_of($mod);
if (_version_cmp ($cur, $arg) >= 0)
{
print "loaded. ($cur" . ( $arg ? " >= $arg" : '' ) . ")\n";
@@ -207,6 +220,7 @@ sub import {
$CheckOnly
or ($mandatory and $UnderCPAN)
or $AllDeps
+ or $InstallDepsTarget
or _prompt(
qq{==> Auto-install the }
. ( @required / 2 )
@@ -237,10 +251,17 @@ sub import {
}
}
- if ( @Missing and not( $CheckOnly or $UnderCPAN ) ) {
+ if ( @Missing and not( $CheckOnly or $UnderCPAN) ) {
require Config;
- print
-"*** Dependencies will be installed the next time you type '$Config::Config{make}'.\n";
+ my $make = $Config::Config{make};
+ if ($InstallDepsTarget) {
+ print
+"*** To install dependencies type '$make installdeps' or '$make installdeps_notest'.\n";
+ }
+ else {
+ print
+"*** Dependencies will be installed the next time you type '$make'.\n";
+ }
# make an educated guess of whether we'll need root permission.
print " (You may need to do that as the 'root' user.)\n"
@@ -271,6 +292,10 @@ END_MESSAGE
sub _check_lock {
return unless @Missing or @_;
+ if ($ENV{PERL5_CPANM_IS_RUNNING}) {
+ return _running_under('cpanminus');
+ }
+
my $cpan_env = $ENV{PERL5_CPAN_IS_RUNNING};
if ($ENV{PERL5_CPANPLUS_IS_RUNNING}) {
@@ -320,17 +345,26 @@ sub install {
my $i; # used below to strip leading '-' from config keys
my @config = ( map { s/^-// if ++$i; $_ } @{ +shift } );
- my ( @modules, @installed );
- while ( my ( $pkg, $ver ) = splice( @_, 0, 2 ) ) {
+ my ( @modules, @installed, @modules_to_upgrade );
+ while (my ($pkg, $ver) = splice(@_, 0, 2)) {
- # grep out those already installed
- if ( _version_cmp( _load($pkg), $ver ) >= 0 ) {
- push @installed, $pkg;
- }
- else {
- push @modules, $pkg, $ver;
- }
- }
+ # grep out those already installed
+ if (_version_cmp(_version_of($pkg), $ver) >= 0) {
+ push @installed, $pkg;
+ if ($UpgradeDeps) {
+ push @modules_to_upgrade, $pkg, $ver;
+ }
+ }
+ else {
+ push @modules, $pkg, $ver;
+ }
+ }
+
+ if ($UpgradeDeps) {
+ push @modules, @modules_to_upgrade;
+ @installed = ();
+ @modules_to_upgrade = ();
+ }
return @installed unless @modules; # nothing to do
return @installed if _check_lock(); # defer to the CPAN shell
@@ -363,7 +397,7 @@ sub install {
# see if we have successfully installed them
while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) {
- if ( _version_cmp( _load($pkg), $ver ) >= 0 ) {
+ if ( _version_cmp( _version_of($pkg), $ver ) >= 0 ) {
push @installed, $pkg;
}
elsif ( $args{do_once} and open( FAILED, '>> .#autoinstall.failed' ) ) {
@@ -463,6 +497,11 @@ sub _cpanplus_config {
} else {
die "*** Cannot convert option $key = '$value' to CPANPLUS version.\n";
}
+ push @config, 'prereqs', $value;
+ } elsif ( $key eq 'force' ) {
+ push @config, $key, $value;
+ } elsif ( $key eq 'notest' ) {
+ push @config, 'skiptest', $value;
} else {
die "*** Cannot convert option $key to CPANPLUS version.\n";
}
@@ -497,10 +536,14 @@ sub _install_cpan {
# set additional options
while ( my ( $opt, $arg ) = splice( @config, 0, 2 ) ) {
( $args{$opt} = $arg, next )
- if $opt =~ /^force$/; # pseudo-option
+ if $opt =~ /^(?:force|notest)$/; # pseudo-option
$CPAN::Config->{$opt} = $arg;
}
+ if ($args{notest} && (not CPAN::Shell->can('notest'))) {
+ die "Your version of CPAN is too old to support the 'notest' pragma";
+ }
+
local $CPAN::Config->{prerequisites_policy} = 'follow';
while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) {
@@ -519,8 +562,16 @@ sub _install_cpan {
delete $INC{$inc};
}
- my $rv = $args{force} ? CPAN::Shell->force( install => $pkg )
- : CPAN::Shell->install($pkg);
+ my $rv = do {
+ if ($args{force}) {
+ CPAN::Shell->force( install => $pkg )
+ } elsif ($args{notest}) {
+ CPAN::Shell->notest( install => $pkg )
+ } else {
+ CPAN::Shell->install($pkg)
+ }
+ };
+
$rv ||= eval {
$CPAN::META->instance( 'CPAN::Distribution', $obj->cpan_file, )
->{install}
@@ -564,7 +615,7 @@ sub _under_cpan {
require Cwd;
require File::Spec;
- my $cwd = File::Spec->canonpath( Cwd::cwd() );
+ my $cwd = File::Spec->canonpath( Cwd::getcwd() );
my $cpan = File::Spec->canonpath( $CPAN::Config->{cpan_home} );
return ( index( $cwd, $cpan ) > -1 );
@@ -575,7 +626,7 @@ sub _update_to {
my $ver = shift;
return
- if _version_cmp( _load($class), $ver ) >= 0; # no need to upgrade
+ if _version_cmp( _version_of($class), $ver ) >= 0; # no need to upgrade
if (
_prompt( "==> A newer version of $class ($ver) is required. Install?",
@@ -660,16 +711,30 @@ sub _can_write {
# load a module and return the version it reports
sub _load {
- my $mod = pop; # class/instance doesn't matter
+ my $mod = pop; # method/function doesn't matter
my $file = $mod;
-
$file =~ s|::|/|g;
$file .= '.pm';
-
local $@;
return eval { require $file; $mod->VERSION } || ( $@ ? undef: 0 );
}
+# report version without loading a module
+sub _version_of {
+ my $mod = pop; # method/function doesn't matter
+ my $file = $mod;
+ $file =~ s|::|/|g;
+ $file .= '.pm';
+ foreach my $dir ( @INC ) {
+ next if ref $dir;
+ my $path = File::Spec->catfile($dir, $file);
+ next unless -e $path;
+ require ExtUtils::MM_Unix;
+ return ExtUtils::MM_Unix->parse_version($path);
+ }
+ return undef;
+}
+
# Load CPAN.pm and it's configuration
sub _load_cpan {
return if $CPAN::VERSION and $CPAN::Config and not @_;
@@ -763,6 +828,35 @@ sub _make_args {
: "\$(NOECHO) \$(NOOP)"
);
+ my $deps_list = join( ',', @Missing, @Existing );
+
+ $PostambleActionsUpgradeDeps =
+ "\$(PERL) $0 --config=$config --upgradedeps=$deps_list";
+
+ my $config_notest =
+ join( ',', (UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config}),
+ 'notest', 1 )
+ if $Config;
+
+ $PostambleActionsNoTest = (
+ ($missing and not $UnderCPAN)
+ ? "\$(PERL) $0 --config=$config_notest --installdeps=$missing"
+ : "\$(NOECHO) \$(NOOP)"
+ );
+
+ $PostambleActionsUpgradeDepsNoTest =
+ "\$(PERL) $0 --config=$config_notest --upgradedeps=$deps_list";
+
+ $PostambleActionsListDeps =
+ '@$(PERL) -le "print for @ARGV" '
+ . join(' ', map $Missing[$_], grep $_ % 2 == 0, 0..$#Missing);
+
+ my @all = (@Missing, @Existing);
+
+ $PostambleActionsListAllDeps =
+ '@$(PERL) -le "print for @ARGV" '
+ . join(' ', map $all[$_], grep $_ % 2 == 0, 0..$#all);
+
return %args;
}
@@ -797,11 +891,15 @@ sub Write {
sub postamble {
$PostambleUsed = 1;
+ my $fragment;
- return <<"END_MAKE";
+ $fragment .= <<"AUTO_INSTALL" if !$InstallDepsTarget;
config :: installdeps
\t\$(NOECHO) \$(NOOP)
+AUTO_INSTALL
+
+ $fragment .= <<"END_MAKE";
checkdeps ::
\t\$(PERL) $0 --checkdeps
@@ -809,12 +907,28 @@ checkdeps ::
installdeps ::
\t$PostambleActions
+installdeps_notest ::
+\t$PostambleActionsNoTest
+
+upgradedeps ::
+\t$PostambleActionsUpgradeDeps
+
+upgradedeps_notest ::
+\t$PostambleActionsUpgradeDepsNoTest
+
+listdeps ::
+\t$PostambleActionsListDeps
+
+listalldeps ::
+\t$PostambleActionsListAllDeps
+
END_MAKE
+ return $fragment;
}
1;
__END__
-#line 1071
+#line 1197
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.00';
+ $VERSION = '1.14';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -73,6 +73,17 @@ sub auto_install {
);
}
+sub installdeps_target {
+ my ($self, @args) = @_;
+
+ $self->include('Module::AutoInstall');
+ require Module::AutoInstall;
+
+ Module::AutoInstall::_installdeps_target(1);
+
+ $self->auto_install(@args);
+}
+
sub auto_install_now {
my $self = shift;
$self->auto_install(@_);
@@ -4,7 +4,7 @@ package Module::Install::Base;
use strict 'vars';
use vars qw{$VERSION};
BEGIN {
- $VERSION = '1.00';
+ $VERSION = '1.14';
}
# Suspend handler for "redefined" warnings
@@ -3,13 +3,12 @@ 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';
+ $VERSION = '1.14';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -29,7 +28,7 @@ sub can_use {
eval { require $mod; $pkg->VERSION($ver || 0); 1 };
}
-# check if we can run some command
+# Check if we can run some command
sub can_run {
my ($self, $cmd) = @_;
@@ -38,14 +37,88 @@ sub can_run {
for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
next if $dir eq '';
- my $abs = File::Spec->catfile($dir, $_[1]);
+ require File::Spec;
+ my $abs = File::Spec->catfile($dir, $cmd);
return $abs if (-x $abs or $abs = MM->maybe_command($abs));
}
return;
}
-# can we locate a (the) C compiler
+# Can our C compiler environment build XS files
+sub can_xs {
+ my $self = shift;
+
+ # Ensure we have the CBuilder module
+ $self->configure_requires( 'ExtUtils::CBuilder' => 0.27 );
+
+ # Do we have the configure_requires checker?
+ local $@;
+ eval "require ExtUtils::CBuilder;";
+ if ( $@ ) {
+ # They don't obey configure_requires, so it is
+ # someone old and delicate. Try to avoid hurting
+ # them by falling back to an older simpler test.
+ return $self->can_cc();
+ }
+
+ # Do we have a working C compiler
+ my $builder = ExtUtils::CBuilder->new(
+ quiet => 1,
+ );
+ unless ( $builder->have_compiler ) {
+ # No working C compiler
+ return 0;
+ }
+
+ # Write a C file representative of what XS becomes
+ require File::Temp;
+ my ( $FH, $tmpfile ) = File::Temp::tempfile(
+ "compilexs-XXXXX",
+ SUFFIX => '.c',
+ );
+ binmode $FH;
+ print $FH <<'END_C';
+#include "EXTERN.h"
+#include "perl.h"
+#include "XSUB.h"
+
+int main(int argc, char **argv) {
+ return 0;
+}
+
+int boot_sanexs() {
+ return 1;
+}
+
+END_C
+ close $FH;
+
+ # Can the C compiler access the same headers XS does
+ my @libs = ();
+ my $object = undef;
+ eval {
+ local $^W = 0;
+ $object = $builder->compile(
+ source => $tmpfile,
+ );
+ @libs = $builder->link(
+ objects => $object,
+ module_name => 'sanexs',
+ );
+ };
+ my $result = $@ ? 0 : 1;
+
+ # Clean up all the build files
+ foreach ( $tmpfile, $object, @libs ) {
+ next unless defined $_;
+ 1 while unlink;
+ }
+
+ return $result;
+}
+
+# Can we locate a (the) C compiler
sub can_cc {
my $self = shift;
my @chunks = split(/ /, $Config::Config{cc}) or return;
@@ -78,4 +151,4 @@ if ( $^O eq 'cygwin' ) {
__END__
-#line 156
+#line 236
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.00';
+ $VERSION = '1.14';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.00';
+ $VERSION = '1.14';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -8,7 +8,7 @@ use Fcntl qw/:flock :seek/;
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.00';
+ $VERSION = '1.14';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -133,7 +133,7 @@ sub makemaker_args {
return $args;
}
-# For mm args that take multiple space-seperated args,
+# For mm args that take multiple space-separated args,
# append an argument to the current list.
sub makemaker_append {
my $self = shift;
@@ -215,18 +215,22 @@ sub write {
require ExtUtils::MakeMaker;
if ( $perl_version and $self->_cmp($perl_version, '5.006') >= 0 ) {
- # MakeMaker can complain about module versions that include
- # an underscore, even though its own version may contain one!
- # Hence the funny regexp to get rid of it. See RT #35800
- # for details.
- my $v = $ExtUtils::MakeMaker::VERSION =~ /^(\d+\.\d+)/;
- $self->build_requires( 'ExtUtils::MakeMaker' => $v );
- $self->configure_requires( 'ExtUtils::MakeMaker' => $v );
+ # This previous attempted to inherit the version of
+ # ExtUtils::MakeMaker in use by the module author, but this
+ # was found to be untenable as some authors build releases
+ # using future dev versions of EU:MM that nobody else has.
+ # Instead, #toolchain suggests we use 6.59 which is the most
+ # stable version on CPAN at time of writing and is, to quote
+ # ribasushi, "not terminally fucked, > and tested enough".
+ # TODO: We will now need to maintain this over time to push
+ # the version up as new versions are released.
+ $self->build_requires( 'ExtUtils::MakeMaker' => 6.59 );
+ $self->configure_requires( 'ExtUtils::MakeMaker' => 6.59 );
} else {
# Allow legacy-compatibility with 5.005 by depending on the
# most recent EU:MM that supported 5.005.
- $self->build_requires( 'ExtUtils::MakeMaker' => 6.42 );
- $self->configure_requires( 'ExtUtils::MakeMaker' => 6.42 );
+ $self->build_requires( 'ExtUtils::MakeMaker' => 6.36 );
+ $self->configure_requires( 'ExtUtils::MakeMaker' => 6.36 );
}
# Generate the MakeMaker params
@@ -241,7 +245,6 @@ in a module, and provide its file path via 'version_from' (or
'all_from' if you prefer) in Makefile.PL.
EOT
- $DB::single = 1;
if ( $self->tests ) {
my @tests = split ' ', $self->tests;
my %seen;
@@ -412,4 +415,4 @@ sub postamble {
__END__
-#line 541
+#line 544
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.00';
+ $VERSION = '1.14';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -151,15 +151,21 @@ sub install_as_site { $_[0]->installdirs('site') }
sub install_as_vendor { $_[0]->installdirs('vendor') }
sub dynamic_config {
- my $self = shift;
- unless ( @_ ) {
- warn "You MUST provide an explicit true/false value to dynamic_config\n";
- return $self;
+ my $self = shift;
+ my $value = @_ ? shift : 1;
+ if ( $self->{values}->{dynamic_config} ) {
+ # Once dynamic we never change to static, for safety
+ return 0;
}
- $self->{values}->{dynamic_config} = $_[0] ? 1 : 0;
+ $self->{values}->{dynamic_config} = $value ? 1 : 0;
return 1;
}
+# Convenience command
+sub static_config {
+ shift->dynamic_config(0);
+}
+
sub perl_version {
my $self = shift;
return $self->{values}->{perl_version} unless @_;
@@ -170,7 +176,7 @@ sub perl_version {
# Normalize the version
$version = $self->_perl_version($version);
- # We don't support the reall old versions
+ # We don't support the really old versions
unless ( $version >= 5.005 ) {
die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n";
}
@@ -341,7 +347,7 @@ sub name_from {
^ \s*
package \s*
([\w:]+)
- \s* ;
+ [\s|;]*
/ixms
) {
my ($name, $module_name) = ($1, $1);
@@ -515,6 +521,7 @@ sub __extract_license {
'GNU Free Documentation license' => 'unrestricted', 1,
'GNU Affero General Public License' => 'open_source', 1,
'(?:Free)?BSD license' => 'bsd', 1,
+ 'Artistic license 2\.0' => 'artistic_2', 1,
'Artistic license' => 'artistic', 1,
'Apache (?:Software )?license' => 'apache', 1,
'GPL' => 'gpl', 1,
@@ -550,9 +557,9 @@ sub license_from {
sub _extract_bugtracker {
my @links = $_[0] =~ m#L<(
- \Qhttp://rt.cpan.org/\E[^>]+|
- \Qhttp://github.com/\E[\w_]+/[\w_]+/issues|
- \Qhttp://code.google.com/p/\E[\w_\-]+/issues/list
+ https?\Q://rt.cpan.org/\E[^>]+|
+ https?\Q://github.com/\E[\w_]+/[\w_]+/issues|
+ https?\Q://code.google.com/p/\E[\w_\-]+/issues/list
)>#gx;
my %links;
@links{@links}=();
@@ -581,7 +588,7 @@ sub bugtracker_from {
sub requires_from {
my $self = shift;
my $content = Module::Install::_readperl($_[0]);
- my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg;
+ my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+(v?[\d\.]+)/mg;
while ( @requires ) {
my $module = shift @requires;
my $version = shift @requires;
@@ -698,7 +705,7 @@ sub _write_mymeta_data {
my @yaml = Parse::CPAN::Meta::LoadFile('META.yml');
my $meta = $yaml[0];
- # Overwrite the non-configure dependency hashs
+ # Overwrite the non-configure dependency hashes
delete $meta->{requires};
delete $meta->{build_requires};
delete $meta->{recommends};
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.00';
+ $VERSION = '1.14';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.00';
+ $VERSION = '1.14';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.00';
+ $VERSION = '1.14';
@ISA = qw{Module::Install::Base};
$ISCORE = 1;
}
@@ -17,7 +17,7 @@ package Module::Install;
# 3. The ./inc/ version of Module::Install loads
# }
-use 5.005;
+use 5.006;
use strict 'vars';
use Cwd ();
use File::Find ();
@@ -31,7 +31,7 @@ BEGIN {
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
- $VERSION = '1.00';
+ $VERSION = '1.14';
# Storage for the pseudo-singleton
$MAIN = undef;
@@ -156,10 +156,10 @@ END_DIE
sub autoload {
my $self = shift;
my $who = $self->_caller;
- my $cwd = Cwd::cwd();
+ my $cwd = Cwd::getcwd();
my $sym = "${who}::AUTOLOAD";
$sym->{$cwd} = sub {
- my $pwd = Cwd::cwd();
+ my $pwd = Cwd::getcwd();
if ( my $code = $sym->{$pwd} ) {
# Delegate back to parent dirs
goto &$code unless $cwd eq $pwd;
@@ -239,7 +239,7 @@ sub new {
# ignore the prefix on extension modules built from top level.
my $base_path = Cwd::abs_path($FindBin::Bin);
- unless ( Cwd::abs_path(Cwd::cwd()) eq $base_path ) {
+ unless ( Cwd::abs_path(Cwd::getcwd()) eq $base_path ) {
delete $args{prefix};
}
return $args{_self} if $args{_self};
@@ -338,7 +338,7 @@ sub find_extensions {
if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) {
my $content = Module::Install::_read($subpath . '.pm');
my $in_pod = 0;
- foreach ( split //, $content ) {
+ foreach ( split /\n/, $content ) {
$in_pod = 1 if /^=\w/;
$in_pod = 0 if /^=cut/;
next if ($in_pod || /^=cut/); # skip pod text
@@ -378,6 +378,7 @@ eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@;
sub _read {
local *FH;
open( FH, '<', $_[0] ) or die "open($_[0]): $!";
+ binmode FH;
my $string = do { local $/; <FH> };
close FH or die "close($_[0]): $!";
return $string;
@@ -386,6 +387,7 @@ END_NEW
sub _read {
local *FH;
open( FH, "< $_[0]" ) or die "open($_[0]): $!";
+ binmode FH;
my $string = do { local $/; <FH> };
close FH or die "close($_[0]): $!";
return $string;
@@ -416,6 +418,7 @@ eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@;
sub _write {
local *FH;
open( FH, '>', $_[0] ) or die "open($_[0]): $!";
+ binmode FH;
foreach ( 1 .. $#_ ) {
print FH $_[$_] or die "print($_[0]): $!";
}
@@ -425,6 +428,7 @@ END_NEW
sub _write {
local *FH;
open( FH, "> $_[0]" ) or die "open($_[0]): $!";
+ binmode FH;
foreach ( 1 .. $#_ ) {
print FH $_[$_] or die "print($_[0]): $!";
}
@@ -434,7 +438,7 @@ END_OLD
# _version is for processing module versions (eg, 1.03_05) not
# Perl versions (eg, 5.8.1).
-sub _version ($) {
+sub _version {
my $s = shift || 0;
my $d =()= $s =~ /(\.)/g;
if ( $d >= 2 ) {
@@ -450,12 +454,12 @@ sub _version ($) {
return $l + 0;
}
-sub _cmp ($$) {
- _version($_[0]) <=> _version($_[1]);
+sub _cmp {
+ _version($_[1]) <=> _version($_[2]);
}
# Cloned from Params::Util::_CLASS
-sub _CLASS ($) {
+sub _CLASS {
(
defined $_[0]
and
@@ -467,4 +471,4 @@ sub _CLASS ($) {
1;
-# Copyright 2008 - 2010 Adam Kennedy.
+# Copyright 2008 - 2012 Adam Kennedy.
@@ -3,7 +3,7 @@ package Test::TCP;
use strict;
use warnings;
use 5.00800;
-our $VERSION = '2.00';
+our $VERSION = '2.06';
use base qw/Exporter/;
use IO::Socket::INET;
use Test::SharedFork 0.12;
@@ -77,21 +77,20 @@ sub port { $_[0]->{port} }
sub start {
my $self = shift;
- if ( my $pid = fork() ) {
- # parent.
+ my $pid = fork();
+ die "fork() failed: $!" unless defined $pid;
+
+ if ( $pid ) { # parent process.
$self->{pid} = $pid;
Test::TCP::wait_port($self->port, $self->{max_wait});
return;
- } elsif ($pid == 0) {
- # child process
+ } else { # child process
$self->{code}->($self->port);
# should not reach here
if (kill 0, $self->{_my_pid}) { # warn only parent process still exists
warn("[Test::TCP] Child process does not block(PID: $$, PPID: $self->{_my_pid})");
}
exit 0;
- } else {
- die "fork failed: $!";
}
}
@@ -144,4 +143,4 @@ sub DESTROY {
1;
__END__
-#line 380
+#line 379
@@ -15,7 +15,7 @@ use Scope::Guard;
use Exporter qw(import);
-our $VERSION = '0.17';
+our $VERSION = '0.19';
our @EXPORT_OK = qw(start_server restart_server server_ports);
my @signals_received;
@@ -46,7 +46,7 @@ sub start_server {
if ! ref $paths && defined $paths;
croak "mandatory option ``exec'' is missing or is not an arrayref\n"
unless $opts->{exec} && ref $opts->{exec} eq 'ARRAY';
-
+
# set envs
$ENV{ENVDIR} = $opts->{envdir}
if defined $opts->{envdir};
@@ -56,7 +56,7 @@ sub start_server {
if defined $opts->{kill_old_delay};
$ENV{AUTO_RESTART_INTERVAL} = $opts->{auto_restart_interval}
if defined $opts->{auto_restart_interval};
-
+
# open pid file
my $pid_file_guard = sub {
return unless $opts->{pid_file};
@@ -153,11 +153,11 @@ sub start_server {
# setup signal handlers
$SIG{$_} = sub {
push @signals_received, $_[0];
- } for (qw/INT TERM HUP/);
+ } for (qw/INT TERM HUP ALRM/);
$SIG{PIPE} = 'IGNORE';
# setup status monitor
- my ($current_worker, %old_workers);
+ my ($current_worker, %old_workers, $last_restart_time);
my $update_status = $opts->{status_file}
? sub {
my $tmpfn = "$opts->{status_file}.$$";
@@ -176,103 +176,144 @@ sub start_server {
or die "failed to rename $tmpfn to $opts->{status_file}:$!";
} : sub {
};
-
+
+ # setup the start_worker function
+ my $start_worker = sub {
+ my $pid;
+ while (1) {
+ $ENV{SERVER_STARTER_GENERATION}++;
+ $pid = fork;
+ die "fork(2) failed:$!"
+ unless defined $pid;
+ if ($pid == 0) {
+ my @args = @{$opts->{exec}};
+ # child process
+ if (defined $opts->{dir}) {
+ chdir $opts->{dir} or die "failed to chdir:$!";
+ }
+ { exec { $args[0] } @args };
+ print STDERR "failed to exec $args[0]$!";
+ exit(255);
+ }
+ print STDERR "starting new worker $pid\n";
+ sleep $opts->{interval};
+ if ((grep { $_ ne 'HUP' } @signals_received)
+ || waitpid($pid, WNOHANG) <= 0) {
+ last;
+ }
+ print STDERR "new worker $pid seems to have failed to start, exit status:$?\n";
+ }
+ # ready, update the environment
+ $current_worker = $pid;
+ $last_restart_time = time;
+ $update_status->();
+ };
+
+ # setup the wait function
+ my $wait = sub {
+ my $block = @signals_received == 0;
+ my @r;
+ if ($block && $ENV{ENABLE_AUTO_RESTART}) {
+ alarm(1);
+ @r = wait3($block);
+ alarm(0);
+ } else {
+ @r = wait3($block);
+ }
+ return @r;
+ };
+
+ # setup the cleanup function
+ my $cleanup = sub {
+ my $sig = shift;
+ my $term_signal = $sig eq 'TERM' ? $opts->{signal_on_term} : 'TERM';
+ $old_workers{$current_worker} = $ENV{SERVER_STARTER_GENERATION};
+ undef $current_worker;
+ print STDERR "received $sig, sending $term_signal to all workers:",
+ join(',', sort keys %old_workers), "\n";
+ kill $term_signal, $_
+ for sort keys %old_workers;
+ while (%old_workers) {
+ if (my @r = wait3(1)) {
+ my ($died_worker, $status) = @r;
+ print STDERR "worker $died_worker died, status:$status\n";
+ delete $old_workers{$died_worker};
+ $update_status->();
+ }
+ }
+ print STDERR "exiting\n";
+ };
+
# the main loop
- my $term_signal = 0;
- $current_worker = _start_worker($opts);
- $update_status->();
- my $auto_restart_interval = 0;
- my $last_restart_time = time();
- my $restart_flag = 0;
+ $start_worker->();
while (1) {
+ # wait for next signal (or when auto-restart becomes necessary)
+ my @r = $wait->();
+ # reload env if necessary
my %loaded_env = _reload_env();
my @loaded_env_keys = keys %loaded_env;
local @ENV{@loaded_env_keys} = map { $loaded_env{$_} } (@loaded_env_keys);
- if ($ENV{ENABLE_AUTO_RESTART}) {
- # restart workers periodically
- $auto_restart_interval = $ENV{AUTO_RESTART_INTERVAL} ||= 360;
- }
- sleep(1);
- my $died_worker = -1;
- my $status = -1;
- while (1) {
- $died_worker = waitpid(-1, WNOHANG);
- $status = $?;
- last if ($died_worker <= 0);
+ $ENV{AUTO_RESTART_INTERVAL} ||= 360
+ if $ENV{ENABLE_AUTO_RESTART};
+ # restart if worker died
+ if (@r) {
+ my ($died_worker, $status) = @r;
if ($died_worker == $current_worker) {
print STDERR "worker $died_worker died unexpectedly with status:$status, restarting\n";
- $current_worker = _start_worker($opts);
- $last_restart_time = time();
+ $start_worker->();
} else {
print STDERR "old worker $died_worker died, status:$status\n";
delete $old_workers{$died_worker};
- # don't update the status file if restart is scheduled and died_worker is the last one
- if ($restart_flag == 0 || scalar(keys %old_workers) != 0) {
- $update_status->();
- }
+ $update_status->();
}
}
- if ($auto_restart_interval > 0 && scalar(@signals_received) == 0 &&
- time() > $last_restart_time + $auto_restart_interval) {
- print STDERR "autorestart triggered (interval=$auto_restart_interval)\n";
- $restart_flag = 1;
- if (time() > $last_restart_time + $auto_restart_interval * 2) {
- print STDERR "force autorestart triggered\n";
- $restart_flag = 2;
+ # handle signals
+ my $restart;
+ while (@signals_received) {
+ my $sig = shift @signals_received;
+ if ($sig eq 'HUP') {
+ print STDERR "received HUP, spawning a new worker\n";
+ $restart = 1;
+ last;
+ } elsif ($sig eq 'ALRM') {
+ # skip
+ } else {
+ return $cleanup->($sig);
}
}
- my $num_old_workers = scalar(keys %old_workers);
- for (; @signals_received; shift @signals_received) {
- if ($signals_received[0] eq 'HUP') {
- print STDERR "received HUP (num_old_workers=$num_old_workers)\n";
- $restart_flag = 1;
- } else {
- $term_signal = $signals_received[0] eq 'TERM' ? $opts->{signal_on_term} : 'TERM';
- goto CLEANUP;
+ if (! $restart && $ENV{ENABLE_AUTO_RESTART}) {
+ my $auto_restart_interval = $ENV{AUTO_RESTART_INTERVAL};
+ my $elapsed_since_restart = time - $last_restart_time;
+ if ($elapsed_since_restart >= $auto_restart_interval && ! %old_workers) {
+ print STDERR "autorestart triggered (interval=$auto_restart_interval)\n";
+ $restart = 1;
+ } elsif ($elapsed_since_restart >= $auto_restart_interval * 2) {
+ print STDERR "autorestart triggered (forced, interval=$auto_restart_interval)\n";
+ $restart = 1;
}
}
- if ($restart_flag > 1 || ($restart_flag > 0 && $num_old_workers == 0)) {
- print STDERR "spawning a new worker (num_old_workers=$num_old_workers)\n";
+ # restart if requested
+ if ($restart) {
$old_workers{$current_worker} = $ENV{SERVER_STARTER_GENERATION};
- $current_worker = _start_worker($opts);
- $last_restart_time = time();
- $restart_flag = 0;
- $update_status->();
+ $start_worker->();
print STDERR "new worker is now running, sending $opts->{signal_on_hup} to old workers:";
if (%old_workers) {
print STDERR join(',', sort keys %old_workers), "\n";
} else {
print STDERR "none\n";
}
- my $kill_old_delay = $ENV{KILL_OLD_DELAY} || 0;
- $kill_old_delay ||= 5 if $ENV{ENABLE_AUTO_RESTART};
- print STDERR "sleep $kill_old_delay secs\n";
- sleep($kill_old_delay) if $kill_old_delay > 0;
+ my $kill_old_delay = defined $ENV{KILL_OLD_DELAY} ? $ENV{KILL_OLD_DELAY} : $ENV{ENABLE_AUTO_RESTART} ? 5 : 0;
+ if ($kill_old_delay != 0) {
+ print STDERR "sleeping $kill_old_delay secs before killing old workers\n";
+ sleep $kill_old_delay;
+ }
print STDERR "killing old workers\n";
kill $opts->{signal_on_hup}, $_
for sort keys %old_workers;
}
}
-
- CLEANUP:
- # cleanup
- $old_workers{$current_worker} = $ENV{SERVER_STARTER_GENERATION};
- undef $current_worker;
-
- print STDERR "received $signals_received[0], sending $term_signal to all workers:",
- join(',', sort keys %old_workers), "\n";
- kill $term_signal, $_
- for sort keys %old_workers;
- while (%old_workers) {
- if (my @r = wait3(1)) {
- my ($died_worker, $status) = @r;
- print STDERR "worker $died_worker died, status:$status\n";
- delete $old_workers{$died_worker};
- $update_status->();
- }
- }
-
- print STDERR "exiting\n";
+
+ die "unreachable";
}
sub restart_server {
@@ -312,7 +353,7 @@ sub restart_server {
# wait for the generation
while (1) {
my @gens = $get_generations->();
- last if scalar(@gens) == 1 && $gens[0] >= $wait_for;
+ last if scalar(@gens) == 1 && $gens[0] == $wait_for;
sleep 1;
}
}
@@ -341,35 +382,6 @@ sub _reload_env {
return %env;
}
-sub _start_worker {
- my $opts = shift;
- my $pid;
- while (1) {
- $ENV{SERVER_STARTER_GENERATION}++;
- $pid = fork;
- die "fork(2) failed:$!"
- unless defined $pid;
- if ($pid == 0) {
- my @args = @{$opts->{exec}};
- # child process
- if (defined $opts->{dir}) {
- chdir $opts->{dir} or die "failed to chdir:$!";
- }
- { exec { $args[0] } @args };
- print STDERR "failed to exec $args[0]$!";
- exit(255);
- }
- print STDERR "starting new worker $pid\n";
- sleep $opts->{interval};
- if ((grep { $_ ne 'HUP' } @signals_received)
- || waitpid($pid, WNOHANG) <= 0) {
- last;
- }
- print STDERR "new worker $pid seems to have failed to start, exit status:$?\n";
- }
- $pid;
-}
-
1;
__END__
@@ -43,11 +43,11 @@ for my $signal_on_hup ('TERM', 'USR1') {
$buf =~ /^(\d+):/;
my $worker_pid = $1;
# switch to next gen
- sleep 2;
+ sleep 3;
my $status = get_status();
like(get_status(), qr/^1:\d+\n$/s, 'status before restart');
kill 'HUP', $server_pid;
- sleep 3;
+ sleep 2;
like(get_status(), qr/^1:\d+\n2:\d+$/s, 'status during restart');
sleep 2;
like(get_status(), qr/^2:\d+\n$/s, 'status after restart');
@@ -23,8 +23,8 @@ for my $signal_on_hup ('TERM', 'USR1') {
],
status_file => "$tempdir/status",
enable_auto_restart => 1,
- auto_restart_interval => 4,
- kill_old_delay => 1,
+ auto_restart_interval => 6,
+ kill_old_delay => 2,
($signal_on_hup ne 'TERM'
? (signal_on_hup => $signal_on_hup) : ()),
);
@@ -49,9 +49,9 @@ for my $signal_on_hup ('TERM', 'USR1') {
sleep 2;
my $status = get_status();
like(get_status(), qr/^1:\d+\n$/s, 'status before auto-restart');
- sleep 5;
+ sleep 7; # new worker spawn at 7 (since start, interval(1) + auto_restart_interval(6)), status updated at 8 (7 + interval(1)), old dies at 11 (8 + kill_old_delay(2) + sleep(1) in the child source code)
like(get_status(), qr/^1:\d+\n2:\d+$/s, 'status during transient state');
- sleep 4;
+ sleep 3;
like(get_status(), qr/^2:\d+\n$/s, 'status after auto-restart');
is(
do {