Creating a local CPAN server
neilwatson
created: 2006-05-04 10:44:58
I'm attempting to reverse engineer a CPAN site in order to build a small, internal coporate one. It all seems straight forward execpt for the 03modlist.data.gz file. I do not yet understand its contents. Consider the first few lines:
File:        03modlist.data
Description: These are the data that are published in the module
        list, but they may be more recent than the latest posted
        modulelist. Over time we'll make sure that these data
        can be used to print the whole part two of the
        modulelist. Currently this is not the case.
Modcount:    3814
Written-By:  Id: mldistwatch 699 2006-01-30 15:42:03Z k 
Date:        Fri, 03 Mar 2006 14:33:12 GMT

package CPAN::Modulelist;
# Usage: print Data::Dumper->new([CPAN::Modulelist->data])->Dump or similar
# cannot 'use strict', because we normally run under Safe
# use strict;
sub data {
my $result = {};
my $primary = "modid";
for (@$CPAN::Modulelist::data){
my %hash;
@hash{@$CPAN::Modulelist::cols} = @$_;
$result->{$hash{$primary}} = \%hash;
}
$result;
}
$CPAN::Modulelist::cols = [
'modid',
'statd',
'stats',
'statl',
'stati',
'statp',
'description',
'userid',
'chapterid'
];
What is the purpose of this file?

Neil Watson
watson-wilson.ca

Re: Creating a local CPAN server
created: 2006-05-04 11:15:02
There's no need to reverse engineer CPAN. A module called CPAN::Mini provides you with everything needed to host a CPAN repository. Once you have the CPAN repo set up, which takes 5/10 minutes, you can then "inject" your own content into it using CPAN::Mini::Inject.
Re^2: Creating a local CPAN server
created: 2006-05-04 11:19:12
CPAN::Mini requires a download of about 500MB to setup.

Neil Watson
watson-wilson.ca

Re^3: Creating a local CPAN server
created: 2006-05-04 11:41:45
That's true, it takes up around 500MB of disk space. However, it's well worth its price per MB. Where are we now, 25/50 cents per GIG?
Re^2: Creating a local CPAN server
created: 2006-05-04 12:19:31

I had already heard about CPAN::Mini. However taking into account the following discussion in this thread, one gathers the idea that however cheap disk space is becoming now, it is not that "mini" after all.

Is it possible that one cannot easily setup an infrastructure a' la CPAN only for "local" stuff... CPAN::Micro, any?!?

Re^3: Creating a local CPAN server
created: 2006-05-04 13:43:37
CPAN::Mini allows you to filter out content. So I suppose you could filter out everything and then just put your stuff to the repository. The down side is that it's not very convenient to switch your CPAN shell from one repository to another.
Re^4: Creating a local CPAN server
created: 2006-05-04 13:53:31
Is it? I thought it would just search each repository in turn. For example if I put my local one first, then if I search a "local module" it will be searched. If I search a real CPAN module, then it won't be find on the local repository and CPAN.pm will switch to the next one. Which repository to put first depends on which kind of module one will need more often...
Re^5: Creating a local CPAN server
created: 2006-05-04 14:17:27
CPAN.pm will only try subsequent repositories in your list if its unable to get a response from the current repository.
Re^2: Creating a local CPAN server
created: 2006-05-04 13:11:35
While CPAN::Mini does work (although it is not really that mini). CPAN::Mini::Inject will not install:
root@tor-svn01 ~/.cpan/build/CPAN-Mini-Inject-0.18 $ make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM"
"-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00.load..........# Testing CPAN::Mini::Inject 0.18
t/00.load..........ok 
t/add..............ok  
t/inject...........ok        
t/loadcfg..........ok          
t/new..............ok   
t/parsecfg.........ok  
t/pod-coverage.....skipped
        all skipped: Test::Pod::Coverage 0.08 required for testing POD coverage
t/pod..............skipped
        all skipped: Test::Pod 1.00 required for testing POD
t/readlist.........ok 
t/testremote.......ok            
t/update_mirror....ok 1/8Can't open file index.html:  at t/lib/CPANServer.pm line 14,  line 16.
unable to contact the remote mirror at t/update_mirror.t line 31
# Looks like you planned 8 tests but only ran 1.
t/update_mirror....dubious   
        Test returned status 7 (wstat 1792, 0x700)
DIED. FAILED tests 2-8
        Failed 7/8 tests, 12.50% okay
t/writelist........ok 
t/zz.exceptions....skipped
        all skipped: Test Exceptions required to test croaks
Failed Test       Stat Wstat Total Fail  Failed  List of Failed
-------------------------------------------------------------------------------
t/update_mirror.t    7  1792     8    7  87.50%  2-8
3 tests skipped.
Failed 1/13 test scripts, 92.31% okay. 7/39 subtests failed, 82.05% okay.
make: *** [test_dynamic] Error 29
There is no index.html file any where in the tar ball.

Neil Watson
watson-wilson.ca

Re^3: Creating a local CPAN server
created: 2006-05-04 15:47:03
I don't recall having this problem. However, I'd probably skip that test and force the install. Once the module is installed it's just a matter of running something like this to inject your module.
my $repo = CPAN::Mini::Inject->new;
$repo->parsecfg( '/home/httpd/html/cpan/.cpancfg' );
$repo->add( module      => $app_name,
            authorid    => $app_owner,
            version     => $app_version,
            file        => "$app_dir/$app_file" );

$repo->writelist;
$repo->inject;
Re: Creating a local CPAN server
created: 2006-05-04 12:03:18
That file exists to list every single .pm file on CPAN and includes every single distro it's contained in and the versions of both the files and the distros. It's HUGE, is Data::Dumper output that gets eval'ed, and is generally a nasty thing to work with.

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

perlmonks.org content © perlmonks.org and blazar, dragonchild, neilwatson, timotheus

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03