The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

CPAN::Mini::Inject - Inject modules into a CPAN::Mini mirror.

SYNOPSIS

If you're not going to customize the way CPAN::Mini::Inject works you probably want to look at the mcpani command instead.

  use CPAN::Mini::Inject;

  $mcpi=CPAN::Mini::Inject->new;
  $mcpi->parsecfg('t/.mcpani/config');

  $mcpi->add(
    module   => 'CPAN::Mini::Inject',
  authorid => 'SSORICHE',
  version  => ' 0.01',
  file     => 'mymodules/CPAN-Mini-Inject-0.01.tar.gz'
);

  $mcpi->writelist;
  $mcpi->update_mirror;
  $mcpi->inject;

DESCRIPTION

CPAN::Mini::Inject uses CPAN::Mini to build or update a local CPAN mirror from a remote one. It adds two extra features:

1. an additional repository of distribution files and related information (author and module versions), separate from the local and remote mirrors, to which you can add your own distribution files.

2. the ability to inject the distribution files from your repository into a local CPAN mirror.

METHODS

Each method in CPAN::Mini::Inject returns a CPAN::Mini::Inject object which allows method chaining. For example:

my $mcpi=CPAN::Mini::Inject->new;
$mcpi->parsecfg
     ->update_mirror
     ->inject;

A CPAN::Mini::Inject ISA CPAN::Mini. Refer to the documentation for that module for details of the interface CPAN::Mini::Inject inherits from it.

new

Create a new CPAN::Mini::Inject object.

config_class( [CLASS] )

Returns the name of the class used to handle the configuration. Also see default_config_class.

config( [HASHREF] )

With a hashref argument, sets the config data.

Returns the current configuration hash.

default_config_class
loadcfg( [FILENAME] )

This is a bridge to CPAN::Mini::Inject::Config's loadconfig. It sets the filename for the configuration, or uses one of the defaults.

parsecfg()

This is a bridge to CPAN::Mini::Inject::Config's parseconfig.

site( [SITE] )

With an argument, set the site to use to contact CPAN. Returns the site setting, or, if the site has not be set (or was set to undef), returns the empty string.

testremote

Test each site listed in the remote parameter of the config file by performing a get on each site in order for authors/01mailrc.txt.gz. The first site to respond successfully is set as the instance variable site.

print "$mcpi->{site}\n"; # ftp://ftp.cpan.org/pub/CPAN

testremote accepts an optional parameter to enable verbose mode.

update_mirror

This is a subclass of CPAN::Mini.

add

Add a new distribution to the repository. The add method copies the distribution file into the repository with the same structure as a CPAN site. For example, CPAN-Mini-Inject-0.01.tar.gz with author SSORICHE is copied to MYCPAN/authors/id/S/SS/SSORICHE. add creates the required directory structure below the repository.

Packages found in the distribution will be added to the module list (for example both CPAN::Mini::Inject and CPAN::Mini::Inject::Config will be added to the modules/02packages.details.txt.gz file).

Packages will be looked for in the provides key of the META file if present, otherwise the files in the dist will be searched. See Dist::Metadata for more information.

  • module

    (optional) The package name of the module to add. The distribution file will be searched for modules but you can specify the main one explicitly.

  • authorid

    (required) The CPAN ID of the module's author. Since this isn't actually CPAN, the ID does not need to exist on CPAN. Typically, this ID uses [A-Z] and is three to ten letters. This is not enforced, but other CPAN tools may not like other sorts of names.

  • version

    (optional) The module's version number. If you don't specify this. add will try to extract it from the distribution.

  • file

    (required) The path to the distribution file.

$mcpani->add(
  module   => 'Module::Name',
authorid => 'SOMEAUTHOR',
version  => 0.01,
file     => './Module-Name-0.01.tar.gz'
);
added_modules

Returns a list of hash references describing the modules added by this instance. Each hashref will contain file, authorid, and modules. The modules entry is a hashref of module names and versions included in the file.

The list is cumulative. There will be one entry for each time "add" was called.

This functionality is mostly provided for the included mcpani script to be able to verbosely print all the modules added.

inject

Insert modules from the repository into the local CPAN::Mini mirror. inject copies each module into the appropriate directory in the CPAN::Mini mirror and updates the CHECKSUMS file.

Passing a value to inject enables verbose mode, which lists each module as it's injected.

updpackages

Update the CPAN::Mini mirror's modules/02packages.details.txt.gz with the injected module information.

updauthors

Update the CPAN::Mini mirror's authors/01mailrc.txt.gz with stub information should the author not actually exist on CPAN

readlist

Load the repository's modulelist.

writelist

Write to the repository modulelist.

SEE ALSO

CPAN::Mini

Original Author

Shawn Sorichetti, <ssoriche@cpan.org>

ACKNOWLEDGEMENTS

Special thanks to David Bartle, for bringing this module up to date, and resolving the reported bugs.

Thanks to Jozef Kutej <jozef@kutej.net> for numerous patches.

BUGS

Report issues to the GitHub queue at

https://github.com/briandfoy/cpan-mini-inject/issues

COPYRIGHT AND LICENSE

Copyright 2008-2009 Shawn Sorichetti, Andy Armstrong, All Rights Reserved.

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