# -*- Mode: cperl; coding: utf-8; cperl-indent-level: 4 -*-
package CPAN;
$VERSION = '1.76_01';
# $Id: CPAN.pm,v 1.412 2003/07/31 14:53:04 k Exp $
# only used during development:
$Revision = "";
# $Revision = "[".substr(q$Revision: 1.412 $, 10)."]";
use Carp ();
use Config ();
use Cwd ();
use DirHandle;
use Exporter ();
use FileHandle ();
use Safe ();
use Text::ParseWords ();
no lib "."; # we need to run chdir all over and we would get at wrong
# libraries there
CPAN 1
Index 2
InfoObj 4
Author 8
Distribution 16
Bundle 32
Module 64
CacheMgr 128
Complete 256
FTP 512
Shell 1024
Eval 2048
Config 4096
Tarzip 8192
Version 16384
Queue 32768
];
package CPAN;
use strict qw(vars);
@EXPORT = qw(
);
#-> sub CPAN::AUTOLOAD ;
sub AUTOLOAD {
my($l) = $AUTOLOAD;
$l =~ s/.*:://;
my(%EXPORT);
if (exists $EXPORT{$l}){
} else {
});
}
}
#-> sub CPAN::shell ;
sub shell {
my($self) = @_;
my $oprompt = shift || "cpan> ";
my $commandline = shift || "";
local($^W) = 1;
unless ($Suppress_readline) {
if (! $term
or
) {
}
$attribs->{attempted_completion_function} = sub {
}
} else {
}
last;
}
my($fh) = FileHandle->new;
open $fh, "<$histfile" or last;
local $/ = "\n";
while (<$fh>) {
chomp;
$term->AddHistory($_);
}
close $fh;
}}
# $term->OUT is autoflushed anyway
$| = 1;
select STDOUT;
$| = 1;
select $odef;
}
# no strict; # I do not recall why no strict was here (2000-09-03)
my $try_detect_readline;
"available (try 'install Bundle::CPAN')";
sprintf qq{
},
)
my($continuation) = "";
SHELLCOMMAND: while () {
if ($Suppress_readline) {
print $prompt;
last SHELLCOMMAND unless defined ($_ = <> );
chomp;
} else {
last SHELLCOMMAND unless
}
$_ = "$continuation$_" if $continuation;
s/^\s+//;
next SHELLCOMMAND if /^$/;
$_ = 'h' if /^\s*\?/;
last SHELLCOMMAND;
} elsif (s/\\$//s) {
chomp;
$continuation = $_;
$prompt = " > ";
} elsif (/^\!/) {
s/^\!//;
my($eval) = $_;
use vars qw($import_done);
eval($eval);
warn $@ if $@;
$continuation = "";
} elsif (/./) {
my(@line);
if ($] < 5.00322) { # parsewords had a bug until recently
@line = split;
} else {
warn($@), next SHELLCOMMAND if $@;
warn("Text::Parsewords could not parse the line [$_]"),
next SHELLCOMMAND unless @line;
}
warn $@ if $@;
$continuation = "";
}
} continue {
# shell, but on the second command I see no
# use in that
$Signal=0;
if ($try_detect_readline) {
||
) {
delete $INC{"Term/ReadLine.pm"};
my $redef = 0;
"Term::ReadLine redefined\n");
@_ = ($oprompt,"");
goto &shell;
}
}
}
}
%can = (
'commit' => "Commit changes to disk",
'defaults' => "Reload defaults from disk",
'init' => "Interactive setting of all options",
);
# we delay requiring LWP::UserAgent and setting up inheritence until we need it
! a b d h i m o q r u autobundle clean dump
$LAST_TIME ||= 0;
$DATE_OF_03 ||= 0;
# use constant PROTOCOL => "2.0"; # outcommented to avoid warning on upgrade from 1.57
package CPAN::Distribution;
sub new {
my($class) = shift;
my($deps) = shift;
my @deps;
my %seen;
}
}
sub as_string {
my($self) = shift;
"\nRecursive dependency detected:\n " .
".\nCannot continue.\n";
}
$COLOR_REGISTERED ||= 0;
$PRINT_ORNAMENTING ||= 0;
#-> sub CPAN::Shell::AUTOLOAD ;
sub AUTOLOAD {
my $class = shift(@_);
# warn "autoload[$autoload] class[$class]";
$autoload =~ s/.*:://;
if ($autoload =~ /^w/) {
} else {
});
}
} else {
});
}
}
# One use of the queue is to determine if we should or shouldn't
# announce the availability of a new CPAN module
# Now we try to use it for dependency tracking. For that to happen
# we need to draw a dependency tree and do the leaves first. This can
# easily be reached by running CPAN.pm recursively, but we don't want
# to waste memory and run into deep recursion. So what we can do is
# this:
# CPAN::Queue is the package where the queue is maintained. Dependencies
# often have high priority and must be brought to the head of the queue,
# possibly by jumping the queue if they are already there. My first code
# attempt tried to be extremely correct. Whenever a module needed
# immediate treatment, I either unshifted it to the front of the queue,
# or, if it was already in the queue, I spliced and let it bypass the
# others. This became a too correct model that made it impossible to put
# an item more than once into the queue. Why would you need that? Well,
# you need temporary duplicates as the manager of the queue is a loop
# that
#
# (1) looks at the first item in the queue without shifting it off
#
# (2) cares for the item
#
# (3) removes the item from the queue, *even if its agenda failed and
# even if the item isn't the first in the queue anymore* (that way
# protecting against never ending queues)
#
# So if an item has prerequisites, the installation fails now, but we
# want to retry later. That's easy if we have it twice in the queue.
#
# I also expect insane dependency situations where an item gets more
# than two lives in the queue. Simplest example is triggered by 'install
# Foo Foo Foo'. People make this kind of mistakes and I don't want to
# get in the way. I wanted the queue manager to be a dumb servant, not
# one that knows everything.
#
# Who would I tell in this model that the user wants to be asked before
# processing? I can't attach that information to the module object,
# because not modules are installed but distributions. So I'd have to
# tell the distribution object that it should ask the user before
# processing. Where would the question be triggered then? Most probably
# in CPAN::Distribution::rematein.
# Hope that makes sense, my head is a bit off:-) -- AK
use vars qw{ @All };
# CPAN::Queue::new ;
sub new {
my($class,$s) = @_;
return $self;
}
# CPAN::Queue::first ;
sub first {
}
# CPAN::Queue::delete_first ;
sub delete_first {
my $i;
for my $i (0..$#All) {
splice @All, $i, 1;
return;
}
}
}
# CPAN::Queue::jumpqueue ;
sub jumpqueue {
my $class = shift;
my @what = @_;
join(",",@what)
my $jumped = 0;
for (my $i=0; $i<$#All;$i++) { #prevent deep recursion
$jumped++;
# processing now; more are OK if
# user typed it several times
);
next WHAT;
}
}
}
}
join(",",@what)
}
# CPAN::Queue::exists ;
sub exists {
# warn "in exists what[$what] all[@all] exists[$exists]";
$exists;
}
# CPAN::Queue::delete ;
sub delete {
}
# CPAN::Queue::nullify_queue ;
sub nullify_queue {
@All = ();
}
package CPAN;
# from here on only subs.
################################################################################
#-> sub CPAN::all_objects ;
sub all_objects {
}
*all = \&all_objects;
# Called by shell, not in batch mode. In batch mode I see no risk in
# having many processes updating something as installations are
# continually checked at runtime. In shell mode I suspect it is
# unintentional to open more than one shell at a time
#-> sub CPAN::checklock ;
sub checklock {
my($self) = @_;
if (-f $lockfile && -M _ > 0) {
$fh->close;
chomp $otherpid;
}
chomp $otherhost;
}
"reports other host $otherhost and other process $otherpid.\n".
"Cannot proceed.\n"));
}
return if $$ == $otherpid; # should never happen
qq{
});
if (kill 0, $otherpid) {
kill $otherpid
});
} elsif (-w $lockfile) {
my($ans) =
unless $ans =~ /^y/i;
} else {
Carp::croak(
);
}
} else {
"reports other process with ID ".
"$otherpid. Cannot proceed.\n"));
}
}
if ($@) {
# A special case at least for Jarkko.
my $firsterror = $@;
my $seconderror;
my $symlinkcpan;
if (-l $dotcpan) {
$symlinkcpan = readlink $dotcpan;
die "readlink $dotcpan failed: $!" unless defined $symlinkcpan;
if ($@) {
$seconderror = $@;
} else {
});
}
}
unless (-d $dotcpan) {
my $diemess = qq{
$diemess .= qq{
} if $seconderror;
$diemess .= qq{
};
}
}
my $fh;
if ($! =~ /Permission/) {
$incc
or
});
}
}
$fh->print($$, "\n");
$fh->close;
&cleanup;
};
# no blocks!!!
print "Caught SIGINT\n";
$Signal++;
};
# From: Larry Wall <larry@wall.org>
# Subject: Re: deprecating SIGDIE
# To: perl5-porters@perl.org
# Date: Thu, 30 Sep 1999 14:58:40 -0700 (PDT)
#
# The original intent of __DIE__ was only to allow you to substitute one
# kind of death for another on an application-wide basis without respect
# to whether you were in an eval or not. As a global backstop, it should
# not be used any more lightly (or any more heavily :-) than class
# UNIVERSAL. Any attempt to build a general exception model on it should
# be politely squashed. Any bug that causes every eval {} to have to be
# modified should be not so politely squashed.
#
# Those are my current opinions. It is also my optinion that polite
# arguments degenerate to personal arguments far too frequently, and that
# when they do, it's because both people wanted it to, or at least didn't
# sufficiently want it not to.
#
# Larry
# global backstop to cleanup if we should really die
}
#-> sub CPAN::DESTROY ;
sub DESTROY {
&cleanup; # need an eval?
}
#-> sub CPAN::anycwd ;
sub anycwd () {
my $getcwd;
}
#-> sub CPAN::cwd ;
#-> sub CPAN::getcwd ;
#-> sub CPAN::exists ;
sub exists {
### Carp::croak "exists called without class argument" unless $class;
$id ||= "";
}
#-> sub CPAN::delete ;
sub delete {
}
#-> sub CPAN::has_usable
# has_inst is sometimes too optimistic, we should replace it with this
# has_usable whenever a case is given
sub has_usable {
return unless $has_inst;
my $usable;
$usable = {
LWP => [ # we frequently had "Can't locate object
# method "new" via package "LWP::UserAgent" at
# (eval 69) line 2006
sub {require LWP},
],
]
};
for my $c (0..$#{$usable->{$mod}}) {
if ($@) {
warn "DEBUG: c[$c]\$\@[$@]ret[$ret]";
return;
}
}
}
}
#-> sub CPAN::has_inst
sub has_inst {
Carp::croak("CPAN->has_inst() called without an argument")
unless defined $mod;
||
||
) {
return 0;
}
my $obj;
$file =~ s|::|/|g;
$file =~ s|/|\\|g if $^O eq 'MSWin32';
$file .= ".pm";
# checking %INC is wrong, because $INC{LWP} may be true
# I really want to say "bla loaded OK", I have to somehow
# cache results.
### warn "$file in %INC"; #debug
return 1;
} elsif (eval { require $file }) {
# eval is good: if we haven't yet read the database it's
# perfect and if we have installed the module in the meantime,
# it tries again. The second require is only a NOOP returning
# 1 if we had success, otherwise it's retrying
if ($mod eq "CPAN::WAIT") {
}
return 1;
} elsif ($mod eq "Net::FTP") {
}) unless $Have_warned->{"Net::FTP"}++;
sleep 3;
} elsif ($mod eq "Digest::MD5"){
});
sleep 2;
} else {
}
return 0;
}
#-> sub CPAN::instance ;
sub instance {
$id ||= "";
# unsafe meta access, ok?
}
#-> sub CPAN::new ;
sub new {
bless {}, shift;
}
#-> sub CPAN::cleanup ;
sub cleanup {
# warn "cleanup called with arg[@_] End[$End] Signal[$Signal]";
my($message) = @_;
my $i = 0;
my $ineval = 0;
my($subroutine);
while ((undef,undef,undef,$subroutine) = caller(++$i)) {
$ineval = 1, last if
$subroutine eq '(eval)';
}
# require Carp;
# Carp::cluck("DEBUGGING");
}
#-> sub CPAN::savehist
sub savehist {
my($self) = @_;
return;
}
return;
}
} else {
return;
}
my($fh) = FileHandle->new;
local $\ = local $, = "\n";
print $fh @h;
close $fh;
}
sub is_tested {
}
sub is_installed {
}
sub set_perl5lib {
my($self) = @_;
my @env;
}
#-> sub CPAN::CacheMgr::as_string ;
sub as_string {
if ($@) {
} else {
}
}
#-> sub CPAN::CacheMgr::cachesize ;
sub cachesize {
shift->{DU};
}
#-> sub CPAN::CacheMgr::tidyup ;
sub tidyup {
my($self) = @_;
"Deleting from cache".
": $toremove (%.1f>%.1f MB)\n",
);
}
}
#-> sub CPAN::CacheMgr::dir ;
sub dir {
shift->{ID};
}
#-> sub CPAN::CacheMgr::entries ;
sub entries {
return unless defined $dir;
or Carp::croak("Couldn't opendir $dir: $!");
my(@entries);
for ($dh->read) {
next if $_ eq "." || $_ eq "..";
if (-f $_) {
} elsif (-d _) {
} else {
}
}
sort { -M $b <=> -M $a} @entries;
}
#-> sub CPAN::CacheMgr::disk_usage ;
sub disk_usage {
my($Du) = 0;
find(
sub {
return if -l $_;
if ($^O eq 'MacOS') {
} else {
$Du += (-s _);
}
},
$dir
);
}
#-> sub CPAN::CacheMgr::force_clean_cache ;
sub force_clean_cache {
return unless -e $dir;
}
#-> sub CPAN::CacheMgr::new ;
sub new {
my $class = shift;
my $time = time;
$debug = "";
my $self = {
DU => 0
};
$self->scan_cache;
$t2 = time;
$self;
}
#-> sub CPAN::CacheMgr::scan_cache ;
sub scan_cache {
my $self = shift;
sprintf("Scanning cache %s for sizes\n",
my $e;
next if $e eq ".." || $e eq ".";
$self->disk_usage($e);
}
}
#-> sub CPAN::Debug::debug ;
sub debug {
# Complete, caller(1)
# eg readline
($caller) = caller(0);
$caller =~ s/.*:://;
if ($@) {
} else {
}
} else {
}
}
}
#-> sub CPAN::Config::edit ;
# returns true on successful action
sub edit {
return unless @args;
$o = shift @args;
if($can{$o}) {
return 1;
} else {
if ($o =~ /list$/) {
$func ||= "";
my $changed;
# Let's avoid eval, it's easier to comprehend without.
if ($func eq "push") {
$changed = 1;
} elsif ($func eq "pop") {
$changed = 1;
} elsif ($func eq "shift") {
$changed = 1;
} elsif ($func eq "unshift") {
$changed = 1;
} elsif ($func eq "splice") {
$changed = 1;
} elsif (@args) {
$changed = 1;
} else {
$self->prettyprint($o);
}
if ($o eq "urllist" && $changed) {
# reset the cached values
}
return $changed;
} else {
$self->prettyprint($o);
}
}
}
sub prettyprint {
my($self,$k) = @_;
if (ref $v) {
my(@report) = ref $v eq "ARRAY" ?
@$v :
map { sprintf(" %-18s => %s\n",
$_,
defined $v->{$_} ? $v->{$_} : "UNDEFINED"
)} keys %$v;
join(
"",
sprintf(
" %-18s\n",
$k
),
map {"\t$_\n"} @report
)
);
} elsif (defined $v) {
} else {
}
}
#-> sub CPAN::Config::commit ;
sub commit {
unless (defined $configpm){
});
}
my($mode);
if (-f $configpm) {
if ($mode && ! -w _) {
Carp::confess("$configpm is not writable");
}
}
my $msg;
# This is CPAN.pm's systemwide configuration file. This file provides
# defaults for users, and the values can be changed in a per-user
# configuration file. The user-config file is being looked for as
# ~/.cpan/CPAN/MyConfig.pm.
$msg ||= "\n";
my($fh) = FileHandle->new;
open $fh, ">$configpm" or
$fh->print(
" '$_' => ",
",\n"
);
}
$fh->print("};\n1;\n__END__\n");
close $fh;
#$mode = 0444 | ( $mode & 0111 ? 0111 : 0 );
#chmod $mode, $configpm;
###why was that so? $self->defaults;
1;
}
#-> sub CPAN::Config::defaults ;
sub defaults {
my($self) = @_;
1;
}
sub init {
my($self) = @_;
# have the least
# important
# variable
# undefined
1;
}
# This is a piece of repeated code that is abstracted here for
# maintainability. RMB
#
sub _configpmtest {
my($configpmdir, $configpmtest) = @_;
if (-w $configpmtest) {
return $configpmtest;
} elsif (-w $configpmdir) {
#_#_# following code dumped core on me with 5.003_11, a.k.
my $configpm_bak = "$configpmtest.bak";
unlink $configpm_bak if -f $configpm_bak;
if( -f $configpmtest ) {
if( rename $configpmtest, $configpm_bak ) {
END
}
}
my $fh = FileHandle->new;
if ($fh->open(">$configpmtest")) {
$fh->print("1;\n");
return $configpmtest;
} else {
# Should never happen
Carp::confess("Cannot open >$configpmtest");
}
} else { return }
}
#-> sub CPAN::Config::load ;
sub load {
my($self) = shift;
my(@miss);
use Carp;
# MakeMaker problems
unless ($dot_cpan++){
# system wide settings
shift @INC;
}
$redo ||= "";
$redo++;
$redo++;
} else {
}
unless ($configpm) {
unless ($configpm) {
}
}
}
local($") = ", ";
@miss
END
});
sleep 2;
}
#-> sub CPAN::Config::missing_config_data ;
sub missing_config_data {
my(@miss);
for (
"cpan_home", "keep_source_where", "build_dir", "build_cache",
"scan_cache", "index_expire", "gzip", "tar", "unzip", "make",
"pager",
"makepl_arg", "make_arg", "make_install_arg", "urllist",
"inhibit_startup_message", "ftp_proxy", "http_proxy", "no_proxy",
"prerequisites_policy",
"cache_metadata",
) {
}
return @miss;
}
#-> sub CPAN::Config::unload ;
sub unload {
delete $INC{'CPAN/MyConfig.pm'};
}
#-> sub CPAN::Config::help ;
sub help {
letter o):
]);
undef; #don't reprint CPAN::Config
}
#-> sub CPAN::Config::cpl ;
sub cpl {
$word ||= "";
if (
defined($words[2])
and
(
||
)
) {
return grep /^\Q$word\E/, qw(splice shift unshift pop push);
} elsif (@words >= 4) {
return ();
}
}
#-> sub CPAN::Shell::h ;
sub h {
if (defined $about) {
} else {
}
}
*help = \&h;
#-> sub CPAN::Shell::a ;
sub a {
# authors are always UPPERCASE
for (@arg) {
$_ = uc $_ unless /=/;
}
}
#-> sub CPAN::Shell::ls ;
sub ls {
my @accept;
for (@arg) {
unless (/^[A-Z\-]+$/i) {
next;
}
push @accept, uc $_;
}
for my $a (@accept){
}
}
#-> sub CPAN::Shell::local_bundles ;
sub local_bundles {
my @bbase = "Bundle";
my($entry);
next if $entry =~ /^\./;
push @bbase, "$bbase\::$entry";
} else {
}
}
}
}
}
}
#-> sub CPAN::Shell::b ;
sub b {
}
#-> sub CPAN::Shell::d ;
#-> sub CPAN::Shell::m ;
sub m { # emacs confused here }; sub mimimimimi { # emacs in sync here
my $self = shift;
}
#-> sub CPAN::Shell::i ;
sub i {
my($self) = shift;
my(@args) = @_;
my(@result);
}
@result == 0 ?
"No objects found of any type for argument @args\n" :
join("",
(map {$_->as_glimpse} @result),
scalar @result, " items found\n",
);
}
#-> sub CPAN::Shell::o ;
# CPAN::Shell::o and CPAN::Config::edit are closely related. 'o conf'
# should have been called set and 'o debug' maybe 'set debug'
sub o {
$o_type ||= "";
if ($o_type eq 'conf') {
if (!@o_what) { # print all things, "o conf"
my($k,$v);
}
if (exists $INC{'CPAN/MyConfig.pm'}) {
}
}
}
}
} elsif ($o_type eq 'debug') {
my(%valid);
if (@o_what) {
while (@o_what) {
next;
}
} elsif ($what =~ /^\d/) {
} elsif (lc $what eq 'all') {
my($max) = 0;
$max += $_;
}
} else {
my($known) = 0;
next unless lc($_) eq lc($what);
$known = 1;
}
unless $known;
}
}
} else {
my $raw = "Valid options for debug are ".
}
my($k,$v);
}
} else {
}
} else {
});
}
}
sub paintdots_onreload {
my($ref) = shift;
sub {
my($subr) = $1;
++$$ref;
local($|) = 1;
# $CPAN::Frontend->myprint(".($subr)");
return;
}
warn @_;
};
}
#-> sub CPAN::Shell::reload ;
sub reload {
$command ||= "";
next unless $INC{$f};
local($/);
my $redef = 0;
eval <$fh>;
warn $@ if $@;
}
} elsif ($command =~ /index/) {
} else {
}
}
#-> sub CPAN::Shell::_binary_extensions ;
sub _binary_extensions {
my($self) = shift @_;
next if $file eq "N/A";
local($|) = 1;
}
# print join " | ", @result;
return @result;
}
#-> sub CPAN::Shell::recompile ;
sub recompile {
my($self) = shift @_;
# don't do it twice
}
# stop a package from recompiling,
# e.g. IO-1.12 when we have perl5.003_10
}
}
#-> sub CPAN::Shell::_u_r_common ;
sub _u_r_common {
my($self) = shift @_;
my($what) = shift @_;
Carp::croak "Usage: \$obj->_u_r_common(a|r|u)" unless
my(@args) = @_;
my $sprintf = "%s%-25s%s %9s %9s %s\n";
if (0) { # Looks like noise to me, was very useful for debugging
# for metadata cache
}
next unless defined $file; # ??
my($have);
if ($inst_file){
if ($what eq "a") {
} elsif ($what eq "r") {
local($^W) = 0;
if ($have eq "undef"){
$version_undefs++;
} elsif ($have == 0){
$version_zeroes++;
}
# to be pedantic we should probably say:
# && !($have eq "undef" && $latest ne "undef" && $latest gt "");
# to catch the case where CPAN has a version 0 and we have a version undef
} elsif ($what eq "u") {
next;
}
} else {
if ($what eq "a") {
next;
} elsif ($what eq "r") {
next;
} elsif ($what eq "u") {
$have = "-";
}
}
if ($what eq "a") {
} elsif ($what eq "r") {
} elsif ($what eq "u") {
}
unless ($headerdone++){
$sprintf,
"",
"Package namespace",
"",
"installed",
"latest",
"in CPAN file"
));
}
my $color_on = "";
my $color_off = "";
if (
&&
&&
) {
}
$color_on,
$have,
$latest,
$file);
}
unless (%need) {
if ($what eq "u") {
} elsif ($what eq "r") {
}
}
if ($what eq "r") {
if ($version_zeroes) {
}
if ($version_undefs) {
}
}
@result;
}
#-> sub CPAN::Shell::r ;
sub r {
shift->_u_r_common("r",@_);
}
#-> sub CPAN::Shell::u ;
sub u {
shift->_u_r_common("u",@_);
}
#-> sub CPAN::Shell::autobundle ;
sub autobundle {
my($self) = shift;
unless (-d $todir) {
return;
}
my($y,$m,$d) = (localtime)[5,4,3];
$y+=1900;
$m++;
my($c) = 0;
my($me) = sprintf "Snapshot_%04d_%02d_%02d_%02d", $y, $m, $d, $c;
while (-f $to) {
$me = sprintf "Snapshot_%04d_%02d_%02d_%02d", $y, $m, $d, ++$c;
}
$fh->print(
"package Bundle::$me;\n\n",
"\$VERSION = '0.01';\n\n",
"1;\n\n",
"__END__\n\n",
"=head1 NAME\n\n",
"Bundle::$me - Snapshot of installation on ",
" on ",
scalar(localtime),
"\n\n=head1 SYNOPSIS\n\n",
"perl -MCPAN -e 'install Bundle::$me'\n\n",
"=head1 CONTENTS\n\n",
join("\n", @bundle),
"\n\n=head1 CONFIGURATION\n\n",
"\n\n=head1 AUTHOR\n\n",
"This Bundle has been generated automatically ",
"by the autobundle routine in CPAN.pm.\n",
);
$fh->close;
$to\n\n");
}
#-> sub CPAN::Shell::expandany ;
sub expandany {
my($self,$s) = @_;
if ($s =~ m|/|) { # looks like a file
# Distributions spring into existence, not expand
} elsif ($s =~ m|^Bundle::|) {
# both attractive and crumpy: always
# current state but easy to forget
# somewhere
} else {
}
return;
}
#-> sub CPAN::Shell::expand ;
sub expand {
shift;
my($arg,@m);
if ($arg =~ m|^/(.*)/$|) {
$regex = $1;
} elsif ($arg =~ m/=/) {
$command = 1;
}
my $class = "CPAN::$type";
my $obj;
$class,
$command || "UNDEFINED",
if (defined $regex) {
for $obj (
sort
) {
# BUG, we got an empty object somewhere
"Bug in CPAN: Empty id on obj[%s][%s]",
$obj,
next;
}
push @m, $obj
or
(
(
$] < 5.00303 ### provide sort of
### compatibility with 5.003
||
)
&&
);
}
} elsif ($command) {
die "equal sign in command disabled (immature interface), ".
"you can set
unless $ADVANCED_QUERY;
for my $self (
sort
) {
if ($matchcrit) {
} else {
}
}
} else {
if ( $type eq 'Bundle' ) {
} elsif ($type eq "Distribution") {
}
} else {
next;
}
push @m, $obj;
}
}
return wantarray ? @m : $m[0];
}
#-> sub CPAN::Shell::format_result ;
sub format_result {
my($self) = shift;
@result == 0 ?
"No objects of type $type found for argument @args\n" :
join("",
(map {$_->as_glimpse} @result),
scalar @result, " items found\n",
);
$result;
}
# The only reason for this method is currently to have a reliable
# debugging utility that reveals which output is going through which
# channel. No, I don't like the colors ;-)
#-> sub CPAN::Shell::print_ornameted ;
sub print_ornamented {
my $longest = 0;
return unless defined $what;
# courtesy jhi:
$what
}
if ($PRINT_ORNAMENTING) {
unless (defined &color) {
} else {
*color = sub { return "" };
}
}
my $line;
}
while ($what){
$what =~ s/(.*\n?)//m;
my $line = $1;
last unless $line;
# print "line[$line]ornament[$ornament]sprintf[$sprintf]\n";
}
} else {
# chomp $what;
# $what .= "\n"; # newlines unless $PRINT_ORNAMENTING
print $what;
}
}
sub myprint {
}
sub myexit {
exit;
}
sub mywarn {
}
sub myconfess {
Carp::confess "died";
}
sub mydie {
die "\n";
}
sub setup_output {
return if -t STDOUT;
$| = 1;
select STDOUT;
$| = 1;
select $odef;
}
#-> sub CPAN::Shell::rematein ;
# RE-adme||MA-ke||TE-st||IN-stall
sub rematein {
shift;
my $pragma = "";
if ($meth eq 'force') {
}
setup_output();
# Here is the place to set "test_count" on all involved parties to
# 0. We then can pass this counter on to the involved
# distributions and those can refuse to test if test_count > X. In
# the first stab at it we could use a 1 for "X".
# But when do I reset the distributions to start with 0 again?
# Jost suggested to have a random or cycling interaction ID that
# we pass through. But the ID is something that is just left lying
# around in addition to the counter, so I'd prefer to set the
# counter to 0 now, and repeat at the end of the loop. But what
# about dependencies? They appear later and are not reset, they
# enter the queue but not its copy. How do they get a sensible
# test_count?
# construct the queue
my($s,@s,@qcopy);
foreach $s (@some) {
my $obj;
if (ref $s) {
$obj = $s;
} elsif ($s =~ m|^/|) { # looks like a regexp
"not supported\n");
sleep 2;
next;
} else {
}
if (ref $obj) {
} else {
join "",
"Don't be silly, you can't $meth ",
" ;-)\n"
);
sleep 2;
}
} else {
qq{don\'t know what it is.
i /$s/
});
sleep 2;
}
}
# queuerunner (please be warned: when I started to change the
# queue to hold objects instead of names, I made one or two
# mistakes and never found which. I reverted back instead)
my $obj;
if (ref $s) {
$obj = $s; # I do not believe, we would survive if this happened
} else {
}
if ($pragma
&&
### compatibility with 5.003
# "CPAN::Distribution" must know
# what we are intending
}
$obj->called_for($s);
}
qq{\]}
} else {
}
}
}
}
#-> sub CPAN::Shell::dump ;
sub dump { shift->rematein('dump',@_); }
#-> sub CPAN::Shell::force ;
#-> sub CPAN::Shell::get ;
#-> sub CPAN::Shell::readme ;
#-> sub CPAN::Shell::make ;
#-> sub CPAN::Shell::test ;
#-> sub CPAN::Shell::install ;
#-> sub CPAN::Shell::clean ;
#-> sub CPAN::Shell::look ;
#-> sub CPAN::Shell::cvs_import ;
sub config {
return if $SETUPDONE;
$SETUPDONE++;
} else {
}
}
sub get_basic_credentials {
return unless $proxy;
} else {
)\nUsername:");
} else {
$CPAN::Frontend->mywarn("Warning: Term::ReadKey seems not to be available, your password will be echoed to the terminal!\n");
}
}
}
}
# mirror(): Its purpose is to deal with proxy authentication. When we
# call SUPER::mirror, we relly call the mirror method in
# LWP::UserAgent. LWP::UserAgent will then call
# $self->get_basic_credentials or some equivalent and this will be
# $self->dispatched to our own get_basic_credentials method.
# Our own get_basic_credentials sets $USER and $PASSWD, two globals.
# 407 stands for HTTP_PROXY_AUTHENTICATION_REQUIRED. Which means
# although we have gone through our get_basic_credentials, the proxy
# server refuses to connect. This could be a case where the username or
# password has changed in the meantime, so I'm trying once again without
# $USER and $PASSWD to give the get_basic_credentials routine another
# chance to set $USER and $PASSWD.
sub mirror {
undef $USER;
undef $PASSWD;
}
$result;
}
#-> sub CPAN::FTP::ftp_get ;
sub ftp_get {
return 0 unless defined $ftp;
warn "Couldn't login on $host";
return;
}
warn "Couldn't cwd $dir";
return;
}
warn "Couldn't fetch $file from $host\n";
return;
}
return 1;
}
# > ***************
# > *** 1562,1567 ****
# > --- 1562,1580 ----
# > return 1 if substr($url,0,4) eq "file";
# > return 1 unless $url =~ m|://([^/]+)|;
# > my $host = $1;
# > + my $proxy = $CPAN::Config->{'http_proxy'} || $ENV{'http_proxy'};
# > + if ($proxy) {
# > + $proxy =~ m|://([^/:]+)|;
# > + $proxy = $1;
# > + my $noproxy = $CPAN::Config->{'no_proxy'} || $ENV{'no_proxy'};
# > + if ($noproxy) {
# > + if ($host !~ /$noproxy$/) {
# > + $host = $proxy;
# > + }
# > + } else {
# > + $host = $proxy;
# > + }
# > + }
# > require Net::Ping;
# > return 1 unless $Net::Ping::VERSION >= 2;
# > my $p;
#-> sub CPAN::FTP::localize ;
sub localize {
$force ||= 0;
Carp::croak "Usage: ->localize(cpan_file,as_local_file[,$force])"
unless defined $aslocal;
if ($^O eq 'MacOS') {
# Comment by AK on 2000-09-03: Uniq short filenames would be
# available in CHECKSUMS file
if (length($name) > 31) {
$name =~ s/(
\.(
tgz |
zip |
)
)$//x;
my $suf = $1;
chop $name;
}
}
}
my($restore) = 0;
if (-f $aslocal){
rename $aslocal, "$aslocal.bak";
$restore++;
}
qq{directory "$aslocal_dir".
I\'ll continue, but if you encounter problems, they may be due
unless ($Ua) {
if ($@) {
} else {
my($var);
# >>>>> On Wed, 13 Dec 2000 09:21:34 -0500, "Robison, Jonathon (J.M.)" <jrobiso2@visteon.com> said:
#
# > I note that although CPAN.pm can use proxies, it doesn't seem equipped to
# > use ones that require basic autorization.
#
# > Example of when I use it manually in my own stuff:
#
# > $ua->proxy(['http','ftp'], http://my.proxy.server:83');
# > $req->proxy_authorization_basic("username","password");
# > $res = $ua->request($req);
#
}
}
}
}
# Try the list of urls for each single object. We keep a record
# where we did get a file from
warn "Malformed urllist; ignoring. Configuration file corrupt?\n";
}
$last = $#{$CPAN::Config->{urllist}};
} else {
@reordered =
sort {
<=>
or
defined($Thesite)
and
($b == $Thesite)
<=>
($a == $Thesite)
} 0..$last;
}
my(@levels);
if ($Themethod) {
} else {
}
my($levelno);
my $method = "host$level";
if ($ret) {
my $now = time;
# utime $now, $now, $aslocal; # too bad, if we do that, we
# might alter a local mirror
return $ret;
} else {
unlink $aslocal;
}
}
my(@mess);
push @mess,
qq{E.g. with 'o conf urllist push ftp://myurl/'};
sleep 2;
}
if ($restore) {
rename "$aslocal.bak", $aslocal;
return $aslocal;
}
return;
}
sub hosteasy {
my($i);
my $l;
$l = $u->path;
} else { # works only on Unix, is poorly constructed, but
# hopefully better than nothing.
# RFC 1738 says fileurl BNF is
# fileurl = "file://" [ host | "localhost" ] "/" fpath
# Thanks to "Mark D. Baushke" <mdb@cisco.com> for
# the code
$l =~ s|^file:||; # assume they
# meant
# file://localhost
$l =~ s|^/||s unless -f $l; # e.g. /P:
}
if ( -f $l && -r _) {
$Thesite = $i;
return $l;
}
# Maybe mirror has compressed it?
if (-f "$l.gz") {
if ( -f $aslocal) {
$Thesite = $i;
return $aslocal;
}
}
}
$url
");
unless ($Ua) {
if ($@) {
}
}
if ($res->is_success) {
$Thesite = $i;
my $now = time;
# important than upload time
return $aslocal;
my $gzurl = "$url.gz";
");
if ($res->is_success &&
) {
$Thesite = $i;
return $aslocal;
}
} else {
"LWP failed with code[%s] message[%s]\n",
));
# Alan Burlison informed me that in firewall environments
# Net::FTP can still succeed where LWP fails. So we do not
# skip Net::FTP anymore when LWP is available.
}
} else {
}
# that's the nice and easy way thanks to Graham
$dir =~ s|/+|/|g;
$url
");
$Thesite = $i;
return $aslocal;
}
my $gz = "$aslocal.gz";
");
$dir,
"$getfile.gz",
$gz) &&
){
$Thesite = $i;
return $aslocal;
}
}
# next HOSTEASY;
}
}
}
}
sub hosthard {
# Came back if Net::FTP couldn't establish connection (or
# failed otherwise) Maybe they are behind a firewall, but they
# gave us a socksified (or other) ftp program...
my($i);
# Courtesy Mark Conty mark_conty@cargill.com change from
# if ($url =~ m|^ftp://(.*?)/(.*)/(.*)|) {
# to
if ($url =~ m|^([^:]+)://(.*?)/(.*)/(.*)|) {
# proto not yet used
} else {
next HOSTHARD; # who said, we could ftp anything except ftp?
}
# success above. Likely a bogus URL
my($f,$funkyftp);
for $f ('lynx','ncftpget','ncftp','wget') {
next unless defined $funkyftp;
next if $funkyftp =~ /^\s*$/;
$asl_gz = "$asl_ungz.gz";
my($src_switch) = "";
if ($f eq "lynx"){
$src_switch = " -source";
} elsif ($f eq "ncftp"){
$src_switch = " -c";
} elsif ($f eq "wget"){
$src_switch = " -O -";
}
my($chdir) = "";
my($stdout_redir) = " > $asl_ungz";
if ($f eq "ncftpget"){
$chdir = "cd $aslocal_dir && ";
$stdout_redir = "";
}
qq[
$url
]);
my($system) =
"$chdir$funkyftp$src_switch \"$url\" $devnull$stdout_redir";
my($wstatus);
&&
($f eq "lynx" ?
-s $asl_ungz # lynx returns 0 when it fails somewhere
: 1
)
) {
if (-s $aslocal) {
# Looks good
# test gzip integrity
# e.g. foo.tar is gzipped --> foo.tar.gz
} else {
}
}
$Thesite = $i;
return $aslocal;
unlink $asl_ungz if
-f $asl_ungz && -s _ == 0;
my $gz = "$aslocal.gz";
my $gzurl = "$url.gz";
qq[
]);
my($system) = "$funkyftp$src_switch \"$url.gz\" $devnull > $asl_gz";
my($wstatus);
&&
-s $asl_gz
) {
# test gzip integrity
} else {
# somebody uncompressed file for us?
}
$Thesite = $i;
return $aslocal;
} else {
}
} else {
", left\n$aslocal with size ".-s _ :
"\nWarning: expected file [$aslocal] doesn't exist";
});
}
} # lynx,ncftpget,ncftp
} # host
}
sub hosthardest {
my($i);
last HOSTHARDEST;
}
next;
}
my $timestamp = 0;
my(@dialog);
push(
@dialog,
"lcd $aslocal_dir",
"cd /",
"bin",
"get $getfile $targetfile",
"quit"
);
if (! $netrcfile) {
$netrc->hasdefault,
$url
}
);
@dialog);
$mtime ||= 0;
$Thesite = $i;
return $aslocal;
} else {
}
} else {
}
} else {
}
# OK, they don't have a valid ~/.netrc. Use 'ftp -n'
# then and login manually to host, using e-mail as
# password.
unshift(
@dialog,
"open $host",
"user anonymous $Config::Config{'cf_email'}"
);
$mtime ||= 0;
$Thesite = $i;
return $aslocal;
} else {
}
sleep 2;
} # host
}
sub talk_ftp {
my $fh = FileHandle->new;
$fh->close; # Wait for process to complete
my $wstatus = $?;
Subprocess "|$command"
}) if $wstatus;
}
# find2perl needs modularization, too, all the following is stolen
# from there
# CPAN::FTP::ls
sub ls {
if ($blocks) {
}
else {
}
if (-f _) { $perms = '-'; }
elsif (-d _) { $perms = 'd'; }
elsif (-p _) { $perms = 'p'; }
elsif (-S _) { $perms = 's'; }
$tmpmode >>= 3;
$tmpmode >>= 3;
my($timeyear);
if (-M _ > 365.25 / 2) {
}
else {
}
sprintf "%5lu %4ld %-10s %2d %-8s %-8s %8s %s %2d %5s %s\n",
$ino,
$blocks,
$perms,
$nlink,
$user,
$group,
$sizemm,
$moname,
$mday,
$timeyear,
$pname;
}
sub new {
my($class) = @_;
= stat($file);
$mode ||= 0;
my $protected = 0;
$hasdefault = 0;
local($/) = "";
my(@tokens) = split " ", $_;
my($t) = shift @tokens;
if ($t eq "default"){
$hasdefault++;
last NETRC;
}
last TOKEN if $t eq "macdef";
if ($t eq "machine") {
}
}
}
} else {
}
bless {
'mach' => [@machines],
'netrc' => $file,
'hasdefault' => $hasdefault,
'protected' => $protected,
}, $class;
}
# CPAN::FTP::hasdefault;
sub contains {
for ( @{$self->{'mach'}} ) {
return 1 if $_ eq $mach;
}
return 0;
}
sub gnu_cpl {
# find longest common match. Can anybody show me how to peruse
# T::R::Gnu to have this done automatically? Seems expensive.
return () unless @perlret;
for (my $i = length($text)+1;;$i++) {
# warn "try[$try]tries[@tries]";
} else {
last;
}
}
}
#-> sub CPAN::Complete::cpl ;
sub cpl {
$word ||= "";
$line ||= "";
$pos ||= 0;
$line =~ s/^\s*//;
$pos -= length($1);
}
my @return;
if ($pos == 0) {
} elsif ( $line !~ /^[\!abcdghimorutl]/ ) {
@return = ();
} elsif ($line =~ /^b\s/) {
} elsif ($line =~ /^d\s/) {
} elsif ($line =~ m/^(
)\s/x ) {
}
} elsif ($line =~ /^i\s/) {
} elsif ($line =~ /^o\s/) {
} elsif ($line =~ m/^\S+\s/ ) {
# fallback for future commands and what we have forgotten above
} else {
@return = ();
}
return @return;
}
#-> sub CPAN::Complete::cplx ;
sub cplx {
# I believed for many years that this was sorted, today I
# realized, it wasn't sorted anymore. Now (rev 1.301 / v 1.55) I
# make it sorted again. Maybe sort was dropped when GNU-readline
# support came in? The RCS file is difficult to read on that:-(
}
#-> sub CPAN::Complete::cpl_any ;
sub cpl_any {
my($word) = shift;
return (
);
}
#-> sub CPAN::Complete::cpl_reload ;
sub cpl_reload {
$word ||= "";
}
#-> sub CPAN::Complete::cpl_option ;
sub cpl_option {
$word ||= "";
if (0) {
return ();
}
}
#-> sub CPAN::Index::force_reload ;
sub force_reload {
my($class) = @_;
}
#-> sub CPAN::Index::reload ;
sub reload {
my $time = time;
# XXX check if a newer one is available. (We currently read it
# from time to time)
$_ = 0.001 unless $_ && $_ > 0.001;
}
# debug here when CPAN doesn't seem to read the Metadata
require Carp;
}
}
# warn "Setting last_time to 0";
}
and ! $force;
if (0) {
# IFF we are developing, it helps to wipe out the memory
# between reloads, otherwise it is not what a user expects.
}
{
my $needshort = $^O eq "dos";
->reload_x(
"authors/01mailrc.txt.gz",
$needshort ?
$force));
$t2 = time;
->reload_x(
"modules/02packages.details.txt.gz",
$needshort ?
$force));
$t2 = time;
->reload_x(
"modules/03modlist.data.gz",
$needshort ?
$force));
$t2 = time;
}
}
#-> sub CPAN::Index::reload_x ;
sub reload_x {
# on Config XXX
$localname);
if (
-f $abs_wanted &&
!($force & 1)
) {
qq{day$s. I\'ll use that.});
return $abs_wanted;
} else {
}
}
#-> sub CPAN::Index::rd_authindex ;
sub rd_authindex {
my($cl, $index_target) = @_;
my @lines;
return unless defined $index_target;
local(*FH);
local($/) = "\n";
foreach (@lines) {
m/alias\s+(\S+)\s+\"([^\"\<]+)\s+\<([^\>]+)\>\"/;
# instantiate an author object
}
}
sub userid {
$ret;
}
#-> sub CPAN::Index::rd_modpacks ;
sub rd_modpacks {
my($self, $index_target) = @_;
my @lines;
return unless defined $index_target;
local($/) = "\n";
s/\012/\n/g;
my @ls = map {"$_\n"} split /\n/, $_;
}
# read header
my($line_count,$last_updated);
while (@lines) {
last if $shift =~ /^\s*$/;
}
if (not defined $line_count) {
happen.\a
};
sleep 5;
} elsif ($line_count != scalar @lines) {
}
if (not defined $last_updated) {
happen.\a
};
sleep 5;
} else {
$last_updated);
$DATE_OF_02 = $last_updated;
if ($age > 30) {
->mywarn(sprintf
I'll continue but problems seem likely to happen.\a\n},
$age);
}
} else {
}
}
# A necessity since we have metadata_cache: delete what isn't
# there anymore
my(%exists);
foreach (@lines) {
chomp;
# before 1.56 we split into 3 and discarded the rest. From
# 1.57 we assign remaining text to $comment thus allowing to
# influence isa_perl
if ($mod eq 'CPAN' &&
! (
)
) {
local($^W)= 0;
}); #});
sleep 2;
}
$bundle = $1;
}
if ($bundle){
# Let's make it a module too, because bundles have so much
# in common with modules.
# Changed in 1.57_63: seems like memory bloat now without
# any value, so commented out
# $CPAN::META->instance('CPAN::Module',$mod);
} else {
# instantiate a module object
}
# different. CPAN prohibits same
# name with different version
'CPAN_USERID' => $userid,
'CPAN_VERSION' => $version,
'CPAN_FILE' => $dist,
);
}
# instantiate a distribution object
# we do not need CONTAINSMODS unless we do something with
# this dist, so we better produce it on demand.
## my $obj = $CPAN::META->instance(
## 'CPAN::Distribution' => $dist
## );
## $obj->{CONTAINSMODS}{$mod} = undef; # experimental
} else {
'CPAN::Distribution' => $dist
)->set(
'CPAN_USERID' => $userid,
'CPAN_COMMENT' => $comment,
);
}
if ($secondtime) {
}
}
}
undef $fh;
if ($secondtime) {
}
}
}
}
#-> sub CPAN::Index::rd_modlist ;
sub rd_modlist {
my($cl,$index_target) = @_;
return unless defined $index_target;
my @eval;
local($/) = "\n";
s/\012/\n/g;
my @ls = map {"$_\n"} split /\n/, $_;
}
while (@eval) {
return if $DATE_OF_03 eq $1;
($DATE_OF_03) = $1;
}
last if $shift =~ /^\s*$/;
}
undef $fh;
local($^W) = 0;
Carp::confess($@) if $@;
for (keys %$ret) {
}
}
#-> sub CPAN::Index::write_metadata_cache ;
sub write_metadata_cache {
my($self) = @_;
my $cache;
CPAN::Distribution)) {
}
}
#-> sub CPAN::Index::read_metadata_cache ;
sub read_metadata_cache {
my($self) = @_;
return unless -r $metadata_file and -f $metadata_file;
my $cache;
$LAST_TIME = 0;
return;
}
"with protocol v%s, requiring v%s\n",
);
return;
}
} else {
"with protocol v1.0\n");
return;
}
my $clcnt = 0;
my $idcnt = 0;
$idcnt++;
}
$clcnt++;
}
unless ($clcnt) { # sanity check
return;
}
if ($idcnt < 1000) {
"in $metadata_file\n");
return;
}
# does initialize to some protocol
if defined $DATE_OF_02; # An old cache may not contain DATE_OF_02
return;
}
# Accessors
sub cpan_userid {
my $self = shift;
}
#-> sub CPAN::InfoObj::new ;
sub new {
my $this = bless {}, shift;
%$this = @_;
$this
}
# The set method may only be used by code that reads index data or
# otherwise "objective" data from the outside world. All session
# related material may do anything else with instance variables but
# must not touch the hash under the RO attribute. The reason is that
# the RO hash gets written to Metadata file and is thus persistent.
#-> sub CPAN::InfoObj::set ;
sub set {
# This must be ||=, not ||, because only if we write an empty
# reference, only then the set method will write into the readonly
# area. But for Distributions that spring into existence, maybe
# because of a typo, we do not like it that they are written into
# the readonly area and made permanent (at least for a while) and
# that is why we do not "allow" other places to call ->set.
return;
}
while (my($k,$v) = each %att) {
$ro->{$k} = $v;
}
}
#-> sub CPAN::InfoObj::as_glimpse ;
sub as_glimpse {
my($self) = @_;
my(@m);
join "", @m;
}
#-> sub CPAN::InfoObj::as_string ;
sub as_string {
my($self) = @_;
my(@m);
push @m, $class, " id = $self->{ID}\n";
# next if m/^(ID|RO)$/;
my $extra = "";
if ($_ eq "CPAN_USERID") {
my $email; # old perls!
)->email) {
$extra .= " <$email>";
} else {
$extra .= " <no email>";
}
$extra .= ")";
} elsif ($_ eq "FULLNAME") { # potential UTF-8 conversion
next;
}
}
for (sort keys %$self) {
if (ref($self->{$_}) eq "ARRAY") {
push @m, sprintf " %-12s %s\n", $_, "@{$self->{$_}}";
} elsif (ref($self->{$_}) eq "HASH") {
push @m, sprintf(
" %-12s %s\n",
$_,
join(" ",keys %{$self->{$_}}),
);
} else {
push @m, sprintf " %-12s %s\n", $_, $self->{$_};
}
}
join "", @m, "\n";
}
#-> sub CPAN::InfoObj::author ;
sub author {
my($self) = @_;
}
#-> sub CPAN::InfoObj::dump ;
sub dump {
my($self) = @_;
}
#-> sub CPAN::Author::id
sub id {
my $self = shift;
$id;
}
#-> sub CPAN::Author::as_glimpse ;
sub as_glimpse {
my($self) = @_;
my(@m);
push @m, sprintf(qq{%-15s %s ("%s" <%s>)\n},
$class,
join "", @m;
}
#-> sub CPAN::Author::fullname ;
sub fullname {
}
#-> sub CPAN::Author::email ;
#-> sub CPAN::Author::ls ;
sub ls {
my $self = shift;
# adapted from CPAN::Distribution::verifyMD5 ;
my(@csf); # chksumfile
my(@dl);
return;
}
return;
}
}
# returns an array of arrays, the latter contain (size,mtime,filename)
#-> sub CPAN::Author::dir_listing ;
sub dir_listing {
my $self = shift;
my $chksumfile = shift;
my $recursive = shift;
my $lc_want =
local($") = "/";
# connect "force" argument with "index_expire".
my $force = 0;
}
unless ($lc_file) {
"$lc_want.gz",1);
if ($lc_file) {
} else {
return;
}
}
# adapted from CPAN::Distribution::MD5_check_file ;
my $fh = FileHandle->new;
my($cksum);
local($/);
close $fh;
if ($@) {
rename $lc_file, "$lc_file.bad";
Carp::confess($@) if $@;
}
} else {
Carp::carp "Could not open $lc_file for reading";
}
my(@result,$f);
for $f (sort keys %$cksum) {
if ($recursive) {
my(@dir) = @$chksumfile;
pop @dir;
push @dir, $f, "CHECKSUMS";
push @result, map {
[$_->[0], $_->[1], "$f/$_->[2]"]
} else {
}
} else {
push @result, [
$f
];
}
}
@result;
}
package CPAN::Distribution;
# Accessors
sub undelay {
my $self = shift;
}
# CPAN::Distribution::normalize
sub normalize {
my($self,$s) = @_;
if (
$s =~ tr|/|| == 1
or
$s !~ m|[A-Z]/[A-Z-]{2}/[A-Z-]{2,}/|
) {
$s =~ s|^(.)(.)([^/]*/)(.+)$|$1/$1$2/$1$2$3$4| or
}
$s;
}
#-> sub CPAN::Distribution::color_cmd_tmps ;
sub color_cmd_tmps {
my($self) = shift;
my($depth) = shift || 0;
my($color) = shift || 0;
my($ancestors) = shift || [];
# a distribution needs to recurse into its prereq_pms
return if exists $self->{incommandcolor}
if ($depth>=100){
}
# warn "color_cmd_tmps $depth $color " . $self->id; # sleep 1;
if (defined $prereq_pm) {
}
}
if ($color==0) {
delete $self->{sponsored_mods};
delete $self->{badtestcnt};
}
}
#-> sub CPAN::Distribution::as_string ;
sub as_string {
my $self = shift;
$self->containsmods;
}
#-> sub CPAN::Distribution::containsmods ;
sub containsmods {
my $self = shift;
# warn "mod_file[$mod_file] dist_id[$dist_id] mod_id[$mod_id]";
# sleep 1;
}
keys %{$self->{CONTAINSMODS}};
}
#-> sub CPAN::Distribution::uptodate ;
sub uptodate {
my($self) = @_;
my $c;
foreach $c ($self->containsmods) {
}
return 1;
}
#-> sub CPAN::Distribution::called_for ;
sub called_for {
return $self->{CALLED_FOR};
}
#-> sub CPAN::Distribution::safe_chdir ;
sub safe_chdir {
# we die if we cannot chdir and we are debuggable
Carp::confess("safe_chdir called without todir argument")
if (chdir $todir) {
} else {
}
}
#-> sub CPAN::Distribution::get ;
sub get {
my($self) = @_;
EXCUSE: {
my @e;
exists $self->{'build_dir'} and push @e,
"Is already unwrapped into directory $self->{'build_dir'}";
}
#
# Get the file on local disk
#
my($local_file);
my($local_wanted) =
"authors",
"id",
);
unless ($local_file =
$local_wanted)) {
my $note = "";
$note = "Note: Current database in memory was generated ".
"on $CPAN::Index::DATE_OF_02\n";
}
}
#
# Check integrity
#
} else {
}
#
# Create a clean room and go there
#
return;
}
#
# Unpack the goods
#
} elsif ( $local_file =~ /\.zip(?!\n)\Z/i ) {
} else {
return;
}
# we are still in the tmp directory!
# Let's check if the package has its own directory.
or Carp::croak("Couldn't opendir .: $!");
$dh->close;
my ($distdir,$packagedir);
"$packagedir\n");
rename($distdir,$packagedir) or
Carp::confess("Couldn't rename $distdir to $packagedir: $!");
$distdir,
-e $packagedir,
-d $packagedir,
} else {
unless ($userid) {
$userid = "anon";
}
$pragmatic_dir =~ s/\W_//g;
$pragmatic_dir++ while -d "../$pragmatic_dir";
my($f);
for $f (@readdir) { # is already without "." and ".."
}
}
return;
}
my($mpl_exists) = -f $mpl;
unless ($mpl_exists) {
# NFS has been reported to have racing problems after the
# renaming of a directory in some environments.
# This trick helps.
sleep 1;
or Carp::croak("Couldn't opendir $packagedir: $!");
$mpldh->close;
}
unless ($mpl_exists) {
$mpl,
if (-f $configure) {
# do we have anything to do?
We\'ll try to build it with that Makefile then.
});
sleep 2;
} else {
if ($cf =~ m|/|) {
$cf =~ s|.*/||;
$cf =~ s|\W.*||;
}
$cf =~ s|[/\\:]||g; # risk of filesystem damage
$self->{had_no_makefile_pl}++;
sleep 3;
# Writing our own Makefile.PL
my $fh = FileHandle->new;
$fh->open(">$mpl")
or Carp::croak("Could not open >$mpl: $!");
$fh->print(
qq{# This Makefile.PL has been autogenerated by the module CPAN.pm
# because there was no Makefile.PL supplied.
# Autogenerated on: }.scalar localtime().qq{
});
$fh->close;
}
}
return $self;
}
# CPAN::Distribution::untar_me ;
sub untar_me {
my($self,$local_file) = @_;
} else {
}
}
# CPAN::Distribution::unzip_me ;
sub unzip_me {
my($self,$local_file) = @_;
} else {
}
return;
}
sub pm2dir_me {
my($self,$local_file) = @_;
} else {
}
}
#-> sub CPAN::Distribution::new ;
sub new {
# $CPAN::META->{cachemgr} ||= CPAN::CacheMgr->new();
}
#-> sub CPAN::Distribution::look ;
sub look {
my($self) = @_;
if ($^O eq 'MacOS') {
return;
}
});
} else {
});
return;
}
my $dir;
}
});
return;
}
my $code = $? >> 8;
}
}
# CPAN::Distribution::cvs_import ;
sub cvs_import {
my($self) = @_;
$cvs_dir =~ s/-\d+[^-]+(?!\n)\Z//;
my $cvs_root =
my $cvs_site_perl =
if ($cvs_site_perl) {
$cvs_dir = "$cvs_site_perl/$cvs_dir";
}
my $cvs_log = qq{"imported $package $version sources"};
$version =~ s/\./_/g;
system(@cmd) == 0 or
}
#-> sub CPAN::Distribution::readme ;
sub readme {
my($self) = @_;
my($local_file);
my($local_wanted) =
"authors",
"id",
split(/\//,"$sans.readme"),
);
if ($^O eq 'MacOS') {
return;
}
my $fh_pager = FileHandle->new;
$fh_pager->open("|$CPAN::Config->{'pager'}")
or die "Could not open pager $CPAN::Config->{'pager'}: $!";
my $fh_readme = FileHandle->new;
$fh_readme->open($local_file)
});
sleep 2;
}
#-> sub CPAN::Distribution::verifyMD5 ;
sub verifyMD5 {
my($self) = @_;
EXCUSE: {
my @e;
}
pop @local;
push @local, "CHECKSUMS";
$lc_want =
local($") = "/";
if (
-s $lc_want
&&
) {
}
$lc_want,1);
unless ($lc_file) {
"$lc_want.gz",1);
if ($lc_file) {
} else {
return;
}
}
}
#-> sub CPAN::Distribution::MD5_check_file ;
sub MD5_check_file {
my $fh = FileHandle->new;
local($/);
close $fh;
if ($@) {
rename $chk_file, "$chk_file.bad";
Carp::confess($@) if $@;
}
} else {
Carp::carp "Could not open $chk_file for reading";
}
binmode $fh;
$fh->close;
unless ($eq) {
# had to inline it, when I tied it, the tiedness got lost on
# the call to eq_MD5. (Jan 1998)
}
}
if ($eq) {
} else {
qq{distribution file. }.
qq{Please investigate.\n\n}.
'CPAN::Author',
)->as_string);
my $wrap = qq{I\'d recommend removing $file. Its MD5
retry.};
# former versions just returned here but this seems a
# serious threat that deserves a die
# $CPAN::Frontend->myprint("\n\n");
# sleep 3;
# return;
}
# close $fh if fileno($fh);
} else {
});
}
return;
}
}
#-> sub CPAN::Distribution::eq_MD5 ;
sub eq_MD5 {
my($data);
}
# $md5->addfile($fh);
# warn "fh[$fh] hex[$hexdigest] aexp[$expectMD5]";
}
#-> sub CPAN::Distribution::force ;
# Both modules and distributions know if "force" is in effect by
# autoinspection, not by inspecting a global variable. One of the
# reason why this was chosen to work that way was the treatment of
# dependencies. They should not autpomatically inherit the force
# status. But this has the downside that ^C and die() will return to
# the prompt but will not be able to reset the force_update
# attributes. We try to correct for it currently in the read_metadata
# routine, and immediately before we check for a Signal. I hope this
# works out in one of v1.57_53ff
sub force {
for my $att (qw(
)) {
}
}
}
#-> sub CPAN::Distribution::unforce ;
sub unforce {
my($self) = @_;
delete $self->{'force_update'};
}
#-> sub CPAN::Distribution::isa_perl ;
sub isa_perl {
my($self) = @_;
-?
(5)
([._-])
(
\d{3}(_[0-4][0-9])?
|
\d*[24680]\.\d+
)
(?!\n)\Z
}xs){
return "$1.$3";
} elsif ($self->cpan_comment
&&
return $1;
}
}
#-> sub CPAN::Distribution::perl ;
sub perl {
my($self) = @_;
unless ($perl) {
last DIST_PERLNAME;
}
}
}
}
$perl;
}
#-> sub CPAN::Distribution::make ;
sub make {
my($self) = @_;
# Emergency brake if they said install Pippi and get newest perl
if (
! $self->{force_update}
) {
# if we die here, we break bundles
I\'ll build that only if you ask for something like
or
install %s
},
'CPAN::Module',
)->cpan_version,
$self->called_for,
$self->called_for,
sleep 5; return;
}
}
EXCUSE: {
my @e;
"Is neither a tar nor a zip archive.";
"had problems unarchiving. Please build manually";
exists $self->{writemakefile} &&
$1 || "Had some problem writing Makefile";
defined $self->{'make'} and push @e,
"Has already been processed within this session";
}
if ($^O eq 'MacOS') {
return;
}
my $system;
if ($self->{'configure'}) {
} else {
my $switch = "";
# This needs a handler that can be turned on or off:
# $switch = "-MExtUtils::MakeMaker ".
# "-Mops=:default,:filesys_read,:filesys_open,require,chdir"
# if $] > 5.00310;
$system = "$perl $switch Makefile.PL $CPAN::Config->{makepl_arg}";
}
unless (exists $self->{writemakefile}) {
$@ = "";
eval {
if (defined($pid = fork)) {
if ($pid) { #parent
# wait;
waitpid $pid, 0;
} else { #child
# note, this exec isn't necessary if
# inactivity_timeout is 0. On the Mac I'd
# suggest, we set it always to 0.
exec $system;
}
} else {
return;
}
};
alarm 0;
if ($@){
kill 9, $pid;
waitpid $pid, 0;
$@ = "";
return;
}
} else {
if ($ret != 0) {
return;
}
}
if (-f "Makefile") {
} else {
$self->{writemakefile} =
# It's probably worth it to record the reason, so let's retry
# local $/;
# my $fh = IO::File->new("$system |"); # STDERR? STDIN?
# $self->{writemakefile} .= <$fh>;
}
}
delete $self->{force_update};
return;
}
}
if (system($system) == 0) {
} else {
}
}
sub follow_prereqs {
my($self) = shift;
my(@prereq) = @_;
"during [$id] -----\n");
for my $p (@prereq) {
}
my $follow = 0;
$follow = 1;
"Shall I follow them and prepend them to the queue
} else {
local($") = ", ";
myprint(" Ignoring dependencies on modules @prereq\n");
}
if ($follow) {
# color them as dirty
for my $p (@prereq) {
# warn "calling color_cmd_tmps(0,1)";
}
return 1; # signal success to the queuerunner
}
}
#-> sub CPAN::Distribution::unsat_prereq ;
sub unsat_prereq {
my($self) = @_;
my(@need);
# we were too demanding:
# if they have not specified a version, we accept any installed one
if (not defined $need_version or
$need_version == 0 or
$need_version eq "undef") {
}
# We only want to install prereqs if either they're not installed
# or if the installed version is too old. We cannot omit this
# check, because if 'force' is in effect, nobody else will check.
{
local($^W) = 0;
if (
){
$nmo->inst_version,
);
next NEED;
}
}
# We have already sponsored it and for some reason it's still
# not available. So we do nothing. Or what should we do?
# if we push it again, we have a potential infinite loop
next;
}
push @need, $need_module;
}
@need;
}
#-> sub CPAN::Distribution::prereq_pm ;
sub prereq_pm {
my($self) = @_;
# but we must have run it
my(%p) = ();
my $fh;
if (-f $makefile
and
local($/) = "\n";
# A.Speer @p -> %p, where %p is $p{Module::Name}=Required_Version
while (<$fh>) {
my($p) = m{^[\#]
\s+PREREQ_PM\s+=>\s+(.+)
}x;
next unless $p;
# warn "Found prereq expr[$p]";
# Regexp modified by A.Speer to remember actual version of file
# PREREQ_PM hash key wants, then add to
while ( $p =~ m/(?:\s)([\w\:]+)=>q\[(.*?)\],?/g ){
# In case a prereq is mentioned twice, complain.
if ( defined $p{$1} ) {
warn "Warning: PREREQ_PM mentions $1 more than once, last mention wins";
}
$p{$1} = $2;
}
last;
}
}
$self->{prereq_pm_detected}++;
}
#-> sub CPAN::Distribution::test ;
sub test {
my($self) = @_;
delete $self->{force_update};
return;
}
}
EXCUSE: {
my @e;
"Make had some problems, maybe interrupted? Won't test";
exists $self->{'make'} and
push @e, "Can't test without successful make";
push @e, "Won't repeat unsuccessful test during this command";
}
chdir $self->{'build_dir'} or
Carp::croak("Couldn't chdir to $self->{'build_dir'}");
if ($^O eq 'MacOS') {
return;
}
if (system($system) == 0) {
} else {
$self->{badtestcnt}++;
}
}
#-> sub CPAN::Distribution::clean ;
sub clean {
my($self) = @_;
EXCUSE: {
my @e;
push @e, "make clean already called once";
}
chdir $self->{'build_dir'} or
Carp::croak("Couldn't chdir to $self->{'build_dir'}");
if ($^O eq 'MacOS') {
return;
}
if (system($system) == 0) {
# $self->force;
# Jost Krieger pointed out that this "force" was wrong because
# it has the effect that the next "install" on this distribution
# will untar everything again. Instead we should bring the
# object's state back to where it is after untarring.
delete $self->{force_update};
delete $self->{writemakefile};
} else {
# Hmmm, what to do if make clean failed?
});
}
}
#-> sub CPAN::Distribution::install ;
sub install {
my($self) = @_;
delete $self->{force_update};
return;
}
EXCUSE: {
my @e;
"Make had some problems, maybe interrupted? Won't install";
exists $self->{'make'} and
push @e, "make had returned bad status, install seems impossible";
push @e, "make test had returned bad status, ".
"won't install without force"
if exists $self->{'make_test'} and
! $self->{'force_update'};
exists $self->{'install'} and push @e,
"Already done" : "Already tried without success";
}
chdir $self->{'build_dir'} or
Carp::croak("Couldn't chdir to $self->{'build_dir'}");
if ($^O eq 'MacOS') {
return;
}
my($makeout) = "";
while (<$pipe>){
$makeout .= $_;
}
$pipe->close;
if ($?==0) {
} else {
}
}
delete $self->{force_update};
}
#-> sub CPAN::Distribution::dir ;
sub dir {
shift->{'build_dir'};
}
sub look {
my $self = shift;
}
sub undelay {
my $self = shift;
}
}
#-> sub CPAN::Bundle::color_cmd_tmps ;
sub color_cmd_tmps {
my($self) = shift;
my($depth) = shift || 0;
my($color) = shift || 0;
my($ancestors) = shift || [];
# a module needs to recurse to its cpan_file, a distribution needs
# to recurse into its prereq_pms, a bundle needs to recurse into its modules
return if exists $self->{incommandcolor}
if ($depth>=100){
}
# warn "color_cmd_tmps $depth $color " . $self->id; # sleep 1;
}
if ($color==0) {
delete $self->{badtestcnt};
}
}
#-> sub CPAN::Bundle::as_string ;
sub as_string {
my($self) = @_;
# following line must be "=", not "||=" because we have a moving target
}
#-> sub CPAN::Bundle::contains ;
sub contains {
my($self) = @_;
unless ($inst_file) {
# Try to get at it in the cpan directory
my $cpan_file;
if ($cpan_file eq "N/A") {
}
or Carp::confess("Couldn't copy $from to $to: $!");
}
my @result;
my $fh = FileHandle->new;
local $/ = "\n";
my $in_cont = 0;
while (<$fh>) {
next unless $in_cont;
next if /^=/;
s/\#.*//;
next if /^\s+$/;
chomp;
}
close $fh;
unless (@result) {
});
}
@result;
}
#-> sub CPAN::Bundle::find_bundle_file
sub find_bundle_file {
### my $bu = File::Spec->catfile($where,$what);
### return $bu if -f $bu;
unless (-f $manifest) {
}
or Carp::croak("Couldn't open $manifest: $!");
local($/) = "\n";
if ($^O eq 'MacOS') {
$what =~ s/^://;
$what =~ tr|:|/|;
$what2 =~ tr|:|/|;
} else {
}
my $bu;
while (<$fh>) {
next if /^\s*\#/;
my($file) = /(\S+)/;
# return File::Spec->catfile($where,$bu); # bad
last;
}
# retry if she managed to
# have no Bundle directory
}
$bu =~ tr|/|:| if $^O eq 'MacOS';
Carp::croak("Couldn't find a Bundle file in $where");
}
# needs to work quite differently from Module::inst_file because of
# shadowing effect. As it makes no sense to take the first in @INC for
# Bundles, we parse them all for $VERSION and take the newest.
#-> sub CPAN::Bundle::inst_file ;
sub inst_file {
my($self) = @_;
my($inst_file);
my(@me);
next unless -f $bfile;
}
}
}
#-> sub CPAN::Bundle::inst_version ;
sub inst_version {
my($self) = @_;
$self->{INST_VERSION};
}
#-> sub CPAN::Bundle::rematein ;
sub rematein {
Carp::croak "Can't $meth $id, don't have an associated bundle file. :-(\n"
my($s,%fail);
my($type) = $s =~ m|/| ? 'CPAN::Distribution' :
if ($type eq 'CPAN::Distribution') {
explicitly a file $s.
});
sleep 3;
}
# possibly noisy action:
&&
exists $obj->{install_failed}
&&
) {
for (keys %{$obj->{install_failed}}) {
# to me in a
# recursive call
# not all children
}
} else {
my $success;
if ($success) {
delete $self->{install_failed}{$s};
} else {
$fail{$s} = 1;
}
}
}
# recap with less noise
if ( $meth eq "install" ) {
if (%fail) {
);
my $paragraph = "";
my %reported;
if ($fail{$s}){
$paragraph .= "$s ";
$self->{install_failed}{$s} = undef;
$reported{$s} = undef;
}
}
my $report_propagated;
for $s (sort keys %{$self->{install_failed}}) {
next if exists $reported{$s};
$paragraph .= "and the following items had problems
$paragraph .= "$s ";
}
} else {
}
}
}
#sub CPAN::Bundle::xs_file
sub xs_file {
# If a bundle contains another that contains an xs_file we have
# here, we just don't bother I suppose
return 0;
}
#-> sub CPAN::Bundle::force ;
#-> sub CPAN::Bundle::get ;
#-> sub CPAN::Bundle::make ;
#-> sub CPAN::Bundle::test ;
sub test {
my $self = shift;
}
#-> sub CPAN::Bundle::install ;
sub install {
my $self = shift;
}
#-> sub CPAN::Bundle::clean ;
#-> sub CPAN::Bundle::uptodate ;
sub uptodate {
my($self) = @_;
my $c;
}
return 1;
}
#-> sub CPAN::Bundle::readme ;
sub readme {
my($self) = @_;
}
# Accessors
# sub CPAN::Module::userid
sub userid {
my $self = shift;
}
# sub CPAN::Module::description
sub undelay {
my $self = shift;
}
}
#-> sub CPAN::Module::color_cmd_tmps ;
sub color_cmd_tmps {
my($self) = shift;
my($depth) = shift || 0;
my($color) = shift || 0;
my($ancestors) = shift || [];
# a module needs to recurse to its cpan_file
return if exists $self->{incommandcolor}
if ($depth>=100){
}
# warn "color_cmd_tmps $depth $color " . $self->id; # sleep 1;
}
if ($color==0) {
delete $self->{badtestcnt};
}
}
#-> sub CPAN::Module::as_glimpse ;
sub as_glimpse {
my($self) = @_;
my(@m);
my $color_on = "";
my $color_off = "";
if (
&&
&&
) {
}
push @m, sprintf("%-15s %s%-15s%s (%s)\n",
$class,
$color_on,
join "", @m;
}
#-> sub CPAN::Module::as_string ;
sub as_string {
my($self) = @_;
my(@m);
local($^W) = 0;
push @m, $class, " id = $self->{ID}\n";
my $sprintf = " %-12s %s\n";
if $self->description;
my $sprintf2 = " %-12s %s (%s)\n";
my($userid);
if ( $userid ){
my $author;
my $email = "";
my $m; # old perls
$email = " <$m>";
}
push @m, sprintf(
$sprintf2,
'CPAN_USERID',
$userid,
);
}
}
if $self->cpan_version;
my $sprintf3 = " %-12s %1s%1s%1s%1s (%s,%s,%s,%s)\n";
push @m, sprintf(
$sprintf3,
'DSLI_STATUS',
if ($local_file) {
} else {
# If we have already untarred it, we should look there
# warn "dist[$dist]";
# mff=manifest file; mfh=manifest handle
if (
and
and
) {
$lfre =~ s/::/./g;
$lfre .= "\\.pm\$";
my($lfl); # local file file
local $/ = "\n";
for (@mflines) {
s/^\s+//;
s/\s.*//s;
}
$lfre =~ s/.+?\.//;
}
$lfl =~ s/\s.*//; # remove comments
$lfl =~ s/\s+//g; # chomp would maybe be too system-specific
# warn "lfl_abs[$lfl_abs]";
if (-f $lfl_abs) {
}
}
}
}
my($item);
}
}
push @m, sprintf($sprintf, 'INST_FILE',
$local_file || "(not installed)");
push @m, sprintf($sprintf, 'INST_VERSION',
join "", @m, "\n";
}
sub manpage_headline {
my($self,$local_file) = @_;
my(@local_file) = $local_file;
push @local_file, $local_file;
for $locf (@local_file) {
next unless -f $locf;
my $inpod = 0;
local $/ = "\n";
while (<$fh>) {
next unless $inpod;
next if /^=/;
next if /^\s+$/;
chomp;
push @result, $_;
}
close $fh;
last if @result;
}
join " ", @result;
}
#-> sub CPAN::Module::cpan_file ;
# Note: also inherited by CPAN::Bundle
sub cpan_file {
my $self = shift;
}
} else {
if ( $userid ) {
$userid);
return sprintf("Contact Author %s",
$userid,
);
}
return "Contact Author $fullname <$email>";
} else {
return "Contact Author $userid (Email address not available)";
}
} else {
return "N/A";
}
}
}
#-> sub CPAN::Module::cpan_version ;
sub cpan_version {
my $self = shift;
# I believe this is always a bug in the index and should be reported
# as such, but usually I find out such an error and do not want to
# provoke too many bugreports
}
#-> sub CPAN::Module::force ;
sub force {
my($self) = @_;
$self->{'force_update'}++;
}
#-> sub CPAN::Module::rematein ;
sub rematein {
$meth,
},
);
return;
}
delete $self->{'force_update'};
}
#-> sub CPAN::Module::readme ;
#-> sub CPAN::Module::look ;
#-> sub CPAN::Module::cvs_import ;
#-> sub CPAN::Module::get ;
#-> sub CPAN::Module::make ;
sub make {
my $self = shift;
}
#-> sub CPAN::Module::test ;
sub test {
my $self = shift;
}
#-> sub CPAN::Module::uptodate ;
sub uptodate {
my($self) = @_;
$latest ||= 0;
my($have) = 0;
if (defined $inst_file) {
}
local($^W)=0;
if ($inst_file
&&
) {
return 1;
}
return;
}
#-> sub CPAN::Module::install ;
sub install {
my($self) = @_;
my($doit) = 0;
&&
not exists $self->{'force_update'}
) {
} else {
$doit = 1;
}
\n\n\n ***WARNING***
});
sleep 5;
}
}
#-> sub CPAN::Module::clean ;
#-> sub CPAN::Module::inst_file ;
sub inst_file {
my($self) = @_;
if (-f $pmfile){
return $pmfile;
}
}
return;
}
#-> sub CPAN::Module::xs_file ;
sub xs_file {
my($self) = @_;
if (-f $xsfile){
return $xsfile;
}
}
return;
}
#-> sub CPAN::Module::inst_version ;
sub inst_version {
my($self) = @_;
my $have;
# there was a bug in 5.6.0 that let lots of unini warnings out of
# parse_version. Fixed shortly after 5.6.0 by PMQS. We can remove
# the following workaround after 5.6.1 is out.
return if $w =~ /uninitialized/i;
warn $w;
};
$have =~ s/^ //; # since the %vd hack these two lines here are needed
$have =~ s/ $//; # trailing whitespace happens all the time
# My thoughts about why %vd processing should happen here
# Alt1 maintain it as string with leading v:
# read index files do nothing
# compare it use utility for compare
# print it do nothing
# Alt2 maintain it as what it is
# read index files convert
# compare it use utility because there's still a ">" vs "gt" issue
# print it use CPAN::Version for print
# Seems cleaner to hold it in memory as a string starting with a "v"
# If the author of this module made a mistake and wrote a quoted
# "v1.13" instead of v1.13, we simply leave it at that with the
# effect that *we* will treat it like a v-tring while the rest of
# perl won't. Seems sensible when we consider that any action we
# could take now would just add complexity.
$have =~ s/\s*//g; # stringify to float around floating point issues
$have; # no stringify needed, \s* above matches always
}
# CPAN::Tarzip::gzip
sub gzip {
$fhw->close;
return 1;
} else {
system("$CPAN::Config->{gzip} -c $read > $write")==0;
}
}
# CPAN::Tarzip::gunzip
sub gunzip {
$fhw->close;
return 1;
} else {
system("$CPAN::Config->{gzip} -dc $read > $write")==0;
}
}
# CPAN::Tarzip::gtest
sub gtest {
# After I had reread the documentation in zlib.h, I discovered that
# uncompressed files do not lead to an gzerror (anymore?).
$len = 0;
$read,
$buffer = "";
}
$success = 0;
}
return $success;
} else {
return system("$CPAN::Config->{gzip} -dt $read")==0;
}
}
# CPAN::Tarzip::TIEHANDLE
sub TIEHANDLE {
my $ret;
die "Could not gzopen $file";
} else {
my $pipe = "$CPAN::Config->{gzip} --decompress --stdout $file |";
binmode $fh;
}
$ret;
}
# CPAN::Tarzip::READLINE
sub READLINE {
my($self) = @_;
return undef if $bytesread <= 0;
return $line;
} else {
return scalar <$fh>;
}
}
# CPAN::Tarzip::READ
sub READ {
die "read with offset not implemented" if defined $offset;
return $byteread;
} else {
}
}
# CPAN::Tarzip::DESTROY
sub DESTROY {
my($self) = @_;
# to be undef ever. AK, 2000-09
} else {
}
undef $self;
}
# CPAN::Tarzip::untar
sub untar {
my($prefer) = 0;
if (0) { # makes changing order easier
} elsif ($BUGHUNTING){
$prefer=2;
&&
# should be default until Archive::Tar is fixed
$prefer = 1;
} elsif (
&&
$prefer = 2;
} else {
});
}
my($system);
if ($is_compressed) {
$system = "$CPAN::Config->{gzip} --decompress --stdout " .
"< $file | $CPAN::Config->{tar} xvf -";
} else {
$system = "$CPAN::Config->{tar} xvf $file";
}
if (system($system) != 0) {
# people find the most curious tar binaries that cannot handle
# pipes
if ($is_compressed) {
} else {
}
}
$system = "$CPAN::Config->{tar} xvf $file";
if (system($system)==0) {
} else {
}
return 1;
} else {
return 1;
}
my $af; # archive file
my @af;
if ($BUGHUNTING) {
# RCS 1.337 had this code, it turned out unacceptable slow but
# it revealed a bug in Archive::Tar. Code is only here to hunt
# the bug again. It should never be enabled in published code.
# GDGraph3d-0.53 was an interesting case according to Larry
# Virden.
warn(">>>Bughunting code enabled<<< " x 20);
if ($af =~ m!^(/|\.\./)!) {
"illegal member [$af]");
}
}
} else {
if ($af =~ m!^(/|\.\./)!) {
"illegal member [$af]");
}
}
}
if ($^O eq 'MacOS');
return 1;
}
}
sub unzip {
# blueprint of the code from Archive::Zip::Tree::extractTree();
my $status;
if ($af =~ m!^(/|\.\./)!) {
"illegal member [$af]");
}
die "Extracting of file[$af] from zipfile[$file] failed\n" if
}
return 1;
} else {
return system(@system) == 0;
}
}
# CPAN::Version::vcmp courtesy Jost Krieger
sub vcmp {
my($self,$l,$r) = @_;
local($^W) = 0;
return 0 if $l eq $r; # short circuit for quicker success
if ($l=~/^v/ <=> $r=~/^v/) {
for ($l,$r) {
next if /^v/;
}
}
return
($l ne "undef") <=> ($r ne "undef") ||
($] >= 5.006 &&
$l =~ /^v/ &&
$r =~ /^v/ &&
$l <=> $r ||
$l cmp $r;
}
sub vgt {
my($self,$l,$r) = @_;
}
sub vstring {
my($self,$n) = @_;
$n =~ s/^v// or die "CPAN::Version::vstring() called with invalid arg [$n]";
pack "U*", split /\./, $n;
}
# vv => visible vstring
sub float2vv {
my($self,$n) = @_;
my($rev) = int($n);
$rev ||= 0;
# architecture influence
$mantissa ||= 0;
while ($mantissa) {
die "Panic: length>0 but not a digit? mantissa[$mantissa]";
}
# warn "n[$n]ret[$ret]";
$ret;
}
sub readable {
my($self,$n) = @_;
$n =~ /^([\w\-\+\.]+)/;
return $1 if defined $1 && length($1)>0;
# if the first user reaches version v43, he will be treated as "+".
# We'll have to decide about a new rule here then, depending on what
# will be the prevailing versioning behavior then.
if ($] < 5.006) { # or whenever v-strings were introduced
# we get them wrong anyway, whatever we do, because 5.005 will
# have already interpreted 0.2.4 to be "0.24". So even if he
# indexer sends us something like "v0.2.4" we compare wrongly.
# And if they say v1.2, then the old perl takes it as "v12"
return $n;
}
my $better = sprintf "v%vd", $n;
return $better;
}
package CPAN;
1;
=head1 NAME
CPAN - query, download and build perl modules from CPAN sites
=head1 SYNOPSIS
Interactive mode:
perl -MCPAN -e shell;
Batch mode:
use CPAN;
autobundle, clean, install, make, recompile, test
=head1 STATUS
This module will eventually be replaced by CPANPLUS. CPANPLUS is kind
of a modern rewrite from ground up with greater extensibility and more
features but no full compatibility. If you're new to CPAN.pm, you
probably should investigate if CPANPLUS is the better choice for you.
If you're already used to CPAN.pm you're welcome to continue using it,
if you accept that its development is mostly (though not completely)
stalled.
=head1 DESCRIPTION
The CPAN module is designed to automate the make and install of perl
modules and extensions. It includes some primitive searching capabilities and
knows how to use Net::FTP or LWP (or lynx or an external ftp client)
to fetch the raw data from the net.
Modules are fetched from one or more of the mirrored CPAN
(Comprehensive Perl Archive Network) sites and unpacked in a dedicated
directory.
The CPAN module also supports the concept of named and versioned
I<bundles> of modules. Bundles simplify the handling of sets of
related modules. See Bundles below.
The package contains a session manager and a cache manager. There is
no status retained between sessions. The session manager keeps track
of what has been fetched, built and installed in the current
session. The cache manager keeps track of the disk space occupied by
the make processes and deletes excess space according to a simple FIFO
mechanism.
For extended searching capabilities there's a plugin for CPAN available,
L<C<CPAN::WAIT>|CPAN::WAIT>. C<CPAN::WAIT> is a full-text search engine
that indexes all documents available in CPAN authors directories. If
C<CPAN::WAIT> is installed on your system, the interactive shell of
CPAN.pm will enable the C<wq>, C<wr>, C<wd>, C<wl>, and C<wh> commands
which send queries to the WAIT server that has been configured for your
installation.
All other methods provided are accessible in a programmer style and in an
interactive shell style.
=head2 Interactive Mode
The interactive mode is entered by running
perl -MCPAN -e shell
which puts you into a readline interface. You will have the most fun if
you install Term::ReadKey and Term::ReadLine to enjoy both history and
command completion.
Once you are on the command line, type 'h' and the rest should be
self-explanatory.
The function call C<shell> takes two optional arguments, one is the
prompt, the second is the default initial command line (the latter
only works if a real ReadLine interface module is installed).
The most common uses of the interactive modes are
=over 2
=item Searching for authors, bundles, distribution files and modules
There are corresponding one-letter commands C<a>, C<b>, C<d>, and C<m>
for each of the four categories and another, C<i> for any of the
mentioned four. Each of the four entities is implemented as a class
with slightly differing methods for displaying an object.
Arguments you pass to these commands are either strings exactly matching
the identification string of an object or regular expressions that are
then matched case-insensitively against various attributes of the
objects. The parser recognizes a regular expression only if you
enclose it between two slashes.
The principle is that the number of found objects influences how an
item is displayed. If the search finds one item, the result is
displayed with the rather verbose method C<as_string>, but if we find
more than one, we display each object with the terse method
<as_glimpse>.
=item make, test, install, clean modules or distributions
These commands take any number of arguments and investigate what is
necessary to perform the action. If the argument is a distribution
file name (recognized by embedded slashes), it is processed. If it is
a module, CPAN determines the distribution file in which this module
is included and processes that, following any dependencies named in
the module's Makefile.PL (this behavior is controlled by
I<prerequisites_policy>.)
Any C<make> or C<test> are run unconditionally. An
install <distribution_file>
also is run unconditionally. But for
install <module>
CPAN checks if an install is actually needed for it and prints
I<module up to date> in the case that the distribution file containing
the module doesn't need to be updated.
CPAN also keeps track of what it has done within the current session
and doesn't try to build a package a second time regardless if it
succeeded or not. The C<force> command takes as a first argument the
method to invoke (currently: C<make>, C<test>, or C<install>) and executes the
command from scratch.
Example:
cpan> install OpenGL
OpenGL is up to date.
cpan> force install OpenGL
Running make
OpenGL-0.4/
[...]
A C<clean> command results in a
make clean
being executed within the distribution file's working directory.
=item get, readme, look module or distribution
C<get> downloads a distribution file without further action. C<readme>
displays the README file of the associated distribution. C<Look> gets
and untars (if not yet done) the distribution file, changes to the
appropriate directory and opens a subshell process in that directory.
=item ls author
C<ls> lists all distribution files in and below an author's CPAN
directory. Only those files that contain modules are listed and if
there is more than one for any given module, only the most recent one
is listed.
=item Signals
CPAN.pm installs signal handlers for SIGINT and SIGTERM. While you are
in the cpan-shell it is intended that you can press C<^C> anytime and
return to the cpan-shell prompt. A SIGTERM will cause the cpan-shell
to clean up and leave the shell loop. You can emulate the effect of a
SIGTERM by sending two consecutive SIGINTs, which usually means by
pressing C<^C> twice.
CPAN.pm ignores a SIGPIPE. If the user sets inactivity_timeout, a
SIGALRM is used during the run of the C<perl Makefile.PL> subprocess.
=back
=head2 CPAN::Shell
The commands that are available in the shell interface are methods in
the package CPAN::Shell. If you enter the shell command, all your
input is split by the Text::ParseWords::shellwords() routine which
acts like most shells do. The first word is being interpreted as the
method to be called and the rest of the words are treated as arguments
to this method. Continuation lines are supported if a line ends with a
literal backslash.
=head2 autobundle
C<autobundle> writes a bundle file into the
C<$CPAN::Config-E<gt>{cpan_home}/Bundle> directory. The file contains
a list of all modules that are both available from CPAN and currently
installed within @INC. The name of the bundle file is based on the
current date and a counter.
=head2 recompile
recompile() is a very special command in that it takes no argument and
dynamically loadable extensions (aka XS modules) with 'force' in
effect. The primary purpose of this command is to finish a network
installation. Imagine, you have a common source tree for two different
architectures. You decide to do a completely independent fresh
installation. You start on one architecture with the help of a Bundle
file produced earlier. CPAN installs the whole Bundle for you, but
when you try to repeat the job on the second architecture, CPAN
responds with a C<"Foo up to date"> message for all modules. So you
invoke CPAN's recompile on the second architecture and you're done.
Another popular use for C<recompile> is to act as a rescue in case your
perl breaks binary compatibility. If one of the modules that CPAN uses
is in turn depending on binary compatibility (so you cannot run CPAN
commands), then you should try the CPAN::Nox module for recovery.
=head2 The four C<CPAN::*> Classes: Author, Bundle, Module, Distribution
Although it may be considered internal, the class hierarchy does matter
for both users and programmer. CPAN.pm deals with above mentioned four
classes, and all those classes share a set of methods. A classical
single polymorphism is in effect. A metaclass object registers all
objects of all kinds and indexes them with a string. The strings
referencing objects have a separated namespace (well, not completely
separated):
Namespace Class
words containing a "/" (slash) Distribution
words starting with Bundle:: Bundle
everything else Module or Author
Modules know their associated Distribution objects. They always refer
to the most recent official release. Developers may mark their releases
as unstable development versions (by inserting an underbar into the
module version number which will also be reflected in the distribution
name when you run 'make dist'), so the really hottest and newest
distribution is not always the default. If a module Foo circulates
on CPAN in both version 1.23 and 1.23_90, CPAN.pm offers a convenient
way to install version 1.23 by saying
install Foo
This would install the complete distribution file (say
BAR/Foo-1.23.tar.gz) with all accompanying material. But if you would
like to install version 1.23_90, you need to know where the
directory. If the author is BAR, this might be BAR/Foo-1.23_90.tar.gz;
so you would have to say
install BAR/Foo-1.23_90.tar.gz
The first example will be driven by an object of the class
CPAN::Module, the second by an object of class CPAN::Distribution.
=head2 Programmer's interface
If you do not enter the shell, the available shell commands are both
available as methods (C<CPAN::Shell-E<gt>install(...)>) and as
functions in the calling package (C<install(...)>).
There's currently only one class that has a stable interface -
CPAN::Shell. All commands that are available in the CPAN shell are
methods of the class CPAN::Shell. Each of the commands that produce
listings of modules (C<r>, C<autobundle>, C<u>) also return a list of
the IDs of all modules within the list.
=over 2
=item expand($type,@things)
The IDs of all objects available within a program are strings that can
be expanded to the corresponding real objects with the
C<CPAN::Shell-E<gt>expand("Module",@things)> method. Expand returns a
list of CPAN::Module objects according to the C<@things> arguments
given. In scalar context it only returns the first element of the
list.
=item expandany(@things)
Like expand, but returns objects of the appropriate type, i.e.
CPAN::Bundle objects for bundles, CPAN::Module objects for modules and
CPAN::Distribution objects fro distributions.
=item Programming Examples
This enables the programmer to do operations that combine
functionalities that are available in the shell.
# install everything that is outdated on my disk:
perl -MCPAN -e 'CPAN::Shell->install(CPAN::Shell->r)'
# install my favorite programs if necessary:
for $mod (qw(Net::FTP Digest::MD5 Data::Dumper)){
my $obj = CPAN::Shell->expand('Module',$mod);
$obj->install;
}
# list all modules on my disk that have no VERSION number
for $mod (CPAN::Shell->expand("Module","/./")){
next unless $mod->inst_file;
# MakeMaker convention for undefined $VERSION:
next unless $mod->inst_version eq "undef";
print "No VERSION in ", $mod->id, "\n";
}
# find out which distribution on CPAN contains a module:
print CPAN::Shell->expand("Module","Apache::Constants")->cpan_file
Or if you want to write a cronjob to watch The CPAN, you could list
all modules that need updating. First a quick and dirty way:
perl -e 'use CPAN; CPAN::Shell->r;'
If you don't want to get any output in the case that all modules are
up to date, you can parse the output of above command for the regular
expression //modules are up to date// and decide to mail the output
only if it doesn't match. Ick?
If you prefer to do it more in a programmer style in one single
process, maybe something like this suits you better:
# list all modules on my disk that have newer versions on CPAN
for $mod (CPAN::Shell->expand("Module","/./")){
next unless $mod->inst_file;
next if $mod->uptodate;
printf "Module %s is installed as %s, could be updated to %s from CPAN\n",
$mod->id, $mod->inst_version, $mod->cpan_version;
}
If that gives you too much output every day, you maybe only want to
watch for three modules. You can write
for $mod (CPAN::Shell->expand("Module","/Apache|LWP|CGI/")){
as the first line instead. Or you can combine some of the above
tricks:
# watch only for a new mod_perl module
$mod = CPAN::Shell->expand("Module","mod_perl");
exit if $mod->uptodate;
# new mod_perl arrived, let me know all update recommendations
CPAN::Shell->r;
=back
=head2 Methods in the other Classes
The programming interface for the classes CPAN::Module,
CPAN::Distribution, CPAN::Bundle, and CPAN::Author is still considered
beta and partially even alpha. In the following paragraphs only those
methods are documented that have proven useful over a longer time and
thus are unlikely to change.
=over 4
=item CPAN::Author::as_glimpse()
Returns a one-line description of the author
=item CPAN::Author::as_string()
Returns a multi-line description of the author
=item CPAN::Author::email()
Returns the author's email address
=item CPAN::Author::fullname()
Returns the author's name
=item CPAN::Author::name()
An alias for fullname
=item CPAN::Bundle::as_glimpse()
Returns a one-line description of the bundle
=item CPAN::Bundle::as_string()
Returns a multi-line description of the bundle
=item CPAN::Bundle::clean()
Recursively runs the C<clean> method on all items contained in the bundle.
=item CPAN::Bundle::contains()
Returns a list of objects' IDs contained in a bundle. The associated
objects may be bundles, modules or distributions.
=item CPAN::Bundle::force($method,@args)
Forces CPAN to perform a task that normally would have failed. Force
takes as arguments a method name to be called and any number of
additional arguments that should be passed to the called method. The
internals of the object get the needed changes so that CPAN.pm does
not refuse to take the action. The C<force> is passed recursively to
all contained objects.
=item CPAN::Bundle::get()
Recursively runs the C<get> method on all items contained in the bundle
=item CPAN::Bundle::inst_file()
Returns the highest installed version of the bundle in either @INC or
C<$CPAN::Config->{cpan_home}>. Note that this is different from
CPAN::Module::inst_file.
=item CPAN::Bundle::inst_version()
Like CPAN::Bundle::inst_file, but returns the $VERSION
=item CPAN::Bundle::uptodate()
Returns 1 if the bundle itself and all its members are uptodate.
=item CPAN::Bundle::install()
Recursively runs the C<install> method on all items contained in the bundle
=item CPAN::Bundle::make()
Recursively runs the C<make> method on all items contained in the bundle
=item CPAN::Bundle::readme()
Recursively runs the C<readme> method on all items contained in the bundle
=item CPAN::Bundle::test()
Recursively runs the C<test> method on all items contained in the bundle
=item CPAN::Distribution::as_glimpse()
Returns a one-line description of the distribution
=item CPAN::Distribution::as_string()
Returns a multi-line description of the distribution
=item CPAN::Distribution::clean()
Changes to the directory where the distribution has been unpacked and
runs C<make clean> there.
=item CPAN::Distribution::containsmods()
Returns a list of IDs of modules contained in a distribution file.
Only works for distributions listed in the 02packages.details.txt.gz
file. This typically means that only the most recent version of a
distribution is covered.
=item CPAN::Distribution::cvs_import()
Changes to the directory where the distribution has been unpacked and
runs something like
cvs -d $cvs_root import -m $cvs_log $cvs_dir $userid v$version
there.
=item CPAN::Distribution::dir()
Returns the directory into which this distribution has been unpacked.
=item CPAN::Distribution::force($method,@args)
Forces CPAN to perform a task that normally would have failed. Force
takes as arguments a method name to be called and any number of
additional arguments that should be passed to the called method. The
internals of the object get the needed changes so that CPAN.pm does
not refuse to take the action.
=item CPAN::Distribution::get()
Downloads the distribution from CPAN and unpacks it. Does nothing if
the distribution has already been downloaded and unpacked within the
current session.
=item CPAN::Distribution::install()
Changes to the directory where the distribution has been unpacked and
runs the external command C<make install> there. If C<make> has not
yet been run, it will be run first. A C<make test> will be issued in
any case and if this fails, the install will be canceled. The
cancellation can be avoided by letting C<force> run the C<install> for
you.
=item CPAN::Distribution::isa_perl()
Returns 1 if this distribution file seems to be a perl distribution.
Normally this is derived from the file name only, but the index from
CPAN can contain a hint to achieve a return value of true for other
filenames too.
=item CPAN::Distribution::look()
Changes to the directory where the distribution has been unpacked and
opens a subshell there. Exiting the subshell returns.
=item CPAN::Distribution::make()
First runs the C<get> method to make sure the distribution is
downloaded and unpacked. Changes to the directory where the
distribution has been unpacked and runs the external commands C<perl
Makefile.PL> and C<make> there.
=item CPAN::Distribution::prereq_pm()
Returns the hash reference that has been announced by a distribution
as the PREREQ_PM hash in the Makefile.PL. Note: works only after an
attempt has been made to C<make> the distribution. Returns undef
otherwise.
=item CPAN::Distribution::readme()
Downloads the README file associated with a distribution and runs it
through the pager specified in C<$CPAN::Config->{pager}>.
=item CPAN::Distribution::test()
Changes to the directory where the distribution has been unpacked and
runs C<make test> there.
=item CPAN::Distribution::uptodate()
Returns 1 if all the modules contained in the distribution are
uptodate. Relies on containsmods.
=item CPAN::Index::force_reload()
Forces a reload of all indices.
=item CPAN::Index::reload()
Reloads all indices if they have been read more than
C<$CPAN::Config->{index_expire}> days.
=item CPAN::InfoObj::dump()
CPAN::Author, CPAN::Bundle, CPAN::Module, and CPAN::Distribution
inherit this method. It prints the data structure associated with an
object. Useful for debugging. Note: the data structure is considered
internal and thus subject to change without notice.
=item CPAN::Module::as_glimpse()
Returns a one-line description of the module
=item CPAN::Module::as_string()
Returns a multi-line description of the module
=item CPAN::Module::clean()
Runs a clean on the distribution associated with this module.
=item CPAN::Module::cpan_file()
Returns the filename on CPAN that is associated with the module.
=item CPAN::Module::cpan_version()
Returns the latest version of this module available on CPAN.
=item CPAN::Module::cvs_import()
Runs a cvs_import on the distribution associated with this module.
=item CPAN::Module::description()
Returns a 44 character description of this module. Only available for
modules listed in The Module List (CPAN/modules/00modlist.long.html
or 00modlist.long.txt.gz)
=item CPAN::Module::force($method,@args)
Forces CPAN to perform a task that normally would have failed. Force
takes as arguments a method name to be called and any number of
additional arguments that should be passed to the called method. The
internals of the object get the needed changes so that CPAN.pm does
not refuse to take the action.
=item CPAN::Module::get()
Runs a get on the distribution associated with this module.
=item CPAN::Module::inst_file()
Returns the filename of the module found in @INC. The first file found
is reported just like perl itself stops searching @INC when it finds a
module.
=item CPAN::Module::inst_version()
Returns the version number of the module in readable format.
=item CPAN::Module::install()
Runs an C<install> on the distribution associated with this module.
=item CPAN::Module::look()
Changes to the directory where the distribution associated with this
module has been unpacked and opens a subshell there. Exiting the
subshell returns.
=item CPAN::Module::make()
Runs a C<make> on the distribution associated with this module.
=item CPAN::Module::manpage_headline()
If module is installed, peeks into the module's manpage, reads the
headline and returns it. Moreover, if the module has been downloaded
within this session, does the equivalent on the downloaded module even
if it is not installed.
=item CPAN::Module::readme()
Runs a C<readme> on the distribution associated with this module.
=item CPAN::Module::test()
Runs a C<test> on the distribution associated with this module.
=item CPAN::Module::uptodate()
Returns 1 if the module is installed and up-to-date.
=item CPAN::Module::userid()
Returns the author's ID of the module.
=back
=head2 Cache Manager
Currently the cache manager only keeps track of the build directory
($CPAN::Config->{build_dir}). It is a simple FIFO mechanism that
deletes complete directories below C<build_dir> as soon as the size of
all directories there gets bigger than $CPAN::Config->{build_cache}
(in MB). The contents of this cache may be used for later
re-installations that you intend to do manually, but will never be
trusted by CPAN itself. This is due to the fact that the user might
use these directories for building modules on different architectures.
There is another directory ($CPAN::Config->{keep_source_where}) where
the original distribution files are kept. This directory is not
covered by the cache manager and must be controlled by the user. If
you choose to have the same directory as build_dir and as
keep_source_where directory, then your sources will be deleted with
the same fifo mechanism.
=head2 Bundles
A bundle is just a perl module in the namespace Bundle:: that does not
define any functions or methods. It usually only contains documentation.
It starts like a perl module with a package declaration and a $VERSION
variable. After that the pod section looks like any other pod with the
only difference being that I<one special pod section> exists starting with
(verbatim):
=head1 CONTENTS
In this pod section each line obeys the format
Module_Name [Version_String] [- optional text]
The only required part is the first field, the name of a module
(e.g. Foo::Bar, ie. I<not> the name of the distribution file). The rest
of the line is optional. The comment part is delimited by a dash just
as in the man page header.
The distribution of a bundle should follow the same convention as
other distributions.
Bundles are treated specially in the CPAN package. If you say 'install
Bundle::Tkkit' (assuming such a bundle exists), CPAN will install all
the modules in the CONTENTS section of the pod. You can install your
own Bundles locally by placing a conformant Bundle file somewhere into
your @INC path. The autobundle() command which is available in the
shell interface does that for you by including all currently installed
modules in a snapshot bundle file.
=head2 Prerequisites
If you have a local mirror of CPAN and can access all files with
"file:" URLs, then you only need a perl better than perl5.003 to run
this module. Otherwise Net::FTP is strongly recommended. LWP may be
required for non-UNIX systems or if your nearest CPAN site is
associated with a URL that is not C<ftp:>.
If you have neither Net::FTP nor LWP, there is a fallback mechanism
implemented for an external ftp command or for an external lynx
command.
=head2 Finding packages and VERSION
This module presumes that all packages on CPAN
=over 2
=item *
declare their $VERSION variable in an easy to parse manner. This
prerequisite can hardly be relaxed because it consumes far too much
memory to load all packages into the running program just to determine
the $VERSION variable. Currently all programs that are dealing with
version use something like this
perl -MExtUtils::MakeMaker -le \
'print MM->parse_version(shift)' filename
If you are author of a package and wonder if your $VERSION can be
parsed, please try the above method.
=item *
come as compressed or gzipped tarfiles or as zip files and contain a
Makefile.PL (well, we try to handle a bit more, but without much
enthusiasm).
=back
=head2 Debugging
The debugging of this module is a bit complex, because we have
interferences of the software producing the indices on CPAN, of the
mirroring process on CPAN, of packaging, of configuration, of
synchronicity, and of bugs within CPAN.pm.
For code debugging in interactive mode you can try "o debug" which
will list options for debugging the various parts of the code. You
should know that "o debug" has built-in completion support.
For data debugging there is the C<dump> command which takes the same
dump.
=head2 Floppy, Zip, Offline Mode
CPAN.pm works nicely without network too. If you maintain machines
that are not networked at all, you should consider working with file:
URLs. Of course, you have to collect your modules somewhere first. So
you might use CPAN.pm to put together all you need on a networked
machine. Then copy the $CPAN::Config->{keep_source_where} (but not
$CPAN::Config->{build_dir}) directory on a floppy. This floppy is kind
of a personal CPAN. CPAN.pm on the non-networked machines works nicely
with this floppy. See also below the paragraph about CD-ROM support.
=head1 CONFIGURATION
When the CPAN module is used for the first time, a configuration
dialog tries to determine a couple of site specific options. The
result of the dialog is stored in a hash reference C< $CPAN::Config >
overridden in a user specific file: CPAN/MyConfig.pm. Such a file is
best placed in $HOME/.cpan/CPAN/MyConfig.pm, because $HOME/.cpan is
added to the search path of the CPAN module before the use() or
require() statements.
The configuration dialog can be started any time later again by
issueing the command C< o conf init > in the CPAN shell.
Currently the following keys in the hash reference $CPAN::Config are
defined:
build_cache size of cache for directories to build modules
build_dir locally accessible directory to build modules
index_expire after this many days refetch index files
cache_metadata use serializer to cache metadata
cpan_home local directory reserved for this package
dontload_hash anonymous hash: modules in the keys will not be
loaded by the CPAN::has_inst() routine
gzip location of external program gzip
histfile file to maintain history between sessions
histsize maximum number of lines to keep in histfile
inactivity_timeout breaks interactive Makefile.PLs after this
many seconds inactivity. Set to 0 to never break.
inhibit_startup_message
if true, does not print the startup message
keep_source_where directory in which to keep the source (if we do)
make location of external make program
make_arg arguments that should always be passed to 'make'
make_install_arg same as make_arg for 'make install'
makepl_arg arguments passed to 'perl Makefile.PL'
pager location of external program more (or any pager)
prerequisites_policy
what to do if you are missing module prerequisites
('follow' automatically, 'ask' me, or 'ignore')
proxy_user username for accessing an authenticating proxy
proxy_pass password for accessing an authenticating proxy
scan_cache controls scanning of cache ('atstart' or 'never')
tar location of external program tar
term_is_latin if true internal UTF-8 is translated to ISO-8859-1
(and nonsense for characters outside latin range)
unzip location of external program unzip
urllist arrayref to nearby CPAN sites (or equivalent locations)
wait_list arrayref to a wait server to try (See CPAN::WAIT)
ftp_proxy, } the three usual variables for configuring
http_proxy, } proxy requests. Both as CPAN::Config variables
no_proxy } and as environment variables configurable.
You can set and query each of these options interactively in the cpan
shell with the command set defined within the C<o conf> command:
=over 2
=item C<o conf E<lt>scalar optionE<gt>>
prints the current value of the I<scalar option>
=item C<o conf E<lt>scalar optionE<gt> E<lt>valueE<gt>>
Sets the value of the I<scalar option> to I<value>
=item C<o conf E<lt>list optionE<gt>>
prints the current value of the I<list option> in MakeMaker's
neatvalue format.
=item C<o conf E<lt>list optionE<gt> [shift|pop]>
shifts or pops the array in the I<list option> variable
=item C<o conf E<lt>list optionE<gt> [unshift|push|splice] E<lt>listE<gt>>
works like the corresponding perl commands.
=back
=head2 Note on urllist parameter's format
urllist parameters are URLs according to RFC 1738. We do a little
guessing if your URL is not compliant, but if you have problems with
file URLs, please try the correct format. Either:
or
=head2 urllist parameter has CD-ROM support
The C<urllist> parameter of the configuration table contains a list of
URLs that are to be used for downloading. If the list contains any
C<file> URLs, CPAN always tries to get files from there first. This
feature is disabled for index files. So the recommendation for the
owner of a CD-ROM with CPAN contents is: include your local, possibly
outdated CD-ROM as a C<file> URL at the end of urllist, e.g.
CPAN.pm will then fetch the index files from one of the CPAN sites
that come at the beginning of urllist. It will later check for each
module if there is a local copy of the most recent version.
Another peculiarity of urllist is that the site that we could
successfully fetch the last file from automatically gets a preference
token and is tried as the first site for the next request. So if you
add a new site at runtime it may happen that the previously preferred
site will be tried another time. This means that if you want to disallow
a site for the next transfer, it must be explicitly removed from
urllist.
=head1 SECURITY
install foreign, unmasked, unsigned code on your machine. We compare
to a checksum that comes from the net just as the distribution file
itself. If somebody has managed to tamper with the distribution file,
they may have as well tampered with the CHECKSUMS file. Future
development will go towards strong authentication.
=head1 EXPORT
Most functions in package CPAN are exported per default. The reason
for this is that the primary use is intended for the cpan shell or for
one-liners.
=head1 POPULATE AN INSTALLATION WITH LOTS OF MODULES
Populating a freshly installed perl with my favorite modules is pretty
easy if you maintain a private bundle definition file. To get a useful
blueprint of a bundle definition file, the command autobundle can be used
on the CPAN shell command line. This command writes a bundle definition
file for all modules that are installed for the currently running perl
interpreter. It's recommended to run this command only once and from then
on maintain the file manually under a private name, say
Bundle/my_bundle.pm. With a clever bundle file you can then simply say
cpan> install Bundle::my_bundle
then answer a few questions and then go out for a coffee.
Maintaining a bundle definition file means keeping track of two
things: dependencies and interactivity. CPAN.pm sometimes fails on
calculating dependencies because not all modules define all MakeMaker
attributes correctly, so a bundle definition file should specify
prerequisites as early as possible. On the other hand, it's a bit
annoying that many distributions need some interactive configuring. So
what I try to accomplish in my private bundle file is to have the
packages that need to be configured early in the file and the gentle
ones later, so I can go out after a few minutes and leave CPAN.pm
untended.
=head1 WORKING WITH CPAN.pm BEHIND FIREWALLS
Thanks to Graham Barr for contributing the following paragraphs about
the interaction between perl, and various firewall configurations. For
further informations on firewalls, it is recommended to consult the
documentation that comes with the ncftp program. If you are unable to
go through the firewall with a simple Perl setup, it is very likely
that you can configure ncftp so that it works for your firewall.
=head2 Three basic types of firewalls
Firewalls can be categorized into three basic types.
=over 4
=item http firewall
This is where the firewall machine runs a web server and to access the
outside world you must do it via the web server. If you set environment
variables like http_proxy or ftp_proxy to a values beginning with http://
or in your web browser you have to set proxy information then you know
you are running an http firewall.
To access servers outside these types of firewalls with perl (even for
ftp) you will need to use LWP.
=item ftp firewall
This where the firewall machine runs an ftp server. This kind of
firewall will only let you access ftp servers outside the firewall.
This is usually done by connecting to the firewall with ftp, then
entering a username like "user@outside.host.com"
To access servers outside these type of firewalls with perl you
will need to use Net::FTP.
=item One way visibility
I say one way visibility as these firewalls try to make themselves look
invisible to the users inside the firewall. An FTP data connection is
normally created by sending the remote server your IP address and then
listening for the connection. But the remote server will not be able to
connect to you because of the firewall. So for these types of firewall
FTP connections need to be done in a passive mode.
There are two that I can think off.
=over 4
=item SOCKS
If you are using a SOCKS firewall you will need to compile perl and link
it with the SOCKS library, this is what is normally called a 'socksified'
perl. With this executable you will be able to connect to servers outside
the firewall as if it is not there.
=item IP Masquerade
This is the firewall implemented in the Linux kernel, it allows you to
hide a complete network behind one IP address. With this firewall no
special compiling is needed as you can access hosts directly.
For accessing ftp servers behind such firewalls you may need to set
the environment variable C<FTP_PASSIVE> to a true value, e.g.
env FTP_PASSIVE=1 perl -MCPAN -eshell
or
perl -MCPAN -e '$ENV{FTP_PASSIVE} = 1; shell'
=back
=back
=head2 Configuring lynx or ncftp for going through a firewall
If you can go through your firewall with e.g. lynx, presumably with a
command such as
then you would configure CPAN.pm with the command
That's all. Similarly for ncftp or ftp, you would configure something
like
Your mileage may vary...
=head1 FAQ
=over 4
=item 1)
I installed a new version of module X but CPAN keeps saying,
I have the old version installed
Most probably you B<do> have the old version installed. This can
happen if a module installs itself into a different directory in the
@INC path than it was previously installed. This is not really a
CPAN.pm problem, you would have the same problem when installing the
module manually. The easiest way to prevent this behaviour is to add
the argument C<UNINST=1> to the C<make install> call, and that is why
many people add this argument permanently by configuring
o conf make_install_arg UNINST=1
=item 2)
So why is UNINST=1 not the default?
Because there are people who have their precise expectations about who
may install where in the @INC path and who uses which @INC array. In
fine tuned environments C<UNINST=1> can cause damage.
=item 3)
I want to clean up my mess, and install a new perl along with
all modules I have. How do I go about it?
Run the autobundle command for your old perl and optionally rename the
resulting bundle file (e.g. Bundle/mybundle.pm), install the new perl
with the Configure option prefix, e.g.
./Configure -Dprefix=/usr/local/perl-5.6.78.9
Install the bundle file you produced in the first step with something like
cpan> install Bundle::mybundle
and you're done.
=item 4)
When I install bundles or multiple modules with one command
there is too much output to keep track of.
You may want to configure something like
o conf make_install_arg "| tee -ai /root/.cpan/logs/make_install.out"
so that STDOUT is captured in a file for later inspection.
=item 5)
I am not root, how can I install a module in a personal directory?
You will most probably like something like this:
install Sybase::Sybperl
You can make this setting permanent like all C<o conf> settings with
C<o conf commit>.
including
or setting the PERL5LIB environment variable.
Another thing you should bear in mind is that the UNINST parameter
should never be set if you are not root.
=item 6)
How to get a package, unwrap it, and make a change before building it?
look Sybase::Sybperl
=item 7)
I installed a Bundle and had a couple of fails. When I
retried, everything resolved nicely. Can this be fixed to work
on first try?
The reason for this is that CPAN does not know the dependencies of all
modules when it starts out. To decide about the additional items to
install, it just uses data found in the generated Makefile. An
undetected missing piece breaks the process. But it may well be that
your Bundle installs some prerequisite later than some depending item
and thus your second try is able to resolve everything. Please note,
CPAN.pm does not know the dependency tree in advance and cannot sort
the queue of things to install in a topologically correct order. It
resolves perfectly well IFF all modules declare the prerequisites
correctly with the PREREQ_PM attribute to MakeMaker. For bundles which
fail and you need to install often, it is recommended sort the Bundle
definition file manually. It is planned to improve the metadata
situation for dependencies on CPAN in general, but this will still
take some time.
=item 8)
In our intranet we have many modules for internal use. How
can I integrate these modules with CPAN.pm but without uploading
the modules to CPAN?
Have a look at the CPAN::Site module.
=item 9)
When I run CPAN's shell, I get error msg about line 1 to 4,
Some versions of readline are picky about capitalization in the
occurrences of C<on> to C<On> and the bug should disappear.
=item 10)
Some authors have strange characters in their names.
Internally CPAN.pm uses the UTF-8 charset. If your terminal is
expecting ISO-8859-1 charset, a converter can be activated by setting
term_is_latin to a true value in your config file. One way of doing so
would be
cpan> ! $CPAN::Config->{term_is_latin}=1
Extended support for converters will be made available as soon as perl
becomes stable with regard to charset issues.
=back
=head1 BUGS
We should give coverage for B<all> of the CPAN and not just the PAUSE
part, right? In this discussion CPAN and PAUSE have become equal --
but they are not. PAUSE is authors/, modules/ and scripts/. CPAN is
PAUSE plus the clpa/, doc/, misc/, ports/, and src/.
Future development should be directed towards a better integration of
the other parts.
If a Makefile.PL requires special customization of libraries, prompts
the user for special input, etc. then you may find CPAN is not able to
build the distribution. In that case, you should attempt the
traditional method of building a Perl module package from a shell.
=head1 AUTHOR
Andreas Koenig E<lt>andreas.koenig@anima.deE<gt>
=head1 TRANSLATIONS
Kawai,Takanori provides a Japanese translation of this manpage at
=head1 SEE ALSO
perl(1), CPAN::Nox(3)
=cut