CPANPL...Backend(3pm)

πŸ“¦
version 0.9916 Β· 5 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– CPANPL...Backend πŸ’–

okay so this is the manual page for CPANPL...Backend(3pm) β€” officially part of the User Contributed Perl Documentation fam, and bestie, it's the main character of the CPANPLUS cinematic universe. buckle up. πŸŽ€


✨ NAME ✨

CPANPLUS::Backend β€” the programmer's interface to CPANPLUS. like, the actual API you talk to when you wanna do CPANPLUS things from your own code. it's giving backstage pass. πŸ’…


🌸 SYNOPSIS 🌸

my $cb      = CPANPLUS::Backend->new;
my $conf    = $cb->configure_object;

my $author  = $cb->author_tree('KANE');
my $mod     = $cb->module_tree('Some::Module');
my $mod     = $cb->parse_module( module => 'Some::Module' );

my @objs    = $cb->search(  type    => TYPE,
                            allow   => [...] );

$cb->flush('all');
$cb->reload_indices;
$cb->local_mirror;

πŸ¦‹ DESCRIPTION πŸ¦‹

This module hands you the programmer's interface to the CPANPLUS libraries. that's it, that's the whole vibe. everything else is just how you use it. ✨


🌈 ENVIRONMENT 🌈

The moment CPANPLUS::Backend gets loaded β€” which is necessary for pretty much every <CPANPLUS> operation, no skips β€” the environment variable PERL5_CPANPLUS_IS_RUNNING gets set to the current process id. slay. 🫢

Also, the environment variable PERL5_CPANPLUS_IS_VERSION gets set to the version of CPANPLUS::Backend.

And apparently this info might be useful somehow to spawned processes. iykyk. πŸ’œ


πŸ‘‘ METHODS πŸ‘‘

πŸ’– $cb = CPANPLUS::Backend->new( [CONFIGURE_OBJ] )

This method returns a brand new CPANPLUS::Backend object. it also initialises the config that goes with this object. you've got two choices here, bestie, pick your fighter:

  • Provide a valid CPANPLUS::Configure object β€” it will be used verbatim. no edits, no notes, just straight up as-is.
  • No arguments β€” your default config gets loaded and used.

new will return a CPANPLUS::Backend object on success and die on failure. dramatic but fair. πŸ’€


🌸 $href = $cb->module_tree( [@modules_names_list] )

Returns a reference to the CPANPLUS module tree. the whole tree. iconic.

If you give it any arguments, they get treated as module names, and module_tree will try to look up those module names and hand you back the corresponding module objects instead.

See CPANPLUS::Module for the operations you can perform on a module object.


πŸŽ€ $href = $cb->author_tree( [@author_names_list] )

Returns a reference to the CPANPLUS author tree. (yes, authors get a tree too, they're valid πŸ’…)

If you give it any arguments, they get treated as author names, and author_tree will try to look up those author names and return the corresponding author objects instead.

See CPANPLUS::Module::Author for the operations you can perform on an author object.


✨ $conf = $cb->configure_object;

Returns a copy of the CPANPLUS::Configure object. a copy, okay, remember that.

See CPANPLUS::Configure for operations you can perform on a configure object.


πŸ¦‹ $su = $cb->selfupdate_object;

Returns a copy of the CPANPLUS::Selfupdate object.

See the CPANPLUS::Selfupdate manpage for the operations you can perform on the selfupdate object. go read it, it's right there. 🫢


πŸ’œ @mods = $cb->search( type => TYPE, allow => AREF, [data => AREF, verbose => BOOL] )

search lets you go looking for either module or author objects, based on their data. the type you can specify is any of the accessors specified in CPANPLUS::Module::Author or CPANPLUS::Module. search figures out from the type you gave it whether it should be searching by author object or module object. it's smart like that.

You have to specify an array reference of regular expressions or strings to match against. the rules used for this array ref are the same as in Params::Check, so go read that manpage for the details. no skipping.

The search is an "or" search, meaning that if any of the criteria match, the search counts as successful. we're not picky, we're welcoming. πŸ’–

You can also pass in the result of a previous search as data, which limits the new search to those module or author objects instead of the entire module or author tree. that's literally how you do "and" searches. queen behaviour.

Returns a list of module or author objects on success, and false on failure. 😭

See CPANPLUS::Module for the operations you can perform on a module object. See CPANPLUS::Module::Author for the operations you can perform on an author object.


πŸ”₯ $backend_rv = $cb->fetch( modules => \@mods )

Fetches a list of modules. @mods can be a list of distribution names, module names or module objects β€” basically anything that parse_module can understand. it's flexible fr fr.

See the equivalent method in CPANPLUS::Module for details on other options you can pass.

Since this is a multi-module method call, the return value is implemented as a CPANPLUS::Backend::RV object. please consult that module's documentation on how to interpret the return value. don't just stare at it, read the docs. πŸ™ˆ


🌈 $backend_rv = $cb->extract( modules => \@mods )

Extracts a list of modules. @mods can be a list of distribution names, module names or module objects β€” basically anything that parse_module can understand.

See the equivalent method in CPANPLUS::Module for details on other options you can pass.

Since this is a multi-module method call, the return value is implemented as a CPANPLUS::Backend::RV object. please consult that module's documentation on how to interpret the return value.


⭐ $backend_rv = $cb->install( modules => \@mods )

Installs a list of modules. @mods can be a list of distribution names, module names or module objects β€” basically anything that parse_module can understand.

See the equivalent method in CPANPLUS::Module for details on other options you can pass.

Since this is a multi-module method call, the return value is implemented as a CPANPLUS::Backend::RV object. please consult that module's documentation on how to interpret the return value.


πŸ“ $backend_rv = $cb->readme( modules => \@mods )

Fetches the readme for a list of modules. @mods can be a list of distribution names, module names or module objects β€” basically anything that parse_module can understand.

See the equivalent method in CPANPLUS::Module for details on other options you can pass.

Since this is a multi-module method call, the return value is implemented as a CPANPLUS::Backend::RV object. please consult that module's documentation on how to interpret the return value.


🧚 $backend_rv = $cb->files( modules => \@mods )

Returns a list of files used by these modules if they are installed. conditional queen. @mods can be a list of distribution names, module names or module objects β€” basically anything that parse_module can understand.

See the equivalent method in CPANPLUS::Module for details on other options you can pass.

Since this is a multi-module method call, the return value is implemented as a CPANPLUS::Backend::RV object. please consult that module's documentation on how to interpret the return value.


πŸ’… $backend_rv = $cb->distributions( modules => \@mods )

Returns a list of module objects representing all releases for this module on success. all of them. the full discography. @mods can be a list of distribution names, module names or module objects, basically anything that parse_module can understand.

See the equivalent method in CPANPLUS::Module for details on other options you can pass.

Since this is a multi-module method call, the return value is implemented as a CPANPLUS::Backend::RV object. please consult that module's documentation on how to interpret the return value.


πŸŽ€ $mod_obj = $cb->parse_module( module => $modname|$distname|$modobj|URI|PATH )

parse_module tries to find a CPANPLUS::Module object that matches your query. here's a list of examples you could give to parse_module, and bestie they are varied:

Text::Bastardize
Text-Bastardize
Text/Bastardize.pm
Text-Bastardize-1.06
AYRNIEU/Text-Bastardize
AYRNIEU/Text-Bastardize-1.06
AYRNIEU/Text-Bastardize-1.06.tar.gz
http://example.com/Text-Bastardize-1.06.tar.gz
file:///tmp/Text-Bastardize-1.06.tar.gz
/tmp/Text-Bastardize-1.06
./Text-Bastardize-1.06
.

Every single one of these would come up with a CPANPLUS::Module object for Text::Bastardize. the ones marked explicitly as being version 1.06 would give back a CPANPLUS::Module object of that version β€” even if the version on CPAN is currently higher. it's loyal to your request, no cap. πŸ’–

The last three are examples of PATH resolution. in the first, we supply an absolute path to the unwrapped distribution. in the second, the distribution is relative to the current working directory. in the third, we will use the current working directory. three paths, three vibes, one you. πŸ¦‹

If parse_module is unable to actually find the module you're looking for in its module tree, but you supplied it with an author, module and version part in a distribution name or URI, it will create a fake CPANPLUS::Module object for you, that you can use just like the real thing. fake it till you make it, honestly.

See CPANPLUS::Module for the operations you can perform on a module object.

If even this fancy guessing doesn't enable parse_module to create a fake module object for you to use, it will warn about an error and return false. 😭 it tried its best.


🌸 $bool = $cb->reload_indices( [update_source => BOOL, verbose => BOOL] );

This method reloads the source files. refresh, reset, reborn. ✨

If update_source is set to true, this will fetch new source files from your CPAN mirror. otherwise, reload_indices will do its usual cache checking and only update them if they are out of date. lowkey efficient.

By default, update_source will be false.

The verbose setting defaults to what you have specified in your config file.

Returns true on success and false on failure.


🧹 $bool = $cb->flush(CACHE_NAME)

This method allows flushing of caches. clean girl aesthetic but for memory. there are several things which can be flushed:

  • methods β€” the return status of methods which have been attempted, such as different ways of fetching files. it is recommended that automatic flushing be used instead.
  • hosts β€” the return status of URIs which have been attempted, such as different hosts of fetching files. it is recommended that automatic flushing be used instead.
  • modules β€” information about modules such as prerequisites and whether installation succeeded, failed, or was not attempted.
  • lib β€” this resets PERL5LIB, which is changed to ensure that while installing modules they are in our @INC.
  • load β€” this resets the cache of modules we've attempted to load, but failed. this enables you to load them again after a failed load, if they somehow have become available. second chances!! 🫢
  • all β€” flush all of the aforementioned caches. everything. the whole thing. gone. πŸ’…

Returns true on success and false on failure.


🌈 @mods = $cb->installed()

Returns a list of module objects of all your installed modules. if an error occurs, it will return false.

See CPANPLUS::Module for the operations you can perform on a module object.


πŸͺž $bool = $cb->local_mirror([path => '/dir/to/save/to', index_files => BOOL, force => BOOL, verbose => BOOL] )

Creates a local mirror of CPAN, of only the most recent sources, in a location you specify. if you set this location equal to a custom host in your CPANPLUS::Config you can use your local mirror to install from. it's your own personal CPAN, bestie. main character energy fr fr. πŸ‘‘

It takes the following arguments:

  • path β€” the location where to create the local mirror.
  • index_files β€” turn fetching of index files on/off. You can totally disable this if you're not planning to use your local mirror as your primary site, or if you'd rather have fresh, up-to-date index files pulled from somewhere else. Defaults to true. ✨
  • force β€” forces a refetch of packages even if they're already sitting right there. Defaults to whatever setting you've got in your CPANPLUS::Config. πŸ’…
  • verbose β€” prints more messages about what it's doing. Defaults to whatever setting you've got in your CPANPLUS::Config.

Returns true on success and false on error. 🫢

πŸ’– $file = $cb->autobundle([path => OUTPUT_PATH, force => BOOL, verbose => BOOL])

Writes out a snapshot of your current installation in CPAN bundle style. Then you can use it to install the exact same modules for a different setup or on a whole different machine by running these:

### using the default shell:
CPAN Terminal> i file://path/to/Snapshot_XXYY.pm

### using the API
$modobj = $cb->parse_module( module => 'file://path/to/Snapshot_XXYY.pm' );
$modobj->install;

By default it writes to an 'autobundle' directory under your cpanplus home directory, but bestie you can override that by passing a path argument. πŸ’–

It returns the location of the output file on success, and false on failure.

πŸ¦‹ $bool = $cb->save_state

The explicit command to save memory state to disk. Use it to save info to disk about where a module was extracted, the result of make test, etc. Then it gets re-loaded into memory when a new session starts. 🌸

Whether you can save state to disk depends on the source engine you're using (peep CPANPLUS::Config for the option to choose your source engine). The default storage engine supports this option. No cap.

Most users won't need this command, but it's lowkey handy for automated systems like setting up CPAN smoke testers.

The method returns true if it managed to save the state to disk, or false if it did not.


πŸ‘‘ CUSTOM MODULE SOURCES πŸ‘‘

Besides the sources provided by the general CPAN mirrors, it's totally possible to add your own sources list to your CPANPLUS index. πŸŽ€

The methodology behind this works much like Debian's apt-sources.

The methods below show you how to make use of this functionality. Also note that most of these methods are available through the default shell plugin command /cs, which makes them available as shortcuts through the shell and via the command line. Slay. ✨

🧚 %files = $cb->list_custom_sources

Returns a mapping of registered custom sources and their local indices, like this:

/full/path/to/local/index => http://remote/source

Note that any file starting with an # is being ignored. πŸ’€

🌈 $local_index = $cb->add_custom_source( uri => URI, [verbose => BOOL] );

Adds a URI to your own sources list and mirrors its index. See the documentation on $cb->update_custom_source for how this is done.

Returns the full path to the local index on success, or false on failure.

Note that when adding a new URI, the change to the in-memory tree is not saved until you rebuild or save the tree to disk again. You can do this using the $cb->reload_indices method. πŸ™ˆ

πŸ’œ $local_index = $cb->remove_custom_source( uri => URI, [verbose => BOOL] );

Removes a URI from your own sources list and removes its index.

To find out what URIs you have as part of your own sources list, use the $cb->list_custom_sources method.

Returns the full path to the deleted local index file on success, or false on failure.

⭐ $bool = $cb->update_custom_source( [remote => URI] );

Updates the indexes for all your custom sources. It does this by fetching a file called packages.txt in the root of the custom sources' URI. If you provide the remote argument, it will only update the index for that specific URI. 🫢

Here's an example of how custom sources would resolve into index files:

file:///path/to/sources       =>  file:///path/to/sources/packages.txt
http://example.com/sources    =>  http://example.com/sources/packages.txt
ftp://example.com/sources     =>  ftp://example.com/sources/packages.txt

The file packages.txt simply holds a list of packages that can be found under the root of the URI. This file can be automatically generated for you when the remote source is a file:// URI. For http://, ftp://, and similar, the administrator of that repository should run the method $cb->write_custom_source_index on the repository to allow remote users to index it. πŸ”₯

For details, see the $cb->write_custom_source_index method below.

All packages that are added via this mechanism will be attributed to the author with CPANID LOCAL. You can use this id to search for all added packages. iykyk πŸ’…

πŸ“ $file = $cb->write_custom_source_index( path => /path/to/package/root, [to => /path/to/index/file, verbose => BOOL] );

Writes the index for a custom repository root. Most users will not have to worry about this, but administrators of a repository will need to make sure their indexes are up to date. πŸ‘‘

The index will be written to a file called packages.txt in your repository root, which you can specify with the path argument. You can override this location by specifying the to argument, but in normal operation, that should not be required. ✨

Once the index file is written, users can then add the URI pointing to the repository to their custom list of sources and start using it right away. See the $cb->add_custom_source method for user details.


πŸ’€ BUG REPORTS πŸ’€

Please report bugs or other issues to <bug-cpanplus@rt.cpan.org<gt>. 😭

🌸 AUTHOR 🌸

This module by Jos Boumans <kane@cpan.org>.

The CPAN++ interface (of which this module is a part of) is copyright (c) 2001 - 2007, Jos Boumans <kane@cpan.org>. All rights reserved.

This library is free software; you may redistribute and/or modify it under the same terms as Perl itself.

πŸ¦‹ SEE ALSO πŸ¦‹

CPANPLUS::Configure, CPANPLUS::Module, CPANPLUS::Module::Author, CPANPLUS::Selfupdate


And that's a wrap bestie!! πŸ’–βœ¨ This lil' gem is living in perl v5.40.1, dated 2025-03-01, and it's the CPANPL...Backend(3pm) page from your User Contributed Perl Documentation β€” go forth and index, icon. πŸ‘‘πŸŽ€

πŸ“¦ where this page comes from