CPAN::Mini(3)
π CPAN::Mini(3) π
Okay bestie, welcome to the CPAN::Mini(3) page from the User Contributed Perl Documentation. This is all about making a minimal mirror of CPAN, and yes, itβs giving major βI can have a tiny CPAN at homeβ energy. π«Ά
β¨ NAME β¨
CPAN::Mini β create a minimal mirror of CPAN π
π VERSION π
version 1.111017 β¨
π¦ SYNOPSIS π¦
Bestie, 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",
log_level => 'debug',
);
π DESCRIPTION π
CPAN::Mini gives you 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.gz02packages.details.txt.gz03modlist.data.gz- the last non-developer release of every dist for every author
Itβs literally the βjust the essentialsβ mirror. So organized. So iconic. π
πΈ PERL VERSION πΈ
This library should run on perls released even a long time ago. It should work on any version of perl released in the last five years. π§
Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.
So yeah β old perl might work, but itβs not a forever promise. π
π οΈ METHODS π οΈ
update_mirror
CPAN::Mini->update_mirror(
remote => "http://cpan.mirrors.comintern.su",
local => "/usr/share/mirrors/cpan",
force => 0,
log_level => 'debug',
);
This is the only method that needs to 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. Periodt. π
The following options are recognized:
localβ this is the local file path where the mirror will be written or updated.remoteβ this is the URL of the CPAN mirror from which to work. A reasonable default will be picked by default. A list of CPAN mirrors can be found at<http://www.cpan.org/SITES.html>.dirmodeβ generally an octal number, this option sets the permissions of created directories. It defaults to0711.exact_mirrorβ if true, thefile_allowedmethod will allow all extra files to be mirrored.ignore_source_controlβ if true,CPAN::Miniwill not try to remove source control files during cleanup. Seeclean_unmirroredfor details.forceβ if true, this option will causeCPAN::Minito 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::Miniwill skip the major language distributions:perl,parrot, andponie. It will also skipembperl,sybperl,bioperl, andkurila.log_levelβ this defines the minimum level of message to log:debug,info,warn, orfatal.errorsβ if true,CPAN::Miniwill warn with status messages on errors. (default: true)path_filtersβ this option provides a set of rules for filtering paths. If a distribution matches one of the rules inpath_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 returns1when the path is passed to it. For example, the following setting would skip all distributions fromRJBSandSUNGO:
path_filters => [
qr/RJBS/,
sub { $_[0] =~ /SUNGO/ }
]
module_filtersβ this option provides a set of rules for filtering modules. It behaves likepath_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 thanpath_filters.) For example, this setting will skip any distribution containing only modules with the word βAcmeβ in them:
module_filters => [ qr/Acme/i ]
also_mirrorβ this option should be an arrayref of extra files in the remote CPAN to mirror locally.skip_cleanupβ if this option is true,CPAN::Miniwill not try to delete unmirrored files when it has finished mirroring.offlineβ if offline,CPAN::Miniwill not attempt to contact remote resources.no_conn_cacheβ if true, no connection cache will be established. This is mostly useful as a workaround for connection cache failures.
new
my $minicpan = CPAN::Mini->new;
This method constructs a new CPAN::Mini object. Its parameters are described above, under update_mirror. β¨
mirror_indices
$minicpan->mirror_indices;
This method updates the index files from the CPAN. πͺ
mirror_file
$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.
file_allowed
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.
clean_unmirrored
$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. π§Ή
If you set ignore_source_control to a true value, then this doesnβt clean up files that belong to source control systems. Currently this ignores:
.cvs .cvsignore
.svn .svnignore
.git .gitignore
Send patches for other source control files that you would like to have added. π«Ά
clean_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. π
log_warn / log / log_debug
$minicpan->log($message);
This will log (print) the given message unless the log level is too low. π¬
log, which logs at the info level, may also be called as trace for backward compatibility reasons.
read_config
my %config = CPAN::Mini->read_config(\%options);
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. π
config_file
my $config_file = CPAN::Mini->config_file( { options } );
This routine returns the config file name. It first looks for the config_file setting, then the CPAN_MINI_CONFIG environment variable, then the default ~/.minicpanrc, and finally the CPAN/Mini/minicpan.conf. It uses the first defined value it finds. If the filename it selects does not exist, it returns false. π
OPTIONS is an optional hash reference of the CPAN::Mini config hash.
remote_from
my $remote = CPAN::Mini->remote_from( $remote_from, $orig_remote, $quiet );
This routine takes a string argument and turns it into a method call to handle retrieving a CPAN mirror URL from a source. Currently supported methods:
cpan - fetch the first mirror from your CPAN.pm config
cpanplus - fetch the first mirror from your CPANPLUS.pm config
remote_from_cpan
my $remote = CPAN::Mini->remote_from_cpan;
This routine loads your CPAN.pm config and returns the first mirror in the mirror list. You can set this as your default by setting remote_from:cpan in your .minicpanrc file. π
remote_from_cpanplus
my $remote = CPAN::Mini->remote_from_cpanplus;
This routine loads your CPANPLUS.pm config and returns the first mirror in the mirror list. You can set this as your default by setting remote_from:cpanplus in your .minicpanrc file. π
π 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. π
- 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.
- Thanks to David Golden for some important bugfixes and refactoring. β¨
π AUTHORS π
- Ricardo SIGNES
<cpan@semiotic.systems> - Randal Schwartz
<merlyn@stonehenge.com>
π CONTRIBUTORS π
- Brian Wightman
<MidLifeXis@wightmanfam.org> - David Golden
<dagolden@cpan.org> - Fabrice Gabolde
<fgabolde@weborama.com> - Gabor Szabo
<gabor@szabgab.com> - Jeff Bisbee
<jbisbee@cpan.org> - Jeffrey Thalhammer
<jeff@imaginative-software.com> - Ricardo Signes
<rjbs@semiotic.systems> - Stephen Thirlwall
<sdt@dr.com>
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2004 by Ricardo SIGNES.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. π«Ά
Final vibe check: this page comes from perl v5.42.0, dated 2023-09-05, and itβs CPAN::Mini(3) β byeee π
β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-CPAN-Mini 1.111017-bp160.1.11 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms