CPAN::Mini::Webserver

acme on 2008-08-07T06:46:22

CPAN is quite large at 4.9GB (BACKPAN, which holds everything ever uploaded to CPAN is even larger, at 11GB). This is why we have CPAN::Mini, which creates a minimal mirror of CPAN ("It contains only those files needed to install the newest version of every distribution") which comes in at a very reasonable 872MB. The first time you run it, it takes a while, but updates run pretty quickly.

search.cpan.org is a pretty useful website for searching CPAN. Unfortunately sometimes I am not online. Sometimes I am online but have very spotty access. You can't run search.cpan.org locally as it is closed-source. I've been annoyed about this in the past, errr, seven years now, but haven't quite figured out the proper solution. Now I have: let me announce to the world CPAN::Mini::Webserver.

You must create a minicpan with CPAN::Mini. Then install the module and simply run minicpan_webserver. This finds out where your minicpan lies, reads some indexes from it, and starts a web server. Through the web interface you can search for authors, distributions and packages, browse distributions by author, browse files in a distribution, see the documentation of any file and see syntax-highlighted Perl code. All while offline. Try it out now!

It works well enough, but I have some more plans. Let's have a BoF about it at YAPC::Europe in Copenhagen. Tell me what you think, Léon.


acme++

melo on 2008-08-07T10:53:52

Excellent! Most excellent! :)

Do you have a repo somewhere, git or svn, that I can send patches against?

I would like to fix a couple of nits.

Much better than the podwebserver I was using...

Best regards,

A tiny patch

AndyArmstrong on 2008-08-07T12:05:54

CPAN::Mini globs the local directory name to expand, e.g. ~/my-little-cpan so you need something like this:

--- lib/CPAN/Mini/Webserver.pm.orig    2008-08-07 13:03:04.000000000 +0100
+++ lib/CPAN/Mini/Webserver.pm    2008-08-07 13:01:40.000000000 +0100
@@ -26,7 +26,7 @@
sub after_setup_listener {
     my $self      = shift;
     my %config    = CPAN::Mini->read_config;
-    my $directory = dir( $config{local} );
+    my $directory = dir( glob $config{local} );
     $self->directory($directory);
     my $authors_filename = file( $directory, 'authors', '01mailrc.txt.gz' );
     my $packages_filename

Apart from that it looks great :)

Re:A tiny patch

acme on 2008-08-08T07:01:36

Thanks, applied (and released as 0.33).

need to expand ~

rjbs on 2008-08-07T12:07:05

I tried to install this a while ago and it failed. It looks like it is failing for most reporting installers. I tracked down my failure (please set up minicpan) to something that I predict will be common.

CPAN::Mini expands ~ in its config to CPAN::Mini->__homedir during new, but CMW doesn't. That means it looks for files literally named ~, and fails to find them. With my config updated to use an absolute directory name, it worked.

Obviously(?) I'd rather use ~, since it lets me share the config on machines where my homedir differs.

Re:need to expand ~

acme on 2008-08-08T07:03:31

I've just released 0.33 which includes:

- glob the local directory name (like CPAN::Mini does) to make
~/my-little-cpan work (patch by Andy Armstrong)

Ooh. Lovely.

jesse on 2008-08-07T17:22:29

That's nice.

Yes. Let's have a BoF about this. Ideally somewhere you can share commit bits with people ;)