NAME
CPAN::Mini - create a minimal mirror of CPAN
VERSION
version 0.36
$Id: Mini.pm,v 1.18 2005/01/06 23:40:22 rjbs Exp $
SYNOPSIS
(If you're not going to do something weird, you probably want to look at the minicpan command, instead.)
use CPAN::Mini;
CPAN::Mini->update_mirror(
remote => "http://cpan.mirrors.comintern.su",
local => "/usr/share/mirrors/cpan",
trace => 1
);
DESCRIPTION
CPAN::Mini provides a simple mechanism to build and update a minimal mirror of the CPAN on your local disk. It contains only those files needed to install the newest version of every distribution. Those files are:
01mailrc.txt.gz
02packages.details.txt.gz
03modlist.data.gz
the last non-developer release of every dist for every author
METHODS
update_mirror( %args )
CPAN::Mini->update_mirror(
remote => "http://cpan.mirrors.comintern.su",
local => "/usr/share/mirrors/cpan",
force => 0,
trace => 1
);
This is the only method that need be called from outside this module. It will update the local mirror with the files from the remote mirror.
If called as a class method, update_mirror
creates an ephemeral CPAN::Mini object on which other methods are called. That object is used to store mirror location and state.
This method returns the number of files updated.
The following options are recognized:
dirmode
Generally an octal number, this option sets the permissions of created directories. It defaults to 0711.
force
If true, this option will cause CPAN::Mini to read the entire module list and update anything out of date, even if the module list itself wasn't out of date on this run.
skip_perl
If true, CPAN::Mini will skip the major language distributions: perl, parrot, and ponie.
trace
If true, CPAN::Mini will print status messages to STDOUT as it works.
path_filters
This options provides a set of rules for filtering paths. If a distribution matches one of the rules in
path_filters
, it will not be mirrored. A regex rule is matched if the path matches the regex; a code rule is matched if the code returns 1 when the path is passed to it. For example, the following setting would skip all distributions from RJBS and SUNGO:path_filters => [ qr/RJBS/, sub { $_[0] =~ /SUNGO/ } ]
module_filters
This options provides a set of rules for filtering modules. It behaves like path_filters, but acts only on module names. (Since most modules are in distributions with more than one module, this setting will probably be less useful than
path_filters
.) For example, this setting will skip any distribution containing only modules with the word "Acme" in them:module_filters => [ qr/Acme/i ]
skip_cleanup
If this option is true, CPAN::Mini will not try delete unmirrored files when it has finished mirroring
new
This method constructs a new CPAN::Mini object. Its parameters are described above, under update_mirror
.
mirror_indices
This method updates the index files from the CPAN.
mirror_file($path, $skip_if_present)
This method will mirror the given file from the remote to the local mirror, overwriting any existing file unless $skip_if_present
is true.
file_allowed($file)
This method returns true if the given file is allowed to exist in the local mirror, even if it isn't one of the required mirror files.
By default, only dot-files are allowed.
clean_unmirrored
This method finds any files in the local mirror which are no longer needed and calls the clean_file
method on them.
clean_file($filename)
This method, called by clean_unmirrored
, checks whether the named file exists. If it exists, and was not mirrored, and file_allowed
doesn't say it can stay, the file is deleted.
trace( $message, $force )
If the object is mirroring verbosely, this method will print messages sent to it. If CPAN::Mini is not operating in verbose mode, but $force
is true, it will print the message anyway.
SEE ALSO
Randal Schwartz's original article on minicpan, here:
http://www.stonehenge.com/merlyn/LinuxMag/col42.html
CPANPLUS::Backend, which provides the local_mirror
method, which performs the same task as this module.
THANKS
Thanks to David Dyck for letting me know about my stupid documentation errors.
Thanks to Roy Fulbright for finding an obnoxious bug on Win32.
Thanks to Shawn Sorichetti for fixing a stupid octal-number-as-string bug.
Thanks to sungo for implementing the filters, so I can finally stop mirroring bioperl, and Robert Rothenberg for suggesting adding coderef rules.
AUTHORS
Randal Schwartz <merlyn@stonehenge.com> did all the work.
Ricardo SIGNES <rjbs@cpan.org> made a module and distribution.
This code was copyrighted in 2004, and is released under the same terms as Perl itself.