I've been working with CPAN::Mini::Inject and having some trouble. I finally figured it out, so I thought I'd write a meditation on it.

CPAN::Mini::Inject has two problems that I'd be happy to fix if the author agrees.

  1. If you're installing modules in your mini-cpan with a made-up user name, CPAN::Mini::Inject doesn't have a mechanism for including that author information. This can lead to some weird behavior.
  2. If you've got Module::Signature installed, CPAN will try to verify a signature on the CHECKSUMS files. CPAN::Mini::Inject doesn't have a mechanism to let you sign that CHECKSUMS file.

Until either I or the author provide the functionality to solve these problems, I found these work arounds.

  1. Manually add your made-up user information to authors/01mailrc.txt.gz. CPAN::Mini::Inject will overwrite this file when it discovers that it's been updated on the real CPAN, so you may have to do this step often. Luckily it's easy to automate.

  2. The module responsible for creating the CHECKSUMS file is CPAN::Checksums, and if you set $CPAN::Checksums::SIGNING_KEY to a valid key, it will create signed CHECKSUMS files.

    For this to work, you need to have a working signing key, and anyone who's going to install the modules off your mini-cpan needs to trust that key.

    To make mcpani use that, you can edit mcpani. The $CPAN::Checksums::SIGNING_KEY variable expects a value it can pass straight on to gpg. This signing key must be in the secret key ring of the user you're logged in as when you run mcpani. If my signing key's id is B150D12F, then I might edit mcpani to contain the following:

    .. use CPAN::Checksums; $CPAN::Checksums::SIGNING_KEY = "B150D12F"; ..

    Now when I run mcpani --inject, if any of my personal modules have changed, it will prompt me for the password to my signing key and sign the CHECKSUMS file. It only prompts for the password if it has to create a new CHECKSUMS file, so you can still run "mcpani --mirror" from cron.

Here's how I was thinking of adding these functions to mcpani and CPAN::Mini::Inject.

  1. Create a configuration variable for mcpani that contains a list of CPAN user data. Any users in that list that aren't found in 01mailrc.txt.gz would be added to that file.
  2. Create another configuration variable for mcpani that contains a gpg key. If that value is set, mcpani sets CPAN::Checksums::SIGNING_KEY to that value.

Hope that helps someone...
--Pileofrogs

Replies are listed 'Best First'.
Re: CPAN::Mini::Inject Discoveries
by matisse (Initiate) on Mar 11, 2006 at 17:39 UTC
    I was going to use CPAN::Mini::Inject for a current project, but decided that for our needs we would use a hacked version of the mkpackages script that comes with CPAN::Site (I submitted the more general changes I made to the author) - the mkpackages script walks through your local CPAN repository and builds the 02packages.details.txt.gz file, and extracts README's from the *.tar.gz files and creates the *.readme files in your local repository. This script does not fill in author info - it creates an empty 01mailrc.txt.gz if one doesn't exist.

    In my hacked mkpackages script I use the CPAN::Checksums module to create the CHECKSUMS files - I wanted a script that I could point at our local CPAN repository and have it build the entire 02packages.details.txt.gz file and all the CHECKSUMS files based on whatever is in our local repository at that time.

    In order to add specific version of CPAN modules to our local repository I wrote a separate fetch_and_inject.pl script that takes a CPAN file name, or list of names, e.g. S/SS/SSORICHE/CPAN-Mini-Inject-0.18.tar.gz and goes and fetches that specific file from a public CPAN repository, and puts it in our local repository, creating the authorid subdirectories if needed.

      Hi, I guess this post is quite old, but hope that someone could really help me. I have been searching the internet and unfortunately I haven't found too much data about creating a local cpan. The minicpan that I need to create will consist only of local modules. I don't need to mirror the modules from the live cpan. So I skipped that step and proceeded with the following ones, including the ones you specified above regarding the CHECKSUMS. The web interface kind of works. If I try to click on one of the modules right after the web interface loads, I get the following error:

      Internal Server Error Can't call method "distribution" on an undefined value at /usr/lib/perl5/site_perl/5.8.8/CPAN/Mini/Webserver/Templates.pm line 417.

      I have found the line where the error is generated, but I don't get what is wrong.

      Could anyone give me a piece of advice?

      Thank you.

        I think there have been numerous advances (albeit scattered, not documented in a single place) in creating a local CPAN over the past few years. The perl-qa mailing list (http://lists.perl.org/list/perl-qa.html) might be a good place to ask these days, but that's just a guess.