|
NAMECPAN - query, download and build perl modules from CPAN sites SYNOPSISInteractive mode: perl -MCPAN -e shell --or-- cpan Basic commands: # Modules:
cpan> install Acme::Meta # in the shell
CPAN::Shell->install("Acme::Meta"); # in perl
# Distributions:
cpan> install NWCLARK/Acme-Meta-0.02.tar.gz # in the shell
CPAN::Shell->
install("NWCLARK/Acme-Meta-0.02.tar.gz"); # in perl
# module objects:
$mo = CPAN::Shell->expandany($mod);
$mo = CPAN::Shell->expand("Module",$mod); # same thing
# distribution objects:
$do = CPAN::Shell->expand("Module",$mod)->distribution;
$do = CPAN::Shell->expandany($distro); # same thing
$do = CPAN::Shell->expand("Distribution",
$distro); # same thing
DESCRIPTIONThe CPAN module automates or at least simplifies the make and install of perl modules and extensions. It includes some primitive searching capabilities and knows how to use LWP, HTTP::Tiny, Net::FTP and certain external download clients to fetch distributions from the net. These are fetched from one or more mirrored CPAN (Comprehensive Perl Archive Network) sites and unpacked in a dedicated directory. The CPAN module also supports named and versioned bundles of modules. Bundles simplify handling of sets of related modules. See Bundles below. The package contains a session manager and a cache manager. 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 using a simple FIFO mechanism. All methods provided are accessible in a programmer style and in an interactive shell style. CPAN::shell([$prompt, $command]) Starting Interactive ModeEnter interactive mode by running perl -MCPAN -e shell or cpan which puts you into a readline interface. If "Term::ReadKey" and either of "Term::ReadLine::Perl" or "Term::ReadLine::Gnu" are installed, history and command completion are supported. Once at the command line, type "h" for one-page help screen; the rest should be self-explanatory. The function call "shell" takes two optional arguments: one the prompt, the second 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
CPAN::ShellThe commands available in the shell interface are methods in the package CPAN::Shell. If you enter the shell command, your input is split by the Text::ParseWords::shellwords() routine, which acts like most shells do. The first word is interpreted as the method to be invoked, and the rest of the words are treated as the method's arguments. Continuation lines are supported by ending a line with a literal backslash. autobundle"autobundle" writes a bundle file into the "$CPAN::Config->{cpan_home}/Bundle" directory. The file contains a list of all modules that are both available from CPAN and currently installed within @INC. Duplicates of each distribution are suppressed. The name of the bundle file is based on the current date and a counter, e.g. Bundle/Snapshot_2012_05_21_00.pm. This is installed again by running "cpan Bundle::Snapshot_2012_05_21_00", or installing "Bundle::Snapshot_2012_05_21_00" from the CPAN shell. Return value: path to the written file. hostsNote: this feature is still in alpha state and may change in future versions of CPAN.pm This commands provides a statistical overview over recent download activities. The data for this is collected in the YAML file "FTPstats.yml" in your "cpan_home" directory. If no YAML module is configured or YAML not installed, no stats are provided.
mkmyconfigmkmyconfig() writes your own CPAN::MyConfig file into your "~/.cpan/" directory so that you can save your own preferences instead of the system-wide ones. r [Module|/Regexp/]...scans current perl installation for modules that have a newer version available on CPAN and provides a list of them. If called without argument, all potential upgrades are listed; if called with arguments the list is filtered to the modules and regexps given as arguments. The listing looks something like this: Package namespace installed latest in CPAN file CPAN 1.94_64 1.9600 ANDK/CPAN-1.9600.tar.gz CPAN::Reporter 1.1801 1.1902 DAGOLDEN/CPAN-Reporter-1.1902.tar.gz YAML 0.70 0.73 INGY/YAML-0.73.tar.gz YAML::Syck 1.14 1.17 AVAR/YAML-Syck-1.17.tar.gz YAML::Tiny 1.44 1.50 ADAMK/YAML-Tiny-1.50.tar.gz CGI 3.43 3.55 MARKSTOS/CGI.pm-3.55.tar.gz Module::Build::YAML 1.40 1.41 DAGOLDEN/Module-Build-0.3800.tar.gz TAP::Parser::Result::YAML 3.22 3.23 ANDYA/Test-Harness-3.23.tar.gz YAML::XS 0.34 0.35 INGY/YAML-LibYAML-0.35.tar.gz It suppresses duplicates in the column "in CPAN file" such that distributions with many upgradeable modules are listed only once. Note that the list is not sorted. recent ***EXPERIMENTAL COMMAND***The "recent" command downloads a list of recent uploads to CPAN and displays them slowly. While the command is running, a $SIG{INT} exits the loop after displaying the current item. Note: This command requires XML::LibXML installed. Note: This whole command currently is just a hack and will probably change in future versions of CPAN.pm, but the general approach will likely remain. Note: See also smoke recompilerecompile() is a special command that takes no argument and runs the make/test/install cycle with brute force over all installed dynamically loadable extensions (a.k.a. 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 "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 "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. report Bundle|Distribution|ModuleThe "report" command temporarily turns on the "test_report" config variable, then runs the "force test" command with the given arguments. The "force" pragma reruns the tests and repeats every step that might have failed before. smoke ***EXPERIMENTAL COMMAND****** WARNING: this command downloads and executes software from CPAN to your computer of completely unknown status. You should never do this with your normal account and better have a dedicated well separated and secured machine to do this. *** The "smoke" command takes the list of recent uploads to CPAN as provided by the "recent" command and tests them all. While the command is running $SIG{INT} is defined to mean that the current item shall be skipped. Note: This whole command currently is just a hack and will probably change in future versions of CPAN.pm, but the general approach will likely remain. Note: See also recent upgrade [Module|/Regexp/]...The "upgrade" command first runs an "r" command with the given arguments and then installs the newest versions of all modules that were listed by that. The four "CPAN::*" Classes: Author, Bundle, Module, DistributionAlthough it may be considered internal, the class hierarchy does matter for both users and programmer. CPAN.pm deals with the four classes mentioned above, and those classes all share a set of methods. 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 underscore 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 distribution file resides on CPAN relative to the authors/id/ 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. Integrating local directoriesNote: this feature is still in alpha state and may change in future versions of CPAN.pm Distribution objects are normally distributions from the CPAN, but there is a slightly degenerate case for Distribution objects, too, of projects held on the local disk. These distribution objects have the same name as the local directory and end with a dot. A dot by itself is also allowed for the current directory at the time CPAN.pm was used. All actions such as "make", "test", and "install" are applied directly to that directory. This gives the command "cpan ." an interesting touch: while the normal mantra of installing a CPAN module without CPAN.pm is one of perl Makefile.PL perl Build.PL
( go and get prerequisites )
make ./Build
make test ./Build test
make install ./Build install
the command "cpan ." does all of this at once. It figures out which of the two mantras is appropriate, fetches and installs all prerequisites, takes care of them recursively, and finally finishes the installation of the module in the current directory, be it a CPAN module or not. The typical usage case is for private modules or working copies of projects from remote repositories on the local disk. RedirectionThe usual shell redirection symbols " | " and ">" are recognized by the cpan shell only when surrounded by whitespace. So piping to pager or redirecting output into a file works somewhat as in a normal shell, with the stipulation that you must type extra spaces. Plugin support ***EXPERIMENTAL***Plugins are objects that implement any of currently eight methods: pre_get post_get pre_make post_make pre_test post_test pre_install post_install The "plugin_list" configuration parameter holds a list of strings of the form Modulename=arg0,arg1,arg2,arg3,... eg: CPAN::Plugin::Flurb=dir,/opt/pkgs/flurb/raw,verbose,1 At run time, each listed plugin is instantiated as a singleton object by running the equivalent of this pseudo code: my $plugin = <string representation from config>;
<generate Modulename and arguments from $plugin>;
my $p = $instance{$plugin} ||= Modulename->new($arg0,$arg1,...);
The generated singletons are kept around from instantiation until the end of the shell session. <plugin_list> can be reconfigured at any time at run time. While the cpan shell is running, it checks all activated plugins at each of the 8 reference points listed above and runs the respective method if it is implemented for that object. The method is called with the active CPAN::Distribution object passed in as an argument. CONFIGURATIONWhen the CPAN module is used for the first time, a configuration dialogue tries to determine a couple of site specific options. The result of the dialog is stored in a hash reference $CPAN::Config in a file CPAN/Config.pm. Default values defined in the CPAN/Config.pm file can be 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 mkmyconfig command writes this file for you. The "o conf" command has various bells and whistles:
The configuration dialog can be started any time later again by issuing the command " o conf init " in the CPAN shell. A subset of the configuration dialog can be run by issuing "o conf init WORD" where WORD is any valid config variable or a regular expression. Config VariablesThe following keys in the hash reference $CPAN::Config are currently defined: allow_installing_module_downgrades
allow or disallow installing module downgrades
allow_installing_outdated_dists
allow or disallow installing modules that are
indexed in the cpan index pointing to a distro
with a higher distro-version number
applypatch path to external prg
auto_commit commit all changes to config variables to disk
build_cache size of cache for directories to build modules
build_dir locally accessible directory to build modules
build_dir_reuse boolean if distros in build_dir are persistent
build_requires_install_policy
to install or not to install when a module is
only needed for building. yes|no|ask/yes|ask/no
bzip2 path to external prg
cache_metadata use serializer to cache metadata
check_sigs if signatures should be verified
cleanup_after_install
remove build directory immediately after a
successful install and remember that for the
duration of the session
colorize_debug Term::ANSIColor attributes for debugging output
colorize_output boolean if Term::ANSIColor should colorize output
colorize_print Term::ANSIColor attributes for normal output
colorize_warn Term::ANSIColor attributes for warnings
commandnumber_in_prompt
boolean if you want to see current command number
commands_quote preferred character to use for quoting external
commands when running them. Defaults to double
quote on Windows, single tick everywhere else;
can be set to space to disable quoting
connect_to_internet_ok
whether to ask if opening a connection is ok before
urllist is specified
cpan_home local directory reserved for this package
curl path to external prg
dontload_hash DEPRECATED
dontload_list arrayref: modules in the list will not be
loaded by the CPAN::has_inst() routine
ftp path to external prg
ftp_passive if set, the environment variable FTP_PASSIVE is set
for downloads
ftp_proxy proxy host for ftp requests
ftpstats_period max number of days to keep download statistics
ftpstats_size max number of items to keep in the download statistics
getcwd see below
gpg path to external prg
gzip location of external program gzip
halt_on_failure stop processing after the first failure of queued
items or dependencies
histfile file to maintain history between sessions
histsize maximum number of lines to keep in histfile
http_proxy proxy host for http requests
inactivity_timeout breaks interactive Makefile.PLs or Build.PLs
after this many seconds inactivity. Set to 0 to
disable timeouts.
index_expire refetch index files after this many days
inhibit_startup_message
if true, suppress the startup message
keep_source_where directory in which to keep the source (if we do)
load_module_verbosity
report loading of optional modules used by CPAN.pm
lynx path to external prg
make location of external make program
make_arg arguments that should always be passed to 'make'
make_install_make_command
the make command for running 'make install', for
example 'sudo make'
make_install_arg same as make_arg for 'make install'
makepl_arg arguments passed to 'perl Makefile.PL'
mbuild_arg arguments passed to './Build'
mbuild_install_arg arguments passed to './Build install'
mbuild_install_build_command
command to use instead of './Build' when we are
in the install stage, for example 'sudo ./Build'
mbuildpl_arg arguments passed to 'perl Build.PL'
ncftp path to external prg
ncftpget path to external prg
no_proxy don't proxy to these hosts/domains (comma separated list)
pager location of external program more (or any pager)
password your password if you CPAN server wants one
patch path to external prg
patches_dir local directory containing patch files
perl5lib_verbosity verbosity level for PERL5LIB additions
plugin_list list of active hooks (see Plugin support above
and the CPAN::Plugin module)
prefer_external_tar
per default all untar operations are done with
Archive::Tar; by setting this variable to true
the external tar command is used if available
prefer_installer legal values are MB and EUMM: if a module comes
with both a Makefile.PL and a Build.PL, use the
former (EUMM) or the latter (MB); if the module
comes with only one of the two, that one will be
used no matter the setting
prerequisites_policy
what to do if you are missing module prerequisites
('follow' automatically, 'ask' me, or 'ignore')
For 'follow', also sets PERL_AUTOINSTALL and
PERL_EXTUTILS_AUTOINSTALL for "--defaultdeps" if
not already set
prefs_dir local directory to store per-distro build options
proxy_user username for accessing an authenticating proxy
proxy_pass password for accessing an authenticating proxy
pushy_https use https to cpan.org when possible, otherwise use http
to cpan.org and issue a warning
randomize_urllist add some randomness to the sequence of the urllist
recommends_policy whether recommended prerequisites should be included
scan_cache controls scanning of cache ('atstart', 'atexit' or 'never')
shell your favorite shell
show_unparsable_versions
boolean if r command tells which modules are versionless
show_upload_date boolean if commands should try to determine upload date
show_zero_versions boolean if r command tells for which modules $version==0
suggests_policy whether suggested prerequisites should be included
tar location of external program tar
tar_verbosity verbosity level for the tar command
term_is_latin deprecated: if true Unicode is translated to ISO-8859-1
(and nonsense for characters outside latin range)
term_ornaments boolean to turn ReadLine ornamenting on/off
test_report email test reports (if CPAN::Reporter is installed)
trust_test_report_history
skip testing when previously tested ok (according to
CPAN::Reporter history)
unzip location of external program unzip
urllist arrayref to nearby CPAN sites (or equivalent locations)
urllist_ping_external
use external ping command when autoselecting mirrors
urllist_ping_verbose
increase verbosity when autoselecting mirrors
use_prompt_default set PERL_MM_USE_DEFAULT for configure/make/test/install
use_sqlite use CPAN::SQLite for metadata storage (fast and lean)
username your username if you CPAN server wants one
version_timeout stops version parsing after this many seconds.
Default is 15 secs. Set to 0 to disable.
wait_list arrayref to a wait server to try (See CPAN::WAIT)
wget path to external prg
yaml_load_code enable YAML code deserialisation via CPAN::DeferredCode
yaml_module which module to use to read/write YAML files
You can set and query each of these options interactively in the cpan shell with the "o conf" or the "o conf init" command as specified below.
CPAN::anycwd($path): Note on config variable getcwdCPAN.pm changes the current working directory often and needs to determine its own current working directory. By default it uses Cwd::cwd, but if for some reason this doesn't work on your system, configure alternatives according to the following table:
Note on the format of the urllist parameterurllist 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: file://localhost/whatever/ftp/pub/CPAN/ or file:///home/ftp/pub/CPAN/ The urllist parameter has CD-ROM supportThe "urllist" parameter of the configuration table contains a list of URLs used for downloading. If the list contains any "file" URLs, CPAN always tries 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 "file" URL at the end of urllist, e.g. o conf urllist push file://localhost/CDROM/CPAN 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 to see whether 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. Maintaining the urllist parameterIf you have YAML.pm (or some other YAML module configured in "yaml_module") installed, CPAN.pm collects a few statistical data about recent downloads. You can view the statistics with the "hosts" command or inspect them directly by looking into the "FTPstats.yml" file in your "cpan_home" directory. To get some interesting statistics, it is recommended that "randomize_urllist" be set; this introduces some amount of randomness into the URL selection. The "requires" and "build_requires" dependency declarationsSince CPAN.pm version 1.88_51 modules declared as "build_requires" by a distribution are treated differently depending on the config variable "build_requires_install_policy". By setting "build_requires_install_policy" to "no", such a module is not installed. It is only built and tested, and then kept in the list of tested but uninstalled modules. As such, it is available during the build of the dependent module by integrating the path to the "blib/arch" and "blib/lib" directories in the environment variable PERL5LIB. If "build_requires_install_policy" is set to "yes", then both modules declared as "requires" and those declared as "build_requires" are treated alike. By setting to "ask/yes" or "ask/no", CPAN.pm asks the user and sets the default accordingly. Configuration of the allow_installing_* parametersThe "allow_installing_*" parameters are evaluated during the "make" phase. If set to "yes", they allow the testing and the installation of the current distro and otherwise have no effect. If set to "no", they may abort the build (preventing testing and installing), depending on the contents of the "blib/" directory. The "blib/" directory is the directory that holds all the files that would usually be installed in the "install" phase. "allow_installing_outdated_dists" compares the "blib/" directory with the CPAN index. If it finds something there that belongs, according to the index, to a different dist, it aborts the current build. "allow_installing_module_downgrades" compares the "blib/" directory with already installed modules, actually their version numbers, as determined by ExtUtils::MakeMaker or equivalent. If a to-be-installed module would downgrade an already installed module, the current build is aborted. An interesting twist occurs when a distroprefs document demands the installation of an outdated dist via goto while "allow_installing_outdated_dists" forbids it. Without additional provisions, this would let the "allow_installing_outdated_dists" win and the distroprefs lose. So the proper arrangement in such a case is to write a second distroprefs document for the distro that "goto" points to and overrule the "cpanconfig" there. E.g.: ---
match:
distribution: "^MAUKE/Keyword-Simple-0.04.tar.gz"
goto: "MAUKE/Keyword-Simple-0.03.tar.gz"
---
match:
distribution: "^MAUKE/Keyword-Simple-0.03.tar.gz"
cpanconfig:
allow_installing_outdated_dists: yes
Configuration for individual distributions (Distroprefs)(Note: This feature has been introduced in CPAN.pm 1.8854) Distributions on CPAN usually behave according to what we call the CPAN mantra. Or since the advent of Module::Build we should talk about two mantras: perl Makefile.PL perl Build.PL
make ./Build
make test ./Build test
make install ./Build install
But some modules cannot be built with this mantra. They try to get some extra data from the user via the environment, extra arguments, or interactively--thus disturbing the installation of large bundles like Phalanx100 or modules with many dependencies like Plagger. The distroprefs system of "CPAN.pm" addresses this problem by allowing the user to specify extra informations and recipes in YAML files to either
See the YAML and Data::Dumper files that come with the "CPAN.pm" distribution in the "distroprefs/" directory for examples. FilenamesThe YAML files themselves must have the ".yml" extension; all other files are ignored (for two exceptions see Fallback Data::Dumper and Storable below). The containing directory can be specified in "CPAN.pm" in the "prefs_dir" config variable. Try "o conf init prefs_dir" in the CPAN shell to set and activate the distroprefs system. Every YAML file may contain arbitrary documents according to the YAML specification, and every document is treated as an entity that can specify the treatment of a single distribution. Filenames can be picked arbitrarily; "CPAN.pm" always reads all files (in alphabetical order) and takes the key "match" (see below in Language Specs) as a hashref containing match criteria that determine if the current distribution matches the YAML document or not. Fallback Data::Dumper and StorableIf neither your configured "yaml_module" nor YAML.pm is installed, CPAN.pm falls back to using Data::Dumper and Storable and looks for files with the extensions ".dd" or ".st" in the "prefs_dir" directory. These files are expected to contain one or more hashrefs. For Data::Dumper generated files, this is expected to be done with by defining $VAR1, $VAR2, etc. The YAML shell would produce these with the command ysh < somefile.yml > somefile.dd For Storable files the rule is that they must be constructed such that Storable::retrieve(file) returns an array reference and the array elements represent one distropref object each. The conversion from YAML would look like so: perl -MYAML=LoadFile -MStorable=nstore -e '
@y=LoadFile(shift);
nstore(\@y, shift)' somefile.yml somefile.st
In bootstrapping situations it is usually sufficient to translate only a few YAML files to Data::Dumper for crucial modules like "YAML::Syck", "YAML.pm" and "Expect.pm". If you prefer Storable over Data::Dumper, remember to pull out a Storable version that writes an older format than all the other Storable versions that will need to read them. BlueprintThe following example contains all supported keywords and structures with the exception of "eexpect" which can be used instead of "expect". ---
comment: "Demo"
match:
module: "Dancing::Queen"
distribution: "^CHACHACHA/Dancing-"
not_distribution: "\.zip$"
perl: "/usr/local/cariba-perl/bin/perl"
perlconfig:
archname: "freebsd"
not_cc: "gcc"
env:
DANCING_FLOOR: "Shubiduh"
disabled: 1
cpanconfig:
make: gmake
pl:
args:
- "--somearg=specialcase"
env: {}
expect:
- "Which is your favorite fruit"
- "apple\n"
make:
args:
- all
- extra-all
env: {}
expect: []
commandline: "echo SKIPPING make"
test:
args: []
env: {}
expect: []
install:
args: []
env:
WANT_TO_INSTALL: YES
expect:
- "Do you really want to install"
- "y\n"
patches:
- "ABCDE/Fedcba-3.14-ABCDE-01.patch"
depends:
configure_requires:
LWP: 5.8
build_requires:
Test::Exception: 0.25
requires:
Spiffy: 0.30
Language SpecsEvery YAML document represents a single hash reference. The valid keys in this hash are as follows:
Processing Instructions
Schema verification with "Kwalify"If you have the "Kwalify" module installed (which is part of the Bundle::CPANxxl), then all your distroprefs files are checked for syntactic correctness. Example Distroprefs Files"CPAN.pm" comes with a collection of example YAML files. Note that these are really just examples and should not be used without care because they cannot fit everybody's purpose. After all, the authors of the packages that ask questions had a need to ask, so you should watch their questions and adjust the examples to your environment and your needs. You have been warned:-) PROGRAMMER'S INTERFACEIf you do not enter the shell, shell commands are available both as methods ("CPAN::Shell->install(...)") and as functions in the calling package (install(...)). Before calling low-level commands, it makes sense to initialize components of CPAN you need, e.g.: CPAN::HandleConfig->load; CPAN::Shell::setup_output; CPAN::Index->reload; High-level commands do such initializations automatically. 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. The arguments on the commandline are passed as arguments to the method. So if you take for example the shell command notest install A B C the actually executed command is CPAN::Shell->notest("install","A","B","C");
Each of the commands that produce listings of modules ("r", "autobundle", "u") also return a list of the IDs of all modules within the list.
Methods in the other Classes
Cache ManagerCurrently 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 "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. BundlesA 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 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, i.e. 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. PREREQUISITESThe CPAN program is trying to depend on as little as possible so the user can use it in hostile environment. It works better the more goodies the environment provides. For example if you try in the CPAN shell install Bundle::CPAN or install Bundle::CPANxxl you will find the shell more convenient than the bare shell before. If you have a local mirror of CPAN and can access all files with "file:" URLs, then you only need a perl later 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 "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. UTILITIESFinding packages and VERSIONThis module presumes that all packages on CPAN
DebuggingDebugging this module is more than a bit complex due to interference from the software producing the indices on CPAN, the mirroring process on CPAN, packaging, configuration, synchronicity, and even (gasp!) due to bugs within the CPAN.pm module itself. For debugging the code of CPAN.pm itself in interactive mode, some debugging aid can be turned on for most packages within CPAN.pm with one of
which sets the debugging packages directly. Note that "o debug 0" turns debugging off. What seems a successful strategy is the combination of "reload cpan" and the debugging switches. Add a new debug statement while running in the shell and then issue a "reload cpan" and see the new debugging messages immediately without losing the current context. "o debug" without an argument lists the valid package names and the current set of packages in debugging mode. "o debug" has built-in completion support. For debugging of CPAN data there is the "dump" command which takes the same arguments as make/test/install and outputs each object's Data::Dumper dump. If an argument looks like a perl variable and contains one of "$", "@" or "%", it is eval()ed and fed to Data::Dumper directly. Floppy, Zip, Offline ModeCPAN.pm works nicely without network access, too. If you maintain machines that are not networked at all, you should consider working with "file:" URLs. You'll 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. Basic Utilities for Programmers
SECURITYThere's no strong security layer in CPAN.pm. CPAN.pm helps you to install foreign, unmasked, unsigned code on your machine. We compare to a checksum that comes from the net just as the distribution file itself. But we try to make it easy to add security on demand: Cryptographically signed modulesSince release 1.77, CPAN.pm has been able to verify cryptographically signed module distributions using Module::Signature. The CPAN modules can be signed by their authors, thus giving more security. The simple unsigned MD5 checksums that were used before by CPAN protect mainly against accidental file corruption. You will need to have Module::Signature installed, which in turn requires that you have at least one of Crypt::OpenPGP module or the command-line gpg tool installed. You will also need to be able to connect over the Internet to the public key servers, like pgp.mit.edu, and their port 11731 (the HKP protocol). The configuration parameter check_sigs is there to turn signature checking on or off. EXPORTMost functions in package CPAN are exported by default. The reason for this is that the primary use is intended for the cpan shell or for one-liners. ENVIRONMENTWhen the CPAN shell enters a subshell via the look command, it sets the environment CPAN_SHELL_LEVEL to 1, or increments that variable if it is already set. When CPAN runs, it sets the environment variable PERL5_CPAN_IS_RUNNING to the ID of the running process. It also sets PERL5_CPANPLUS_IS_RUNNING to prevent runaway processes which could happen with older versions of Module::Install. When running "perl Makefile.PL", the environment variable "PERL5_CPAN_IS_EXECUTING" is set to the full path of the "Makefile.PL" that is being executed. This prevents runaway processes with newer versions of Module::Install. When the config variable ftp_passive is set, all downloads will be run with the environment variable FTP_PASSIVE set to this value. This is in general a good idea as it influences both Net::FTP and LWP based connections. The same effect can be achieved by starting the cpan shell with this environment variable set. For Net::FTP alone, one can also always set passive mode by running libnetcfg. POPULATE AN INSTALLATION WITH LOTS OF MODULESPopulating a freshly installed perl with one's 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 installed for the current perl interpreter. It's recommended to run this command once only, 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 go out for coffee (possibly even in a different city). 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 annoying that so many distributions need some interactive configuring. So what you can try to accomplish in your private bundle file is to have the packages that need to be configured early in the file and the gentle ones later, so you can go out for coffee after a few minutes and leave CPAN.pm to churn away unattended. WORKING WITH CPAN.pm BEHIND FIREWALLSThanks to Graham Barr for contributing the following paragraphs about the interaction between perl, and various firewall configurations. For further information 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 likely that you can configure ncftp so that it works through your firewall. Three basic types of firewallsFirewalls can be categorized into three basic types.
Configuring lynx or ncftp for going through a firewallIf you can go through your firewall with e.g. lynx, presumably with a command such as /usr/local/bin/lynx -pscott:tiger then you would configure CPAN.pm with the command o conf lynx "/usr/local/bin/lynx -pscott:tiger" That's all. Similarly for ncftp or ftp, you would configure something like o conf ncftp "/usr/bin/ncftp -f /home/scott/ncftplogin.cfg" Your mileage may vary... FAQ
COMPATIBILITYOLD PERL VERSIONSCPAN.pm is regularly tested to run under 5.005 and assorted newer versions. It is getting more and more difficult to get the minimal prerequisites working on older perls. It is close to impossible to get the whole Bundle::CPAN working there. If you're in the position to have only these old versions, be advised that CPAN is designed to work fine without the Bundle::CPAN installed. To get things going, note that GBARR/Scalar-List-Utils-1.18.tar.gz is compatible with ancient perls and that File::Temp is listed as a prerequisite but CPAN has reasonable workarounds if it is missing. CPANPLUSThis module and its competitor, the CPANPLUS module, are both much cooler than the other. CPAN.pm is older. CPANPLUS was designed to be more modular, but it was never intended to be compatible with CPAN.pm. CPANMINUSIn the year 2010 App::cpanminus was launched as a new approach to a cpan shell with a considerably smaller footprint. Very cool stuff. SECURITY ADVICEThis software enables you to upgrade software on your computer and so is inherently dangerous because the newly installed software may contain bugs and may alter the way your computer works or even make it unusable. Please consider backing up your data before every upgrade. BUGSPlease report bugs via <http://rt.cpan.org/> Before submitting a bug, please make sure that the traditional method of building a Perl module package from a shell by following the installation instructions of that package still works in your environment. AUTHORAndreas Koenig "<andk@cpan.org>" LICENSEThis program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See <http://www.perl.com/perl/misc/Artistic.html> TRANSLATIONSKawai,Takanori provides a Japanese translation of a very old version of this manpage at <http://homepage3.nifty.com/hippo2000/perltips/CPAN.htm> SEE ALSOMany people enter the CPAN shell by running the cpan utility program which is installed in the same directory as perl itself. So if you have this directory in your PATH variable (or some equivalent in your operating system) then typing "cpan" in a console window will work for you as well. Above that the utility provides several commandline shortcuts. melezhik (Alexey) sent me a link where he published a chef recipe to work with CPAN.pm: http://community.opscode.com/cookbooks/cpan.
|