|
CPAN::Mini - create a minimal mirror of CPAN |
CPAN::Mini - create a minimal mirror of CPAN
version 0.562
$Id: /my/cs/projects/CPAN-Mini/trunk/lib/CPAN/Mini.pm 31971 2007-07-04T12:57:59.792487Z rjbs $
(If you're not going to do something weird, you probably want to look at the the minicpan manpage command, instead.)
use CPAN::Mini;
CPAN::Mini->update_mirror( remote => "http://cpan.mirrors.comintern.su", local => "/usr/share/mirrors/cpan", trace => 1 );
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:
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:
dirmodeexact_mirrorfiles_allowed method will allow all extra files to be mirrored.
forceskip_perltraceerrorspath_filterspath_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_filterspath_filters.) For example, this setting will skip any
distribution containing only modules with the word ``Acme'' in them:
module_filters => [ qr/Acme/i ]
also_mirrorskip_cleanup
my $minicpan = CPAN::Mini->new;
This method constructs a new CPAN::Mini object. Its parameters are described
above, under update_mirror.
$minicpan->mirror_indices;
This method updates the index files from the CPAN.
$minicpan->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.
next unless $minicpan->file_allowed($filename);
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. If the exact_mirror option is true,
all files are allowed.
$minicpan->clean_unmirrored;
This method looks through the local mirror's files. If it finds a file that
neither belongs in the mirror nor is allowed (see the file_allowed method),
clean_file is called on the file.
$minicpan->clean_file($filename);
This method, called by clean_unmirrored, deletes the named file. It returns
true if the file is successfully unlinked. Otherwise, it returns false.
$minicpan->trace($message);
If the object is mirroring verbosely, this method will print messages sent to it.
my %config = CPAN::Mini->read_config;
This routine returns a set of arguments that can be passed to CPAN::Mini's
new or update_mirror methods. It will look for a file called
.minicpanrc in the user's home directory as determined by
File::HomeDir.
Randal Schwartz's original article on minicpan, here:
http://www.stonehenge.com/merlyn/LinuxMag/col42.html
the CPANPLUS::Backend manpage, which provides the local_mirror method, which performs
the same task as this module.
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.
Thanks to Adam Kennedy for noticing and complaining about a lot of stupid little design decisions.
Thanks to Michael Schwern and Jason Kohles, for pointing out missing documentation.
Randal Schwartz <merlyn@stonehenge.com> wrote the original minicpan script.
Ricardo SIGNES <rjbs@cpan.org> turned Randal's script into a module and CPAN distribution, and has maintained it since its release as such.
This code was copyrighted in 2004, and is released under the same terms as Perl itself.
|
CPAN::Mini - create a minimal mirror of CPAN |