lcpan - Manage your local CPAN mirror
This document describes version 0.01 of lcpan (from Perl distribution CPAN-Local), released on 2015-01-13.
% lcpan update
A mini CPAN mirror will be downloaded in your ~/cpan directory. This will take a while (it downloads +- 4GB of files, as of this writing; subsequent update will of course take shorter time.)
~/cpan
A SQLite database is also created/updated in ~/cpan/index.db which contains information about authors, modules/packages, distributions. This database is used for quickly answer various queries.
~/cpan/index.db
You can run the above command e.g. daily to keep your mirror up-to-date.
% cpanm --mirror ~/cpan --mirror-only -n Some::Module
You can also set up a shell alias to save typing the options all the time, e.g.:
alias lcpanm="cpanm --mirror ~/cpan --mirror-only -n"
Then you can install modules simply using:
% lcpanm Some::Module
Info about your local CPAN mirror:
% lcpan stats +------------------+----------------------+ | name | value | +------------------+----------------------+ | authors | 11967 | | distributions | 29907 | | last-updated | 2015-01-09T10:40:55Z | | modules | 13365 | | packages | 133650 | +------------------+----------------------+
Add --verbose if you want more stats which normally are skipped because they can take a while to get (e.g. disk-space).
--verbose
List modules:
% lcpan modules
List modules matching some query (name):
% lcpan modules smtp
List modules by certain author, show detail instead of just module names:
% lcpan modules --author PERLANCAR --detail
List modules from a certain dist:
% lcpan modules --dist libwww-perl --detail
List distributions:
% lcpan dists
List distributions matching some query (name, filename, abstract), show detail instead of just distribution name:
% lcpan dists critic --detail
List distributions released by a certain author:
% lcpan dists --author PERLANCAR
List authors:
% lcpan authors
List authors matching some query (PAUSE ID, name, email), show detail instead of just ID:
% lcpan authors tatsuhiko --detail
Show dependencies and reverse dependencies:
# which modules does Text::ANSITable depend on? % lcpan deps Text::ANSITable # do it recursively % lcpan deps Text::ANSITable -R # which distributions depend on Text::ANSITable? % lcpan rev-deps Text::ANSITable
This application is a convenient bundling of CPAN::Mini and an indexer so in addition to creating your local CPAN mirror and installing modules from it, you can also query various things about your local CPAN mirror quickly from the command-line (as well as programmatically).
CPAN::Mini
List authors in local CPAN.
List dependencies of a module, data from local CPAN.
List distributions in local CPAN.
List packages in local CPAN.
List reverse dependencies of a module, data from local CPAN.
* marks required options.
*
Set path to configuration file.
Can be specified multiple times.
Set configuration profile to use.
Set log level to debug.
Choose output format, e.g. json, text.
Display this help message.
Set output format to json.
Set log level.
When outputing as JSON, strip result envelope.
By default, when outputing as JSON, the full enveloped result is returned, e.g.:
[200,"OK",[1,2,3],{"func.extra"=>4}]
The reason is so you can get the status (1st element), status message (2nd element) as well as result metadata/extra result (4th element) instead of just the result (3rd element). However, sometimes you want just the result, e.g. when you want to pipe the result for more post-processing. In this case you can use `--naked-res` so you just get:
[1,2,3]
Do not use any configuration file.
Set log level to quiet.
List available subcommands.
Set log level to trace.
Set log level to info.
Location of your local CPAN mirror, e.g. /path/to/cpan.
Defaults to ~/cpan.
Search query.
Include Perl core modules.
Recurse for a number of levels (-1 means unlimited).
Default value:
1
Set base Perl version for determining core modules.
"v5.18.4"
"runtime"
Valid values:
["develop", "configure", "build", "runtime", "test", "ALL"]
"requires"
["requires", "recommends", "suggests", "conflicts", "ALL"]
Recurse (alias for `--level -1`).
See --level.
--level
Filter by author.
Filter by distribution.
LCPAN_OPT
~/lcpan.conf
/etc/lcpan.conf
This script has shell tab completion capability with support for several shells.
To activate bash completion for this script, put:
complete -C lcpan lcpan
in your bash startup (e.g. ~/.bashrc). Your next shell session will then recognize tab completion for the command. Or, you can also directly execute the line above in your shell to activate immediately.
~/.bashrc
It is recommended, however, that you install shcompgen which allows you to activate completion scripts for several kinds of scripts on multiple shells. Some CPAN distributions (those that are built with Dist::Zilla::Plugin::GenShellCompletion) will even automatically enable shell completion for their included scripts (using shcompgen) at installation time, so you can immadiately have tab completion.
shcompgen
To activate tcsh completion for this script, put:
complete lcpan 'p/*/`lcpan`/'
in your tcsh startup (e.g. ~/.tcshrc). Your next shell session will then recognize tab completion for the command. Or, you can also directly execute the line above in your shell to activate immediately.
~/.tcshrc
It is also recommended to install shcompgen (see above).
For fish and zsh, install shcompgen as described above.
Please visit the project's homepage at https://metacpan.org/release/CPAN-Local.
Source repository is at https://github.com/perlancar/perl-CPAN-Local.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=CPAN-Local
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
perlancar <perlancar@cpan.org>
This software is copyright (c) 2015 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install CPAN::Local, copy and paste the appropriate command in to your terminal.
cpanm
cpanm CPAN::Local
CPAN shell
perl -MCPAN -e shell install CPAN::Local
For more information on module installation, please visit the detailed CPAN module installation guide.