# vim: ts=4 sts=4 sw=4:
use strict;
package CPAN;
-$CPAN::VERSION = '1.9800';
+$CPAN::VERSION = '1.99_51';
$CPAN::VERSION =~ s/_//;
# we need to run chdir all over and we would get at wrong libraries
sub _list_sorted_descending_is_tested {
my($self) = @_;
- sort
+ my $foul = 0;
+ my @sorted = sort
{ ($self->{is_tested}{$b}||0) <=> ($self->{is_tested}{$a}||0) }
- keys %{$self->{is_tested}}
+ grep
+ { if ($foul){ 0 } elsif (-e) { 1 } else { $foul = $_; 0 } }
+ keys %{$self->{is_tested}};
+ if ($foul) {
+ $CPAN::Frontend->mywarn("Lost build_dir detected ($foul), giving up all cached test results of currently running session.\n");
+ for my $dbd (keys %{$self->{is_tested}}) { # distro-build-dir
+ SEARCH: for my $d ($CPAN::META->all_objects("CPAN::Distribution")) {
+ if ($d->{build_dir} && $d->{build_dir} eq $dbd) {
+ $CPAN::Frontend->mywarn(sprintf "Flushing cache for %s\n", $d->pretty_id);
+ $d->fforce("");
+ last SEARCH;
+ }
+ }
+ delete $self->{is_tested}{$dbd};
+ }
+ return ();
+ } else {
+ return @sorted;
+ }
}
#-> sub CPAN::set_perl5lib
a list of all modules that are both available from CPAN and currently
installed within @INC. Duplicates of each distribution are suppressed.
The name of the bundle file is based on the current date and a
-counter.
+counter, e.g. F<Bundle/Snapshot_2012_05_21_00.pm>. This is installed
+again by running C<cpan Bundle::Snapshot_2012_05_21_00>, or installing
+C<Bundle::Snapshot_2012_05_21_00> from the CPAN shell.
Return value: path to the written file.
C<FTPstats.yml> in your C<cpan_home> directory. If no YAML module is
configured or YAML not installed, no stats are provided.
+=over
+
+=item install_tested
+
+Install all distributions that have been tested successfully but have
+not yet been installed. See also C<is_tested>.
+
+=item is_tested
+
+List all buid directories of distributions that have been tested
+successfully but have not yet been installed. See also
+C<install_tested>.
+
+=back
+
=head2 mkmyconfig
mkmyconfig() writes your own CPAN::MyConfig file into your C<~/.cpan/>
Note that install() gives no meaningful return value. See uptodate().
-=item CPAN::Distribution::install_tested()
-
-Install all distributions that have tested successfully but
-not yet installed. See also C<is_tested>.
-
=item CPAN::Distribution::isa_perl()
Returns 1 if this distribution file seems to be a perl distribution.
what you can try to accomplish in your private bundle file is to have the
packages that need to be configured early in the file and the gentle
ones later, so you can go out for coffee after a few minutes and leave CPAN.pm
-to churn away untended.
+to churn away unattended.
=head1 WORKING WITH CPAN.pm BEHIND FIREWALLS
=head2 OLD PERL VERSIONS
-CPAN.pm is regularly tested to run under 5.004, 5.005, and assorted
+CPAN.pm is regularly tested to run under 5.005 and assorted
newer versions. It is getting more and more difficult to get the
minimal prerequisites working on older perls. It is close to
impossible to get the whole Bundle::CPAN working there. If you're in
work for you as well. Above that the utility provides several
commandline shortcuts.
+melezhik (Alexey) sent me a link where he published a chef recipe to
+work with CPAN.pm: http://community.opscode.com/cookbooks/cpan.
+
+
=cut
);
return 1;
}
+ if (exists $self->{build_dir} && ! -d $self->{build_dir}){
+ # we have lost it.
+ $self->fforce(""); # no method to reset all phases but not set force (dodge)
+ }
# although we talk about 'force' we shall not test on
# force directly. New model of force tries to refrain from
chmod 0777 &~ umask, $packagedir; # may fail
my $f;
for $f (@dirents) { # is already without "." and ".."
- my $from = File::Spec->catdir($from_dir,$f);
- my $to = File::Spec->catdir($packagedir,$f);
+ my $from = File::Spec->catfile($from_dir,$f);
+ my $to = File::Spec->catfile($packagedir,$f);
unless (File::Copy::move($from,$to)) {
my $err = $!;
$from = File::Spec->rel2abs($from);
push @choices, 'META.yml' if $has_cm || $has_pcm;
for my $file ( grep { /$filter/ } @choices ) {
- my $path = File::Spec->catdir( $build_dir, $file );
+ my $path = File::Spec->catfile( $build_dir, $file );
return $path if -f $path
}
return $self;
}
+# see also reanimate_build_dir
#-> CPAN::Distribution::store_persistent_state
sub store_persistent_state {
my($self) = @_;
"will not store persistent state\n");
return;
}
- unless (File::Spec->canonpath(File::Basename::dirname($dir))
- eq File::Spec->canonpath($CPAN::Config->{build_dir})) {
+ unless ( Cwd::realpath(File::Spec->catdir($dir, File::Spec->updir()) )
+ eq Cwd::realpath($CPAN::Config->{build_dir} ) ) {
$CPAN::Frontend->mywarnonce("Directory '$dir' not below $CPAN::Config->{build_dir}, ".
"will not store persistent state\n");
return;
if ($result) {
$self->{unwrapped} = CPAN::Distrostatus->new("YES");
} else {
+ # unfortunately we have no $@ here, Tarzip is using mydie which dies with "\n"
$self->{unwrapped} = CPAN::Distrostatus->new("NO -- untar failed");
}
}
return;
}
- my %env;
- while (my($k,$v) = each %ENV) {
- next unless defined $v;
- $env{$k} = $v;
- }
- local %ENV = %env;
+ local $ENV{PERL_AUTOINSTALL} = $ENV{PERL_AUTOINSTALL};
+ local $ENV{PERL_EXTUTILS_AUTOINSTALL} = $ENV{PERL_EXTUTILS_AUTOINSTALL};
if ($CPAN::Config->{prerequisites_policy} eq "follow") {
$ENV{PERL_AUTOINSTALL} ||= "--defaultdeps";
$ENV{PERL_EXTUTILS_AUTOINSTALL} ||= "--defaultdeps";
if ($self->prefs->{pl}) {
$pl_commandline = $self->prefs->{pl}{commandline};
}
+ local $ENV{PERL} = $ENV{PERL};
+ local $ENV{PERL5_CPAN_IS_EXECUTING} = $ENV{PERL5_CPAN_IS_EXECUTING};
if ($pl_commandline) {
$system = $pl_commandline;
$ENV{PERL} = $^X;
$system = $self->{'configure'};
} elsif ($self->{modulebuild}) {
my($perl) = $self->perl or die "Couldn\'t find executable perl\n";
- $system = "$perl Build.PL $CPAN::Config->{mbuildpl_arg}";
+ my $mbuildpl_arg = $self->_make_phase_arg("pl");
+ $system = sprintf("%s Build.PL%s",
+ $perl,
+ $mbuildpl_arg ? " $mbuildpl_arg" : "",
+ );
} else {
my($perl) = $self->perl or die "Couldn\'t find executable perl\n";
my $switch = "";
if ($self->prefs->{pl}) {
$pl_env = $self->prefs->{pl}{env};
}
- if ($pl_env) {
- for my $e (keys %$pl_env) {
- $ENV{$e} = $pl_env->{$e};
- }
- }
+ local @ENV{keys %$pl_env} = values %$pl_env if $pl_env;
if (exists $self->{writemakefile}) {
} else {
local($SIG{ALRM}) = sub { die "inactivity_timeout reached\n" };
return $self->goodbye("$system -- NOT OK");
}
}
- if (-f "Makefile" || -f "Build") {
+ if (-f "Makefile" || -f "Build" || ($^O eq 'VMS' && (-f 'descrip.mms' || -f 'Build.com'))) {
$self->{writemakefile} = CPAN::Distrostatus->new("YES");
delete $self->{make_clean}; # if cleaned before, enable next
} else {
if ($self->prefs->{make}) {
$make_commandline = $self->prefs->{make}{commandline};
}
+ local $ENV{PERL} = $ENV{PERL};
if ($make_commandline) {
$system = $make_commandline;
$ENV{PERL} = CPAN::find_perl();
} else {
if ($self->{modulebuild}) {
- unless (-f "Build") {
+ unless (-f "Build" || ($^O eq 'VMS' && -f 'Build.com')) {
my $cwd = CPAN::anycwd();
$CPAN::Frontend->mywarn("Alert: no Build file available for 'make $self->{id}'".
" in cwd[$cwd]. Danger, Will Robinson!\n");
if ($self->prefs->{make}) {
$make_env = $self->prefs->{make}{env};
}
- if ($make_env) { # overriding the local ENV of PL, not the outer
- # ENV, but unlikely to be a risk
- for my $e (keys %$make_env) {
- $ENV{$e} = $make_env->{$e};
- }
- }
+ local @ENV{keys %$make_env} = values %$make_env if $make_env;
my $expect_model = $self->_prefs_with_expect("make");
my $want_expect = 0;
if ( $expect_model && @{$expect_model->{talk}} ) {
# DMAKI/DateTime-Calendar-Chinese-0.05.tar.gz
# in 2007-03 for 'make install'
# and 2008-04: #30464 (for 'make test')
- $CPAN::Frontend->mywarn("Warning: Prerequisite ".
- "'$need_module => $need_version' ".
- "for '$selfid' already built ".
- "but the result looks suspicious. ".
- "Skipping another build attempt, ".
- "to prevent looping endlessly.\n"
- );
+ # $CPAN::Frontend->mywarn("Warning: Prerequisite ".
+ # "'$need_module => $need_version' ".
+ # "for '$selfid' already built ".
+ # "but the result looks suspicious. ".
+ # "Skipping another build attempt, ".
+ # "to prevent looping endlessly.\n"
+ # );
next NEED;
}
}
$ENV{PERL} = CPAN::find_perl();
} elsif ($self->{modulebuild}) {
$system = sprintf "%s test", $self->_build_command();
- unless (-e "Build") {
+ unless (-e "Build" || ($^O eq 'VMS' && -e "Build.com")) {
my $id = $self->pretty_id;
$CPAN::Frontend->mywarn("Alert: no 'Build' file found while trying to test '$id'");
}
$make_test_arg ? " $make_test_arg" : "",
);
my($tests_ok);
- my %env;
- while (my($k,$v) = each %ENV) {
- next unless defined $v;
- $env{$k} = $v;
- }
- local %ENV = %env;
my $test_env;
if ($self->prefs->{test}) {
$test_env = $self->prefs->{test}{env};
}
- if ($test_env) {
- for my $e (keys %$test_env) {
- $ENV{$e} = $test_env->{$e};
- }
- }
+ local @ENV{keys %$test_env} = values %$test_env if $test_env;
my $expect_model = $self->_prefs_with_expect("test");
my $want_expect = 0;
if ( $expect_model && @{$expect_model->{talk}} ) {
$CPAN::Config->{mbuild_install_build_command} ?
$CPAN::Config->{mbuild_install_build_command} :
$self->_build_command();
- $system = sprintf("%s install %s",
+ my $install_directive = $^O eq 'VMS' ? '"install"' : 'install';
+ $system = sprintf("%s %s %s",
$mbuild_install_build_command,
+ $install_directive,
$CPAN::Config->{mbuild_install_arg},
);
+
} else {
my($make_install_make_command) =
CPAN::HandleConfig->prefs_lookup($self,
);
}
- my($stderr) = $^O eq "MSWin32" ? "" : " 2>&1 ";
+ my($stderr) = $^O eq "MSWin32" || $^O eq 'VMS' ? "" : " 2>&1 ";
my $brip = CPAN::HandleConfig->prefs_lookup($self,
q{build_requires_install_policy});
$brip ||="ask/yes";
my($perl) = $self->perl or $CPAN::Frontend->mydie("Couldn't find executable perl\n");
return "$perl ./Build";
}
+ elsif ($^O eq 'VMS') {
+ return "$^X Build.com";
+ }
return "./Build";
}